Make length editable only for still images.
authorCarl Hetherington <cth@carlh.net>
Tue, 30 Jul 2013 19:14:47 +0000 (20:14 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 30 Jul 2013 19:14:47 +0000 (20:14 +0100)
src/wx/timecode.cc
src/wx/timecode.h
src/wx/timing_panel.cc

index f826dd93fe99751487c583f70dd609a75fff77a6..033bd2bd01e97f29965829c8c28c20bd37fa2a3b 100644 (file)
@@ -42,26 +42,33 @@ Timecode::Timecode (wxWindow* parent)
        }
 
        validator.SetIncludes (list);
+
+       _sizer = new wxBoxSizer (wxHORIZONTAL);
        
-       wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
-       _hours = new wxTextCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator);
+       _editable = new wxPanel (this);
+       wxSizer* editable_sizer = new wxBoxSizer (wxHORIZONTAL);
+       _hours = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator);
        _hours->SetMaxLength (2);
-       sizer->Add (_hours);
-       add_label_to_sizer (sizer, this, wxT (":"), false);
-       _minutes = new wxTextCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator);
+       editable_sizer->Add (_hours);
+       add_label_to_sizer (editable_sizer, _editable, wxT (":"), false);
+       _minutes = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator);
        _minutes->SetMaxLength (2);
-       sizer->Add (_minutes);
-       add_label_to_sizer (sizer, this, wxT (":"), false);
-       _seconds = new wxTextCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator);
+       editable_sizer->Add (_minutes);
+       add_label_to_sizer (editable_sizer, _editable, wxT (":"), false);
+       _seconds = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator);
        _seconds->SetMaxLength (2);
-       sizer->Add (_seconds);
-       add_label_to_sizer (sizer, this, wxT ("."), false);
-       _frames = new wxTextCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator);
+       editable_sizer->Add (_seconds);
+       add_label_to_sizer (editable_sizer, _editable, wxT ("."), false);
+       _frames = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator);
        _frames->SetMaxLength (2);
-       sizer->Add (_frames);
-       _set_button = new wxButton (this, wxID_ANY, _("Set"));
-       sizer->Add (_set_button, 0, wxLEFT | wxRIGHT, 8);
+       editable_sizer->Add (_frames);
+       _set_button = new wxButton (_editable, wxID_ANY, _("Set"));
+       editable_sizer->Add (_set_button, 0, wxLEFT | wxRIGHT, 8);
+       _editable->SetSizerAndFit (editable_sizer);
+       _sizer->Add (_editable);
 
+       _fixed = add_label_to_sizer (_sizer, this, wxT ("42"), false);
+       
        _hours->Bind      (wxEVT_COMMAND_TEXT_UPDATED,   boost::bind (&Timecode::changed, this));
        _minutes->Bind    (wxEVT_COMMAND_TEXT_UPDATED,   boost::bind (&Timecode::changed, this));
        _seconds->Bind    (wxEVT_COMMAND_TEXT_UPDATED,   boost::bind (&Timecode::changed, this));
@@ -69,8 +76,10 @@ Timecode::Timecode (wxWindow* parent)
        _set_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&Timecode::set_clicked, this));
 
        _set_button->Enable (false);
-       
-       SetSizerAndFit (sizer);
+
+       set_editable (true);
+
+       SetSizerAndFit (_sizer);
 }
 
 void
@@ -88,6 +97,8 @@ Timecode::set (Time t, int fps)
        checked_set (_minutes, lexical_cast<string> (m));
        checked_set (_seconds, lexical_cast<string> (s));
        checked_set (_frames, lexical_cast<string> (f));
+
+       _fixed->SetLabel (wxString::Format ("%02d:%02d:%02d.%02d", h, m, s, f));
 }
 
 Time
@@ -118,3 +129,11 @@ Timecode::set_clicked ()
        Changed ();
        _set_button->Enable (false);
 }
+
+void
+Timecode::set_editable (bool e)
+{
+       _editable->Show (e);
+       _fixed->Show (!e);
+       _sizer->Layout ();
+}
index bebfa3f5f8d2f00c3cdea476a5b7e6fde8f9b9ae..5b094e39f0c2c3cf6d67d36eba70a804acf73017 100644 (file)
@@ -29,16 +29,22 @@ public:
        void set (Time, int);
        Time get (int) const;
 
+       void set_editable (bool);
+
        boost::signals2::signal<void ()> Changed;
 
 private:
        void changed ();
        void set_clicked ();
        
+       wxSizer* _sizer;
+       wxPanel* _editable;
        wxTextCtrl* _hours;
+       wxStaticText* _hours_label;
        wxTextCtrl* _minutes;
        wxTextCtrl* _seconds;
        wxTextCtrl* _frames;
        wxButton* _set_button;
+       wxStaticText* _fixed;
 };
 
index ee62797e3078dfb3f29506fcd8da93fe28dc39c2..313543d2d0cccddacd3598f4bc3c6bcfedbe1988 100644 (file)
@@ -24,6 +24,7 @@
 #include "timecode.h"
 #include "film_editor.h"
 
+using std::cout;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 
@@ -60,6 +61,8 @@ TimingPanel::film_content_changed (shared_ptr<Content> content, int property)
                        _length->set (0, 24);
                }
        }
+
+       _length->set_editable (dynamic_pointer_cast<StillImageContent> (content));
 }
 
 void