Add background image configuration to swaroop variant.
authorCarl Hetherington <cth@carlh.net>
Wed, 26 Sep 2018 12:51:05 +0000 (13:51 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 26 Sep 2018 12:51:05 +0000 (13:51 +0100)
src/lib/config.cc
src/lib/config.h
src/wx/player_config_dialog.cc

index 5e953382dadb26ed99726fe2f9a844d67a07d9ee..b61b1d054db99b9badb5299d4fb2449750399fa1 100644 (file)
@@ -169,6 +169,9 @@ Config::set_defaults ()
        _player_log_file = boost::none;
        _player_dcp_directory = boost::none;
        _player_kdm_directory = boost::none;
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       _player_background_image = boost::none;
+#endif
 
        _allowed_dcp_frame_rates.clear ();
        _allowed_dcp_frame_rates.push_back (24);
@@ -501,6 +504,9 @@ try
        _player_log_file = f.optional_string_child("PlayerLogFile");
        _player_dcp_directory = f.optional_string_child("PlayerDCPDirectory");
        _player_kdm_directory = f.optional_string_child("PlayerKDMDirectory");
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       _player_background_image = f.optional_string_child("PlayerBackgroundImage");
+#endif
 
        /* Replace any cinemas from config.xml with those from the configured file */
        if (boost::filesystem::exists (_cinemas_file)) {
@@ -898,6 +904,11 @@ Config::write_config () const
        if (_player_kdm_directory) {
                root->add_child("PlayerKDMDirectory")->add_child_text(_player_kdm_directory->string());
        }
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       if (_player_background_image) {
+               root->add_child("PlayerBackgroundImage")->add_child_text(_player_background_image->string());
+       }
+#endif
 
        try {
                doc.write_to_file_formatted(config_file().string());
index 60e85c5f362dc1bfa2c0d8983458c758290342ef..04f521575b23b3553b5024faf53f3465fda99e39 100644 (file)
@@ -490,6 +490,12 @@ public:
                return _player_kdm_directory;
        }
 
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       boost::optional<boost::filesystem::path> player_background_image () const {
+               return _player_background_image;
+       }
+#endif
+
        /* SET (mostly) */
 
        void set_master_encoding_threads (int n) {
@@ -936,6 +942,20 @@ public:
                changed ();
        }
 
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       void set_player_background_image (boost::filesystem::path p) {
+               maybe_set (_player_background_image, p);
+       }
+
+       void unset_player_background_image () {
+               if (!_player_background_image) {
+                       return;
+               }
+               _player_background_image = boost::none;
+               changed ();
+       }
+#endif
+
        void changed (Property p = OTHER);
        boost::signals2::signal<void (Property)> Changed;
        /** Emitted if read() failed on an existing Config file.  There is nothing
@@ -1128,6 +1148,9 @@ private:
        */
        boost::optional<boost::filesystem::path> _player_dcp_directory;
        boost::optional<boost::filesystem::path> _player_kdm_directory;
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       boost::optional<boost::filesystem::path> _player_background_image;
+#endif
 
        static int const _current_version;
 
index a34f0bd3b4a897a78c544051a5a75391c33653dd..a24dbc88022823e8c5b86a8975b24fe38cc9f023 100644 (file)
@@ -120,12 +120,22 @@ private:
                table->Add (_kdm_directory, wxGBPosition (r, 1));
                ++r;
 
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+               add_label_to_sizer (table, _panel, _("Background image"), true, wxGBPosition (r, 0));
+               _background_image = new FilePickerCtrl (_panel, _("Select image file"), "*.png;*.jpg;*.jpeg;*.tif;*.tiff", true);
+               table->Add (_background_image, wxGBPosition (r, 1));
+               ++r;
+#endif
+
                _player_mode->Bind (wxEVT_CHOICE, bind(&PlayerGeneralPage::player_mode_changed, this));
                _image_display->Bind (wxEVT_CHOICE, bind(&PlayerGeneralPage::image_display_changed, this));
                _respect_kdm->Bind (wxEVT_CHECKBOX, bind(&PlayerGeneralPage::respect_kdm_changed, this));
                _log_file->Bind (wxEVT_FILEPICKER_CHANGED, bind(&PlayerGeneralPage::log_file_changed, this));
                _dcp_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&PlayerGeneralPage::dcp_directory_changed, this));
                _kdm_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&PlayerGeneralPage::kdm_directory_changed, this));
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+               _background_image->Bind (wxEVT_DIRPICKER_CHANGED, bind(&PlayerGeneralPage::background_image_changed, this));
+#endif
        }
 
        void config_changed ()
@@ -157,6 +167,11 @@ private:
                if (config->player_kdm_directory()) {
                        checked_set (_kdm_directory, *config->player_kdm_directory());
                }
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+               if (config->player_background_image()) {
+                       checked_set (_background_image, *config->player_background_image());
+               }
+#endif
        }
 
 private:
@@ -200,12 +215,22 @@ private:
                Config::instance()->set_player_kdm_directory(wx_to_std(_kdm_directory->GetPath()));
        }
 
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       void background_image_changed ()
+       {
+               Config::instance()->set_player_background_image(wx_to_std(_background_image->GetPath()));
+       }
+#endif
+
        wxChoice* _player_mode;
        wxChoice* _image_display;
        wxCheckBox* _respect_kdm;
        FilePickerCtrl* _log_file;
        wxDirPickerCtrl* _dcp_directory;
        wxDirPickerCtrl* _kdm_directory;
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       FilePickerCtrl* _background_image;
+#endif
 };
 
 wxPreferencesEditor*