Add default scaling setting to preferences (#384).
authorCarl Hetherington <cth@carlh.net>
Wed, 16 Jul 2014 16:01:46 +0000 (17:01 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 16 Jul 2014 16:01:46 +0000 (17:01 +0100)
src/lib/config.cc
src/lib/config.h
src/lib/video_content.cc
src/wx/config_dialog.cc

index 24f9242ec259afdfb93ff3c04eef98b0b9738ca9..0588f01dabf59acfe6370985520c19e39e7a4ae6 100644 (file)
@@ -63,6 +63,7 @@ Config::Config ()
        , _sound_processor (SoundProcessor::from_id (N_("dolby_cp750")))
        , _allow_any_dcp_frame_rate (false)
        , _default_still_length (10)
+       , _default_scale (Ratio::from_id ("185"))
        , _default_container (Ratio::from_id ("185"))
        , _default_dcp_content_type (DCPContentType::from_isdcf_name ("TST"))
        , _default_j2k_bandwidth (100000000)
@@ -133,6 +134,11 @@ Config::read ()
 
        _language = f.optional_string_child ("Language");
 
+       c = f.optional_string_child ("DefaultScale");
+       if (c) {
+               _default_scale = Ratio::from_id (c.get ());
+       }
+
        c = f.optional_string_child ("DefaultContainer");
        if (c) {
                _default_container = Ratio::from_id (c.get ());
@@ -341,6 +347,9 @@ Config::write () const
        if (_language) {
                root->add_child("Language")->add_child_text (_language.get());
        }
+       if (_default_scale) {
+               root->add_child("DefaultScale")->add_child_text (_default_scale->id ());
+       }
        if (_default_container) {
                root->add_child("DefaultContainer")->add_child_text (_default_container->id ());
        }
index 85e419a0a0348b53e3a19e643539832b8f3d1ce4..44936172c3a821b6c8efa96b9acd15d0552d5b58 100644 (file)
@@ -133,6 +133,10 @@ public:
                return _default_still_length;
        }
 
+       Ratio const * default_scale () const {
+               return _default_scale;
+       }
+
        Ratio const * default_container () const {
                return _default_container;
        }
@@ -282,6 +286,11 @@ public:
                changed ();
        }
 
+       void set_default_scale (Ratio const * s) {
+               _default_scale = s;
+               changed ();
+       }
+
        void set_default_container (Ratio const * c) {
                _default_container = c;
                changed ();
@@ -413,6 +422,7 @@ private:
        ISDCFMetadata _default_isdcf_metadata;
        boost::optional<std::string> _language;
        int _default_still_length;
+       Ratio const * _default_scale;
        Ratio const * _default_container;
        DCPContentType const * _default_dcp_content_type;
        libdcp::XMLMetadata _dcp_metadata;
index 02cc1f810dd6fc114f10ed738a16b6c5e42c1d58..15e1ca7911982b9dc811de4481f7f386e9035688 100644 (file)
@@ -61,7 +61,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f)
        , _original_video_frame_rate (0)
        , _video_frame_rate (0)
        , _video_frame_type (VIDEO_FRAME_TYPE_2D)
-       , _scale (Ratio::from_id ("185"))
+       , _scale (Config::instance()->default_scale ())
 {
        setup_default_colour_conversion ();
 }
@@ -72,7 +72,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f, Time s, VideoContent::Fram
        , _original_video_frame_rate (0)
        , _video_frame_rate (0)
        , _video_frame_type (VIDEO_FRAME_TYPE_2D)
-       , _scale (Ratio::from_id ("185"))
+       , _scale (Config::instance()->default_scale ())
 {
        setup_default_colour_conversion ();
 }
@@ -83,7 +83,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f, boost::filesystem::path p)
        , _original_video_frame_rate (0)
        , _video_frame_rate (0)
        , _video_frame_type (VIDEO_FRAME_TYPE_2D)
-       , _scale (Ratio::from_id ("185"))
+       , _scale (Config::instance()->default_scale ())
 {
        setup_default_colour_conversion ();
 }
index 5d1b32038290549b5263b2fc0f83aac43b6db454..00f6a2668cfcfb7f3308beed638fa43e1cb8845e 100644 (file)
@@ -266,6 +266,10 @@ public:
                add_label_to_sizer (table, panel, _("Default ISDCF name details"), true);
                _isdcf_metadata_button = new wxButton (panel, wxID_ANY, _("Edit..."));
                table->Add (_isdcf_metadata_button);
+
+               add_label_to_sizer (table, panel, _("Default scale to"), true);
+               _scale = new wxChoice (panel, wxID_ANY);
+               table->Add (_scale);
                
                add_label_to_sizer (table, panel, _("Default container"), true);
                _container = new wxChoice (panel, wxID_ANY);
@@ -315,6 +319,10 @@ public:
                vector<Ratio const *> ratio = Ratio::all ();
                int n = 0;
                for (vector<Ratio const *>::iterator i = ratio.begin(); i != ratio.end(); ++i) {
+                       _scale->Append (std_to_wx ((*i)->nickname ()));
+                       if (*i == config->default_scale ()) {
+                               _scale->SetSelection (n);
+                       }
                        _container->Append (std_to_wx ((*i)->nickname ()));
                        if (*i == config->default_container ()) {
                                _container->SetSelection (n);
@@ -322,6 +330,7 @@ public:
                        ++n;
                }
                
+               _scale->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DefaultsPage::scale_changed, this));
                _container->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DefaultsPage::container_changed, this));
                
                vector<DCPContentType const *> const ct = DCPContentType::all ();
@@ -380,6 +389,12 @@ private:
        {
                Config::instance()->set_default_still_length (_still_length->GetValue ());
        }
+
+       void scale_changed ()
+       {
+               vector<Ratio const *> ratio = Ratio::all ();
+               Config::instance()->set_default_scale (ratio[_scale->GetSelection()]);
+       }
        
        void container_changed ()
        {
@@ -416,6 +431,7 @@ private:
 #else
        wxDirPickerCtrl* _directory;
 #endif
+       wxChoice* _scale;
        wxChoice* _container;
        wxChoice* _dcp_content_type;
        wxTextCtrl* _issuer;