From 921e681d6e4bde33c6652905dcebf4e7259cf14e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 16 Jan 2025 00:14:46 +0100 Subject: Extract layout_for_short_screen(). --- src/tools/dcpomatic_kdm.cc | 13 +++---------- src/wx/wx_util.cc | 10 ++++++++++ src/wx/wx_util.h | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 0c0af4a96..d554107cd 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -62,7 +62,6 @@ #include #include LIBDCP_DISABLE_WARNINGS -#include #include #include #include @@ -228,15 +227,9 @@ public: h->SetFont (subheading_font); right->Add(h, 0, wxTOP, DCPOMATIC_SUBHEADING_TOP_PAD); - int const sn = wxDisplay::GetFromWindow(this); - if (sn >= 0) { - auto const screen = wxDisplay(sn).GetClientArea(); - if (screen.height <= 800) { - _output = new ShortKDMOutputPanel(overall_panel); - } - } - - if (!_output) { + if (layout_for_short_screen(this)) { + _output = new ShortKDMOutputPanel(overall_panel); + } else { _output = new TallKDMOutputPanel(overall_panel); } diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index fc8b3dc99..e82ca8e1b 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -42,6 +42,7 @@ #include #include LIBDCP_DISABLE_WARNINGS +#include #include #include #include @@ -828,3 +829,12 @@ wx::report_problem() { return std_to_wx(::report_problem()); } + + +bool +layout_for_short_screen(wxWindow* reference) +{ + auto const sn = wxDisplay::GetFromWindow(reference); + return sn >= 0 && wxDisplay(sn).GetClientArea().height <= 800; +} + diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index b6907310d..a101a8498 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -125,6 +125,7 @@ extern bool gui_is_dark (); extern double dpi_scale_factor (wxWindow* window); extern int search_ctrl_height (); extern void report_config_load_failure(wxWindow* parent, Config::LoadFailure what); +extern bool layout_for_short_screen(wxWindow* reference); struct Offset -- cgit v1.2.3