Various more hacks; basically trying to remove Regions as an unnecessary complexity.
[dcpomatic.git] / src / wx / imagemagick_content_dialog.cc
index 726e4b8e2c5db315fc21eaa84ba7e6d6494b329f..52f3cf1a78d4c28855618621682fcf781dc7a12f 100644 (file)
@@ -1,3 +1,5 @@
+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
 /*
     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
 
 #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);
@@ -53,10 +57,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);
 }