Merge master.
[dcpomatic.git] / src / wx / imagemagick_content_dialog.cc
index 726e4b8e2c5db315fc21eaa84ba7e6d6494b329f..6aa75626059dcc1dd84500c7efddceaceb582fd8 100644 (file)
 #include "wx_util.h"
 
 using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
 
 ImageMagickContentDialog::ImageMagickContentDialog (wxWindow* parent, shared_ptr<ImageMagickContent> content)
        : wxDialog (parent, wxID_ANY, _("Image"))
+       , _content (content)
 {
        wxFlexGridSizer* grid = new wxFlexGridSizer (3, 6, 6);
        grid->AddGrowableCol (1, 1);
 
        {
-               add_label_to_sizer (grid, this, (_("Duration")));
+               add_label_to_sizer (grid, this, _("Duration"), true);
                wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
                _video_length = new wxSpinCtrl (this);
                s->Add (_video_length);
                /// TRANSLATORS: this is an abbreviation for seconds, the unit of time
-               add_label_to_sizer (s, this, _("s"));
+               add_label_to_sizer (s, this, _("s"), false);
                grid->Add (s);
        }
 
@@ -53,10 +55,16 @@ ImageMagickContentDialog::ImageMagickContentDialog (wxWindow* parent, shared_ptr
        overall_sizer->SetSizeHints (this);
 
        checked_set (_video_length, content->video_length () / 24);
+       _video_length->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (ImageMagickContentDialog::video_length_changed), 0, this);
 }
 
-int
-ImageMagickContentDialog::video_length () const
+void
+ImageMagickContentDialog::video_length_changed (wxCommandEvent &)
 {
-       return _video_length->GetValue ();
+       shared_ptr<ImageMagickContent> c = _content.lock ();
+       if (!c) {
+               return;
+       }
+       
+       c->set_video_length (_video_length->GetValue() * 24);
 }