summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-19 20:21:27 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-19 20:21:27 +0100
commite6e20d9b37ebdd50768777d7b603ad4f736d790b (patch)
treeee75ed8217211206f6f791c93d716705490fd4c0 /src
parente1b818fe3eb59d854c1b8b7951a8af58c3095ba2 (diff)
Split timing panel into its own class.
Diffstat (limited to 'src')
-rw-r--r--src/wx/film_editor.cc65
-rw-r--r--src/wx/film_editor.h20
-rw-r--r--src/wx/timing_panel.cc88
-rw-r--r--src/wx/timing_panel.h37
-rw-r--r--src/wx/wscript2
5 files changed, 147 insertions, 65 deletions
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index 8ae63bd4b..9030c6cdc 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -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);
@@ -1454,31 +1424,6 @@ FilmEditor::audio_mapping_changed (AudioMapping 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)
{
ContentList content = _film->content ();
diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h
index 9501bbd7c..7425780f8 100644
--- a/src/wx/film_editor.h
+++ b/src/wx/film_editor.h
@@ -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
index 000000000..da62aabdf
--- /dev/null
+++ b/src/wx/timing_panel.cc
@@ -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
index 000000000..b5c9ef026
--- /dev/null
+++ b/src/wx/timing_panel.h
@@ -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;
+};
diff --git a/src/wx/wscript b/src/wx/wscript
index c46321f1c..ebd284567 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -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
"""