Split timing panel into its own class.
authorCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 19:21:27 +0000 (20:21 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 19:21:27 +0000 (20:21 +0100)
src/wx/film_editor.cc
src/wx/film_editor.h
src/wx/timing_panel.cc [new file with mode: 0644]
src/wx/timing_panel.h [new file with mode: 0644]
src/wx/wscript

index 8ae63bd4bfad1c6d6878b9366694bd661fc4f26a..9030c6cdc7c474ffac94054a5d85b5f30285adfc 100644 (file)
@@ -50,6 +50,7 @@
 #include "audio_dialog.h"
 #include "timeline_dialog.h"
 #include "audio_mapping_view.h"
+#include "timing_panel.h"
 
 using std::string;
 using std::cout;
@@ -241,8 +242,6 @@ FilmEditor::connect_to_widgets ()
        _sequence_video->Connect         (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::sequence_video_changed), 0, this);
                
        _audio_mapping->Changed.connect  (boost::bind (&FilmEditor::audio_mapping_changed, this, _1));
-       _start->Changed.connect          (boost::bind (&FilmEditor::start_changed, this));
-       _length->Changed.connect         (boost::bind (&FilmEditor::length_changed, this));
 }
 
 void
@@ -348,8 +347,7 @@ FilmEditor::make_content_panel ()
        _content_notebook->AddPage (_audio_panel, _("Audio"), false);
        make_subtitle_panel ();
        _content_notebook->AddPage (_subtitle_panel, _("Subtitles"), false);
-       make_timing_panel ();
-       _content_notebook->AddPage (_timing_panel, _("Timing"), false);
+       _timing_panel = new TimingPanel (this);
 }
 
 void
@@ -448,24 +446,6 @@ FilmEditor::make_subtitle_panel ()
        _subtitle_scale->SetValue (100);
 }
 
-void
-FilmEditor::make_timing_panel ()
-{
-       _timing_panel = new wxPanel (_content_notebook);
-       wxBoxSizer* timing_sizer = new wxBoxSizer (wxVERTICAL);
-       _timing_panel->SetSizer (timing_sizer);
-       wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4);
-       timing_sizer->Add (grid, 0, wxALL, 8);
-
-       add_label_to_sizer (grid, _timing_panel, _("Start time"), true);
-       _start = new Timecode (_timing_panel);
-       grid->Add (_start);
-       add_label_to_sizer (grid, _timing_panel, _("Length"), true);
-       _length = new Timecode (_timing_panel);
-       grid->Add (_length);
-}
-
-
 /** Called when the left crop widget has been changed */
 void
 FilmEditor::left_crop_changed (wxCommandEvent &)
@@ -705,21 +685,11 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
                ffmpeg_content = dynamic_pointer_cast<FFmpegContent> (content);
        }
 
+       _timing_panel->film_content_changed (content, property);
+
        /* We can't use case {} here */
        
