Add option to force short screen layout (#2946).
authorCarl Hetherington <cth@carlh.net>
Wed, 15 Jan 2025 23:37:22 +0000 (00:37 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 18 Jan 2025 23:44:06 +0000 (00:44 +0100)
src/lib/config.cc
src/lib/config.h
src/wx/full_config_dialog.cc
src/wx/wx_util.cc
test/data

index aa7c79bbe1934036ad10288c40ce333812bc2125..aa783b7a244e014732fc007305c386f530e94e42 100644 (file)
@@ -222,6 +222,7 @@ Config::set_defaults ()
        _enable_player_http_server = false;
        _player_http_server_port = 8080;
        _relative_paths = false;
+       _layout_for_short_screen = false;
 
        _allowed_dcp_frame_rates.clear ();
        _allowed_dcp_frame_rates.push_back (24);
@@ -662,6 +663,7 @@ try
        _enable_player_http_server = f.optional_bool_child("EnablePlayerHTTPServer").get_value_or(false);
        _player_http_server_port = f.optional_number_child<int>("PlayerHTTPServerPort").get_value_or(8080);
        _relative_paths = f.optional_bool_child("RelativePaths").get_value_or(false);
+       _layout_for_short_screen = f.optional_bool_child("LayoutForShortScreen").get_value_or(false);
 
 #ifdef DCPOMATIC_GROK
        if (auto grok = f.optional_node_child("Grok")) {
@@ -1139,6 +1141,8 @@ Config::write_config () const
        cxml::add_text_child(root, "PlayerHTTPServerPort", fmt::to_string(_player_http_server_port));
        /* [XML] RelativePaths 1 to write relative paths to project metadata files, 0 to use absolute paths */
        cxml::add_text_child(root, "RelativePaths", _relative_paths ? "1" : "0");
+       /* [XML] LayoutForShortScreen 1 to set up DCP-o-matic as if the screen were less than 800 pixels high */
+       cxml::add_text_child(root, "LayoutForShortScreen", _layout_for_short_screen ? "1" : "0");
 
 #ifdef DCPOMATIC_GROK
        if (_grok) {
index 794e39ec735d9881f982b3e6b9f240c007a1b6db..ba3e1cdd8b5beaa2ae545febbae82f21c1c2056d 100644 (file)
@@ -681,6 +681,10 @@ public:
                return _relative_paths;
        }
 
+       bool layout_for_short_screen() {
+               return _layout_for_short_screen;
+       }
+
        /* SET (mostly) */
 
        void set_master_encoding_threads (int n) {
@@ -1232,6 +1236,10 @@ public:
                maybe_set(_relative_paths, relative);
        }
 
+       void set_layout_for_short_screen(bool layout) {
+               maybe_set(_layout_for_short_screen, layout);
+       }
+
 
        void changed (Property p = OTHER);
        boost::signals2::signal<void (Property)> Changed;
@@ -1473,6 +1481,7 @@ private:
        bool _enable_player_http_server;
        int _player_http_server_port;
        bool _relative_paths;
+       bool _layout_for_short_screen;
 
 #ifdef DCPOMATIC_GROK
        boost::optional<Grok> _grok;
index 0291d4fa603edde7529c6510b790ad88423e1f07..2b7eaac9dd7cda591492a40e9de78866d99c098b 100644 (file)
@@ -1567,6 +1567,10 @@ private:
                table->Add (_only_servers_encode, 1, wxEXPAND | wxLEFT, DCPOMATIC_SIZER_GAP);
                table->AddSpacer (0);
 
+               _layout_for_short_screen = new CheckBox(_panel, _("Layout for short screen"));
+               table->Add(_layout_for_short_screen, 1, wxEXPAND | wxLEFT, DCPOMATIC_SIZER_GAP);
+               table->AddSpacer (0);
+
                {
                        add_label_to_sizer (table, _panel, _("Maximum number of frames to store per thread"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
                        auto s = new wxBoxSizer (wxHORIZONTAL);
@@ -1659,6 +1663,7 @@ private:
                _video_display_mode->Bind (wxEVT_CHOICE, boost::bind(&AdvancedPage::video_display_mode_changed, this));
                _show_experimental_audio_processors->bind(&AdvancedPage::show_experimental_audio_processors_changed, this);
                _only_servers_encode->bind(&AdvancedPage::only_servers_encode_changed, this);
+               _layout_for_short_screen->bind(&AdvancedPage::layout_for_short_screen_changed, this);
                _frames_in_memory_multiplier->Bind (wxEVT_SPINCTRL, boost::bind(&AdvancedPage::frames_in_memory_multiplier_changed, this));
                _dcp_metadata_filename_format->Changed.connect (boost::bind (&AdvancedPage::dcp_metadata_filename_format_changed, this));
                _dcp_asset_filename_format->Changed.connect (boost::bind (&AdvancedPage::dcp_asset_filename_format_changed, this));
@@ -1691,6 +1696,7 @@ private:
                }
                checked_set (_show_experimental_audio_processors, config->show_experimental_audio_processors ());
                checked_set (_only_servers_encode, config->only_servers_encode ());
+               checked_set (_layout_for_short_screen, config->layout_for_short_screen());
                checked_set (_log_general, config->log_types() & LogEntry::TYPE_GENERAL);
                checked_set (_log_warning, config->log_types() & LogEntry::TYPE_WARNING);
                checked_set (_log_error, config->log_types() & LogEntry::TYPE_ERROR);
@@ -1731,6 +1737,11 @@ private:
                Config::instance()->set_only_servers_encode (_only_servers_encode->GetValue());
        }
 
+       void layout_for_short_screen_changed()
+       {
+               Config::instance()->set_layout_for_short_screen(_layout_for_short_screen->GetValue());
+       }
+
        void dcp_metadata_filename_format_changed ()
        {
                Config::instance()->set_dcp_metadata_filename_format(_dcp_metadata_filename_format->get());
@@ -1788,6 +1799,7 @@ private:
        wxSpinCtrl* _frames_in_memory_multiplier = nullptr;
        CheckBox* _show_experimental_audio_processors = nullptr;
        CheckBox* _only_servers_encode = nullptr;
+       CheckBox* _layout_for_short_screen = nullptr;
        NameFormatEditor* _dcp_metadata_filename_format = nullptr;
        NameFormatEditor* _dcp_asset_filename_format = nullptr;
        CheckBox* _log_general = nullptr;
index e82ca8e1b97e442f2ae848f933cf520d7317f34f..b1cd873fc0d78b6baac892f9c636159df04aaa5a 100644 (file)
@@ -834,6 +834,10 @@ wx::report_problem()
 bool
 layout_for_short_screen(wxWindow* reference)
 {
+       if (Config::instance()->layout_for_short_screen()) {
+               return true;
+       }
+
        auto const sn = wxDisplay::GetFromWindow(reference);
        return sn >= 0 && wxDisplay(sn).GetClientArea().height <= 800;
 }
index c2ad073f0bf7105fb628dbbe2eb82d92bc800dcc..8cf2d01f470c8e5be3ab4a241dd88236c041a5c0 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit c2ad073f0bf7105fb628dbbe2eb82d92bc800dcc
+Subproject commit 8cf2d01f470c8e5be3ab4a241dd88236c041a5c0