-       if (property == ContentProperty::START) {
-               if (content) {
-                       _start->set (content->start (), _film->dcp_video_frame_rate ());
-               } else {
-                       _start->set (0, 24);
-               }
-       } else if (property == ContentProperty::LENGTH) {
-               if (content) {
-                       _length->set (content->length (), _film->dcp_video_frame_rate ());
-               } else {
-                       _length->set (0, 24);
-               }
-       } else if (property == VideoContentProperty::VIDEO_CROP) {
+       if (property == VideoContentProperty::VIDEO_CROP) {
                checked_set (_left_crop,   video_content ? video_content->crop().left   : 0);
                checked_set (_right_crop,  video_content ? video_content->crop().right  : 0);
                checked_set (_top_crop,    video_content ? video_content->crop().top    : 0);
@@ -1453,31 +1423,6 @@ FilmEditor::audio_mapping_changed (AudioMapping m)
        ac->set_audio_mapping (m);
 }
 
-void
-FilmEditor::start_changed ()
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-
-       c->set_start (_start->get (_film->dcp_video_frame_rate ()));
-}
-
-void
-FilmEditor::length_changed ()
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-
-       shared_ptr<StillImageContent> ic = dynamic_pointer_cast<StillImageContent> (c);
-       if (ic) {
-               ic->set_video_length (_length->get(_film->dcp_video_frame_rate()) * ic->video_frame_rate() / TIME_HZ);
-       }
-}
-
 void
 FilmEditor::set_selection (weak_ptr<Content> wc)
 {
index 9501bbd7cbb0d82f0da896b567c9273b58af3427..7425780f8b70f40f245232fe774ae2b172555502 100644 (file)
@@ -38,6 +38,7 @@ class TimelineDialog;
 class AudioMappingView;
 class Ratio;
 class Timecode;
+class TimingPanel;
 
 /** @class FilmEditor
  *  @brief A wx widget to edit a film's metadata, and perform various functions.
@@ -52,13 +53,24 @@ public:
 
        boost::signals2::signal<void (std::string)> FileChanged;
 
+       /* Stuff for panels */
+       
+       wxNotebook* content_notebook () const {
+               return _content_notebook;
+       }
+
+       boost::shared_ptr<Film> film () const {
+               return _film;
+       }
+
+       boost::shared_ptr<Content> selected_content ();
+
 private:
        void make_dcp_panel ();
        void make_content_panel ();
        void make_video_panel ();
        void make_audio_panel ();
        void make_subtitle_panel ();
-       void make_timing_panel ();
        void connect_to_widgets ();
        
        /* Handle changes to the view */
@@ -115,11 +127,12 @@ private:
        void setup_content_sensitivity ();
        
        void active_jobs_changed (bool);
-       boost::shared_ptr<Content> selected_content ();
        boost::shared_ptr<VideoContent> selected_video_content ();
        boost::shared_ptr<AudioContent> selected_audio_content ();
        boost::shared_ptr<SubtitleContent> selected_subtitle_content ();
 
+       TimingPanel* _timing_panel;
+
        wxNotebook* _main_notebook;
        wxNotebook* _content_notebook;
        wxPanel* _dcp_panel;
@@ -129,7 +142,6 @@ private:
        wxPanel* _video_panel;
        wxPanel* _audio_panel;
        wxPanel* _subtitle_panel;
-       wxPanel* _timing_panel;
 
        /** The film we are editing */
        boost::shared_ptr<Film> _film;
@@ -171,8 +183,6 @@ private:
        wxStaticText* _audio_description;
        wxChoice* _subtitle_stream;
        AudioMappingView* _audio_mapping;
-       Timecode* _start;
-       Timecode* _length;
        wxChoice* _dcp_resolution;
 
        ContentMenu _menu;
diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc
new file mode 100644 (file)
index 0000000..da62aab
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+    Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "lib/content.h"
+#include "lib/still_image_content.h"
+#include "timing_panel.h"
+#include "wx_util.h"
+#include "timecode.h"
+#include "film_editor.h"
+
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
+
+TimingPanel::TimingPanel (FilmEditor* e)
+       : FilmEditorPanel (e, _("Timing"))
+{
+       wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4);
+       _sizer->Add (grid, 0, wxALL, 8);
+
+       add_label_to_sizer (grid, this, _("Start time"), true);
+       _start = new Timecode (this);
+       grid->Add (_start);
+       add_label_to_sizer (grid, this, _("Length"), true);
+       _length = new Timecode (this);
+       grid->Add (_length);
+
+       _start->Changed.connect  (boost::bind (&TimingPanel::start_changed, this));
+       _length->Changed.connect (boost::bind (&TimingPanel::length_changed, this));
+}
+
+void
+TimingPanel::film_content_changed (shared_ptr<Content> content, int property)
+{
+       if (property == ContentProperty::START) {
+               if (content) {
+                       _start->set (content->start (), _editor->film()->dcp_video_frame_rate ());
+               } else {
+                       _start->set (0, 24);
+               }
+       } else if (property == ContentProperty::LENGTH) {
+               if (content) {
+                       _length->set (content->length (), _editor->film()->dcp_video_frame_rate ());
+               } else {
+                       _length->set (0, 24);
+               }
+       }
+}
+
+void
+TimingPanel::start_changed ()
+{
+       shared_ptr<Content> c = _editor->selected_content ();
+       if (!c) {
+               return;
+       }
+
+       c->set_start (_start->get (_editor->film()->dcp_video_frame_rate ()));
+}
+
+void
+TimingPanel::length_changed ()
+{
+       shared_ptr<Content> c = _editor->selected_content ();
+       if (!c) {
+               return;
+       }
+
+       shared_ptr<StillImageContent> ic = dynamic_pointer_cast<StillImageContent> (c);
+       if (ic) {
+               ic->set_video_length (_length->get (_editor->film()->dcp_video_frame_rate()) * ic->video_frame_rate() / TIME_HZ);
+       }
+}
diff --git a/src/wx/timing_panel.h b/src/wx/timing_panel.h
new file mode 100644 (file)
index 0000000..b5c9ef0
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+    Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "film_editor_panel.h"
+
+class Timecode;
+
+class TimingPanel : public FilmEditorPanel
+{
+public:
+       TimingPanel (FilmEditor *);
+
+       void film_content_changed (boost::shared_ptr<Content>, int);
+       
+private:
+       void start_changed ();
+       void length_changed ();
+       
+       Timecode* _start;
+       Timecode* _length;
+};
index c46321f1cf2119ab86354d5cf6370bf5edc09557..ebd284567b41268fa24734f66e3e4d14a414e69a 100644 (file)
@@ -13,6 +13,7 @@ sources = """
           dci_metadata_dialog.cc
           dir_picker_ctrl.cc
           film_editor.cc
+          film_editor_panel.cc
           film_viewer.cc
           filter_dialog.cc
           filter_view.cc
@@ -26,6 +27,7 @@ sources = """
           timecode.cc
           timeline.cc
           timeline_dialog.cc
+          timing_panel.cc
           wx_util.cc
           wx_ui_signaller.cc
           """