Similarly split subtitle panel.
authorCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 19:45:39 +0000 (20:45 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 19:45:39 +0000 (20:45 +0100)
src/wx/film_editor.cc
src/wx/film_editor.h
src/wx/film_editor_panel.cc [new file with mode: 0644]
src/wx/film_editor_panel.h [new file with mode: 0644]
src/wx/subtitle_panel.cc [new file with mode: 0644]
src/wx/subtitle_panel.h [new file with mode: 0644]
src/wx/timing_panel.cc
src/wx/timing_panel.h
src/wx/wscript

index 9030c6cdc7c474ffac94054a5d85b5f30285adfc..3e2eaa8a282a05ef2d3ca794a303bb1d9b35b53b 100644 (file)
@@ -51,6 +51,7 @@
 #include "timeline_dialog.h"
 #include "audio_mapping_view.h"
 #include "timing_panel.h"
+#include "subtitle_panel.h"
 
 using std::string;
 using std::cout;
@@ -226,9 +227,6 @@ FilmEditor::connect_to_widgets ()
        _dcp_frame_rate->Connect         (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::dcp_frame_rate_changed), 0, this);
        _best_dcp_frame_rate->Connect    (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::best_dcp_frame_rate_clicked), 0, this);
        _dcp_audio_channels->Connect     (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::dcp_audio_channels_changed), 0, this);
-       _with_subtitles->Connect         (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this);
-       _subtitle_offset->Connect        (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::subtitle_offset_changed), 0, this);
-       _subtitle_scale->Connect         (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this);
        _j2k_bandwidth->Connect          (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::j2k_bandwidth_changed), 0, this);
        _audio_gain->Connect             (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this);
        _audio_gain_calculate_button->Connect (
@@ -237,7 +235,6 @@ FilmEditor::connect_to_widgets ()
        _show_audio->Connect             (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::show_audio_clicked), 0, this);
        _audio_delay->Connect            (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
        _audio_stream->Connect           (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this);
-       _subtitle_stream->Connect        (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this);
        _dcp_resolution->Connect         (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::dcp_resolution_changed), 0, this);
        _sequence_video->Connect         (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::sequence_video_changed), 0, this);
                
@@ -345,8 +342,7 @@ FilmEditor::make_content_panel ()
        _content_notebook->AddPage (_video_panel, _("Video"), false);
        make_audio_panel ();
        _content_notebook->AddPage (_audio_panel, _("Audio"), false);
-       make_subtitle_panel ();
-       _content_notebook->AddPage (_subtitle_panel, _("Subtitles"), false);
+       _subtitle_panel = new SubtitlePanel (this);
        _timing_panel = new TimingPanel (this);
 }
 
@@ -406,46 +402,6 @@ FilmEditor::make_audio_panel ()
        _audio_delay->SetRange (-1000, 1000);
 }
 
-void
-FilmEditor::make_subtitle_panel ()
-{
-       _subtitle_panel = new wxPanel (_content_notebook);
-       wxBoxSizer* subtitle_sizer = new wxBoxSizer (wxVERTICAL);
-       _subtitle_panel->SetSizer (subtitle_sizer);
-       wxFlexGridSizer* grid = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
-       subtitle_sizer->Add (grid, 0, wxALL, 8);
-
-       _with_subtitles = new wxCheckBox (_subtitle_panel, wxID_ANY, _("With Subtitles"));
-       grid->Add (_with_subtitles, 1);
-       grid->AddSpacer (0);
-       
-       {
-               add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Offset"), true);
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _subtitle_offset = new wxSpinCtrl (_subtitle_panel);
-               s->Add (_subtitle_offset);
-               add_label_to_sizer (s, _subtitle_panel, _("%"), false);
-               grid->Add (s);
-       }
-
-       {
-               add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Scale"), true);
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _subtitle_scale = new wxSpinCtrl (_subtitle_panel);
-               s->Add (_subtitle_scale);
-               add_label_to_sizer (s, _subtitle_panel, _("%"), false);
-               grid->Add (s);
-       }
-
-       add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Stream"), true);
-       _subtitle_stream = new wxChoice (_subtitle_panel, wxID_ANY);
-       grid->Add (_subtitle_stream, 1, wxEXPAND);
-       
-       _subtitle_offset->SetRange (-100, 100);
-       _subtitle_scale->SetRange (1, 1000);
-       _subtitle_scale->SetValue (100);
-}
-
 /** Called when the left crop widget has been changed */
 void
 FilmEditor::left_crop_changed (wxCommandEvent &)
@@ -505,28 +461,6 @@ FilmEditor::name_changed (wxCommandEvent &)
        _film->set_name (string (_name->GetValue().mb_str()));
 }
 
-void
-FilmEditor::subtitle_offset_changed (wxCommandEvent &)
-{
-       shared_ptr<SubtitleContent> c = selected_subtitle_content ();
-       if (!c) {
-               return;
-       }
-
-       c->set_subtitle_offset (_subtitle_offset->GetValue() / 100.0);
-}
-
-void
-FilmEditor::subtitle_scale_changed (wxCommandEvent &)
-{
-       shared_ptr<SubtitleContent> c = selected_subtitle_content ();
-       if (!c) {
-               return;
-       }
-
-       c->set_subtitle_scale (_subtitle_scale->GetValue() / 100.0);
-}
-
 void
 FilmEditor::j2k_bandwidth_changed (wxCommandEvent &)
 {
@@ -586,13 +520,15 @@ FilmEditor::film_changed (Film::Property p)
        }
 
        stringstream s;
+
+       _subtitle_panel->film_changed (p);
+       _timing_panel->film_changed (p);
                
        switch (p) {
        case Film::NONE:
                break;
        case Film::CONTENT:
                setup_content ();
-               setup_subtitle_control_sensitivity ();
                setup_show_audio_sensitivity ();
                break;
        case Film::CONTAINER:
@@ -602,6 +538,9 @@ FilmEditor::film_changed (Film::Property p)
                checked_set (_name, _film->name());
                setup_dcp_name ();
                break;
+       case Film::WITH_SUBTITLES:
+               setup_dcp_name ();
+               break;
        case Film::DCP_CONTENT_TYPE:
                checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
                setup_dcp_name ();
@@ -609,11 +548,6 @@ FilmEditor::film_changed (Film::Property p)
        case Film::SCALER:
                checked_set (_scaler, Scaler::as_index (_film->scaler ()));
                break;
-       case Film::WITH_SUBTITLES:
-               checked_set (_with_subtitles, _film->with_subtitles ());
-               setup_subtitle_control_sensitivity ();
-               setup_dcp_name ();
-               break;
        case Film::RESOLUTION:
                checked_set (_dcp_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
                setup_dcp_name ();
@@ -685,7 +619,8 @@ 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);
+       _subtitle_panel->film_content_changed (content, subtitle_content, ffmpeg_content, property);
+       _timing_panel->film_content_changed   (content, subtitle_content, ffmpeg_content, property);
 
        /* We can't use case {} here */
        
@@ -720,21 +655,6 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
                checked_set (_audio_delay, audio_content ? audio_content->audio_delay() : 0);
        } else if (property == AudioContentProperty::AUDIO_MAPPING) {
                _audio_mapping->set (audio_content ? audio_content->audio_mapping () : AudioMapping ());
-       } else if (property == FFmpegContentProperty::SUBTITLE_STREAMS) {
-               _subtitle_stream->Clear ();
-               if (ffmpeg_content) {
-                       vector<shared_ptr<FFmpegSubtitleStream> > s = ffmpeg_content->subtitle_streams ();
-                       for (vector<shared_ptr<FFmpegSubtitleStream> >::iterator i = s.begin(); i != s.end(); ++i) {
-                               _subtitle_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
-                       }
-                       
-                       if (ffmpeg_content->subtitle_stream()) {
-                               checked_set (_subtitle_stream, lexical_cast<string> (ffmpeg_content->subtitle_stream()->id));
-                       } else {
-                               _subtitle_stream->SetSelection (wxNOT_FOUND);
-                       }
-               }
-               setup_subtitle_control_sensitivity ();
        } else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
                _audio_stream->Clear ();
                if (ffmpeg_content) {
@@ -762,10 +682,6 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
                        }
                        _dcp_sizer->Layout ();
                }
-       } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET) {
-               checked_set (_subtitle_offset, subtitle_content ? (subtitle_content->subtitle_offset() * 100) : 0);
-       } else if (property == SubtitleContentProperty::SUBTITLE_SCALE) {
-               checked_set (_subtitle_scale, subtitle_content ? (subtitle_content->subtitle_scale() * 100) : 100);
        }
 }
 
@@ -894,7 +810,7 @@ FilmEditor::set_things_sensitive (bool s)
        _audio_delay->Enable (s);
        _container->Enable (s);
 
-       setup_subtitle_control_sensitivity ();
+       _subtitle_panel->setup_control_sensitivity ();
        setup_show_audio_sensitivity ();
        setup_content_sensitivity ();
        _best_dcp_frame_rate->Enable (s && _film && _film->best_dcp_video_frame_rate () != _film->dcp_video_frame_rate ());
@@ -996,36 +912,6 @@ FilmEditor::setup_ratios ()
        _dcp_sizer->Layout ();
 }
 
-void
-FilmEditor::with_subtitles_toggled (wxCommandEvent &)
-{
-       if (!_film) {
-               return;
-       }
-
-       _film->set_with_subtitles (_with_subtitles->GetValue ());
-}
-
-void
-FilmEditor::setup_subtitle_control_sensitivity ()
-{
-       bool h = false;
-       if (_generally_sensitive && _film) {
-               h = _film->has_subtitles ();
-       }
-       
-       _with_subtitles->Enable (h);
-
-       bool j = false;
-       if (_film) {
-               j = _film->with_subtitles ();
-       }
-       
-       _subtitle_offset->Enable (j);
-       _subtitle_scale->Enable (j);
-       _subtitle_stream->Enable (j);
-}
-
 void
 FilmEditor::use_dci_name_toggled (wxCommandEvent &)
 {
@@ -1380,33 +1266,6 @@ FilmEditor::audio_stream_changed (wxCommandEvent &)
        }
 }
 
-
-
-void
-FilmEditor::subtitle_stream_changed (wxCommandEvent &)
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-       
-       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
-       if (!fc) {
-               return;
-       }
-       
-       vector<shared_ptr<FFmpegSubtitleStream> > a = fc->subtitle_streams ();
-       vector<shared_ptr<FFmpegSubtitleStream> >::iterator i = a.begin ();
-       string const s = string_client_data (_subtitle_stream->GetClientObject (_subtitle_stream->GetSelection ()));
-       while (i != a.end() && lexical_cast<string> ((*i)->id) != s) {
-               ++i;
-       }
-
-       if (i != a.end ()) {
-               fc->set_subtitle_stream (*i);
-       }
-}
-
 void
 FilmEditor::audio_mapping_changed (AudioMapping m)
 {
index 7425780f8b70f40f245232fe774ae2b172555502..be4d14f99450731ba80c89a89f6b965ab42b517f 100644 (file)
@@ -39,6 +39,7 @@ class AudioMappingView;
 class Ratio;
 class Timecode;
 class TimingPanel;
+class SubtitlePanel;
 
 /** @class FilmEditor
  *  @brief A wx widget to edit a film's metadata, and perform various functions.
@@ -64,13 +65,17 @@ public:
        }
 
        boost::shared_ptr<Content> selected_content ();
+       boost::shared_ptr<SubtitleContent> selected_subtitle_content ();
+       
+       bool generally_sensitive () const {
+               return _generally_sensitive;
+       }
 
 private:
        void make_dcp_panel ();
        void make_content_panel ();
        void make_video_panel ();
        void make_audio_panel ();
-       void make_subtitle_panel ();
        void connect_to_widgets ();
        
        /* Handle changes to the view */
@@ -93,16 +98,12 @@ private:
        void audio_gain_calculate_button_clicked (wxCommandEvent &);
        void show_audio_clicked (wxCommandEvent &);
        void audio_delay_changed (wxCommandEvent &);
-       void with_subtitles_toggled (wxCommandEvent &);
-       void subtitle_offset_changed (wxCommandEvent &);
-       void subtitle_scale_changed (wxCommandEvent &);
        void j2k_bandwidth_changed (wxCommandEvent &);
        void dcp_frame_rate_changed (wxCommandEvent &);
        void best_dcp_frame_rate_clicked (wxCommandEvent &);
        void edit_filters_clicked (wxCommandEvent &);
        void content_timeline_clicked (wxCommandEvent &);
        void audio_stream_changed (wxCommandEvent &);
-       void subtitle_stream_changed (wxCommandEvent &);
        void audio_mapping_changed (AudioMapping);
        void start_changed ();
        void length_changed ();
@@ -118,7 +119,6 @@ private:
 
        void set_things_sensitive (bool);
        void setup_ratios ();
-       void setup_subtitle_control_sensitivity ();
        void setup_dcp_name ();
        void setup_show_audio_sensitivity ();
        void setup_scaling_description ();
@@ -129,8 +129,8 @@ private:
        void active_jobs_changed (bool);
        boost::shared_ptr<VideoContent> selected_video_content ();
        boost::shared_ptr<AudioContent> selected_audio_content ();
-       boost::shared_ptr<SubtitleContent> selected_subtitle_content ();
 
+       SubtitlePanel* _subtitle_panel;
        TimingPanel* _timing_panel;
 
        wxNotebook* _main_notebook;
@@ -141,7 +141,6 @@ private:
        wxSizer* _content_sizer;
        wxPanel* _video_panel;
        wxPanel* _audio_panel;
-       wxPanel* _subtitle_panel;
 
        /** The film we are editing */
        boost::shared_ptr<Film> _film;
@@ -171,9 +170,6 @@ private:
        wxButton* _audio_gain_calculate_button;
        wxButton* _show_audio;
        wxSpinCtrl* _audio_delay;
-       wxCheckBox* _with_subtitles;
-       wxSpinCtrl* _subtitle_offset;
-       wxSpinCtrl* _subtitle_scale;
        wxSpinCtrl* _j2k_bandwidth;
        wxChoice* _dcp_content_type;
        wxChoice* _dcp_frame_rate;
@@ -181,7 +177,6 @@ private:
        wxButton* _best_dcp_frame_rate;
        wxChoice* _audio_stream;
        wxStaticText* _audio_description;
-       wxChoice* _subtitle_stream;
        AudioMappingView* _audio_mapping;
        wxChoice* _dcp_resolution;
 
diff --git a/src/wx/film_editor_panel.cc b/src/wx/film_editor_panel.cc
new file mode 100644 (file)
index 0000000..a637df1
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+    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 <wx/notebook.h>
+#include "film_editor_panel.h"
+#include "film_editor.h"
+
+using boost::shared_ptr;
+
+FilmEditorPanel::FilmEditorPanel (FilmEditor* e, wxString name)
+       : wxPanel (e->content_notebook (), wxID_ANY)
+       , _editor (e)
+       , _sizer (new wxBoxSizer (wxVERTICAL))
+{
+       e->content_notebook()->AddPage (this, name, false);
+       SetSizer (_sizer);
+}
+
diff --git a/src/wx/film_editor_panel.h b/src/wx/film_editor_panel.h
new file mode 100644 (file)
index 0000000..f238b7f
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+    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.
+
+*/
+
+#ifndef DCPOMATIC_FILM_EDITOR_PANEL_H
+#define DCPOMATIC_FILM_EDITOR_PANEL_H
+
+#include <boost/shared_ptr.hpp>
+#include <wx/wx.h>
+#include "lib/film.h"
+
+class FilmEditor;
+class Content;
+
+class FilmEditorPanel : public wxPanel
+{
+public:
+       FilmEditorPanel (FilmEditor *, wxString);
+
+       virtual void film_changed (Film::Property) {}
+       virtual void film_content_changed (
+               boost::shared_ptr<Content>,
+               boost::shared_ptr<SubtitleContent>,
+               boost::shared_ptr<FFmpegContent>,
+               int) = 0;
+
+protected:
+       FilmEditor* _editor;
+       wxSizer* _sizer;
+};
+
+#endif
diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc
new file mode 100644 (file)
index 0000000..22b382c
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+    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 <boost/lexical_cast.hpp>
+#include <wx/spinctrl.h>
+#include "subtitle_panel.h"
+#include "film_editor.h"
+#include "wx_util.h"
+
+using std::vector;
+using std::string;
+using boost::shared_ptr;
+using boost::lexical_cast;
+using boost::dynamic_pointer_cast;
+
+SubtitlePanel::SubtitlePanel (FilmEditor* e)
+       : FilmEditorPanel (e, _("Subtitles"))
+{
+       wxFlexGridSizer* grid = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+       _sizer->Add (grid, 0, wxALL, 8);
+
+       _with_subtitles = new wxCheckBox (this, wxID_ANY, _("With Subtitles"));
+       grid->Add (_with_subtitles, 1);
+       grid->AddSpacer (0);
+       
+       {
+               add_label_to_sizer (grid, this, _("Subtitle Offset"), true);
+               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+               _offset = new wxSpinCtrl (this);
+               s->Add (_offset);
+               add_label_to_sizer (s, this, _("%"), false);
+               grid->Add (s);
+       }
+
+       {
+               add_label_to_sizer (grid, this, _("Subtitle Scale"), true);
+               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+               _scale = new wxSpinCtrl (this);
+               s->Add (_scale);
+               add_label_to_sizer (s, this, _("%"), false);
+               grid->Add (s);
+       }
+
+       add_label_to_sizer (grid, this, _("Subtitle Stream"), true);
+       _stream = new wxChoice (this, wxID_ANY);
+       grid->Add (_stream, 1, wxEXPAND);
+       
+       _offset->SetRange (-100, 100);
+       _scale->SetRange (1, 1000);
+       _scale->SetValue (100);
+
+       _with_subtitles->Connect  (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (SubtitlePanel::with_subtitles_toggled), 0, this);
+       _offset->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (SubtitlePanel::offset_changed), 0, this);
+       _scale->Connect  (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (SubtitlePanel::scale_changed), 0, this);
+       _stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,  wxCommandEventHandler (SubtitlePanel::stream_changed), 0, this);
+}
+
+void
+SubtitlePanel::film_changed (Film::Property property)
+{
+       switch (property) {
+       case Film::CONTENT:
+               setup_control_sensitivity ();
+               break;
+       case Film::WITH_SUBTITLES:
+               checked_set (_with_subtitles, _editor->film()->with_subtitles ());
+               setup_control_sensitivity ();
+               break;
+       default:
+               break;
+       }
+}
+
+void
+SubtitlePanel::film_content_changed (
+       shared_ptr<Content>,
+       shared_ptr<SubtitleContent> subtitle_content,
+       shared_ptr<FFmpegContent> ffmpeg_content,
+       int property
+       )
+{
+       if (property == FFmpegContentProperty::SUBTITLE_STREAMS) {
+               _stream->Clear ();
+               if (ffmpeg_content) {
+                       vector<shared_ptr<FFmpegSubtitleStream> > s = ffmpeg_content->subtitle_streams ();
+                       for (vector<shared_ptr<FFmpegSubtitleStream> >::iterator i = s.begin(); i != s.end(); ++i) {
+                               _stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
+                       }
+                       
+                       if (ffmpeg_content->subtitle_stream()) {
+                               checked_set (_stream, lexical_cast<string> (ffmpeg_content->subtitle_stream()->id));
+                       } else {
+                               _stream->SetSelection (wxNOT_FOUND);
+                       }
+               }
+               setup_control_sensitivity ();
+       } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET) {
+               checked_set (_offset, subtitle_content ? (subtitle_content->subtitle_offset() * 100) : 0);
+       } else if (property == SubtitleContentProperty::SUBTITLE_SCALE) {
+               checked_set (_scale, subtitle_content ? (subtitle_content->subtitle_scale() * 100) : 100);
+       }
+
+}
+
+void
+SubtitlePanel::with_subtitles_toggled (wxCommandEvent &)
+{
+       if (!_editor->film()) {
+               return;
+       }
+
+       _editor->film()->set_with_subtitles (_with_subtitles->GetValue ());
+}
+
+void
+SubtitlePanel::setup_control_sensitivity ()
+{
+       bool h = false;
+       if (_editor->generally_sensitive() && _editor->film()) {
+               h = _editor->film()->has_subtitles ();
+       }
+       
+       _with_subtitles->Enable (h);
+
+       bool j = false;
+       if (_editor->film()) {
+               j = _editor->film()->with_subtitles ();
+       }
+       
+       _offset->Enable (j);
+       _scale->Enable (j);
+       _stream->Enable (j);
+}
+
+void
+SubtitlePanel::stream_changed (wxCommandEvent &)
+{
+       shared_ptr<Content> c = _editor->selected_content ();
+       if (!c) {
+               return;
+       }
+       
+       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+       if (!fc) {
+               return;
+       }
+       
+       vector<shared_ptr<FFmpegSubtitleStream> > a = fc->subtitle_streams ();
+       vector<shared_ptr<FFmpegSubtitleStream> >::iterator i = a.begin ();
+       string const s = string_client_data (_stream->GetClientObject (_stream->GetSelection ()));
+       while (i != a.end() && lexical_cast<string> ((*i)->id) != s) {
+               ++i;
+       }
+
+       if (i != a.end ()) {
+               fc->set_subtitle_stream (*i);
+       }
+}
+
+void
+SubtitlePanel::offset_changed (wxCommandEvent &)
+{
+       shared_ptr<SubtitleContent> c = _editor->selected_subtitle_content ();
+       if (!c) {
+               return;
+       }
+
+       c->set_subtitle_offset (_offset->GetValue() / 100.0);
+}
+
+void
+SubtitlePanel::scale_changed (wxCommandEvent &)
+{
+       shared_ptr<SubtitleContent> c = _editor->selected_subtitle_content ();
+       if (!c) {
+               return;
+       }
+
+       c->set_subtitle_scale (_scale->GetValue() / 100.0);
+}
+
diff --git a/src/wx/subtitle_panel.h b/src/wx/subtitle_panel.h
new file mode 100644 (file)
index 0000000..b4b2024
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+    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 wxCheckBox;
+class wxSpinCtrl;
+
+class SubtitlePanel : public FilmEditorPanel
+{
+public:
+       SubtitlePanel (FilmEditor *);
+
+       void film_changed (Film::Property);
+       void film_content_changed (
+               boost::shared_ptr<Content>,
+               boost::shared_ptr<SubtitleContent>,
+               boost::shared_ptr<FFmpegContent>,
+               int);
+
+       void setup_control_sensitivity ();
+       
+private:
+       void with_subtitles_toggled (wxCommandEvent &);
+       void offset_changed (wxCommandEvent &);
+       void scale_changed (wxCommandEvent &);
+       void stream_changed (wxCommandEvent &);
+       
+       wxCheckBox* _with_subtitles;
+       wxSpinCtrl* _offset;
+       wxSpinCtrl* _scale;
+       wxChoice* _stream;
+};
index da62aabdfab0c8e88de1f217f2711e28048b99d1..3f3788d1637fae7d978d94501e48e7fc39dc5439 100644 (file)
@@ -45,7 +45,7 @@ TimingPanel::TimingPanel (FilmEditor* e)
 }
 
 void
-TimingPanel::film_content_changed (shared_ptr<Content> content, int property)
+TimingPanel::film_content_changed (shared_ptr<Content> content, shared_ptr<SubtitleContent>, shared_ptr<FFmpegContent>, int property)
 {
        if (property == ContentProperty::START) {
                if (content) {
index b5c9ef026b5130581428cc596d91d5a77ef92e10..f9cd482d678ccae640eba9f5927689ea46978d25 100644 (file)
@@ -26,7 +26,11 @@ class TimingPanel : public FilmEditorPanel
 public:
        TimingPanel (FilmEditor *);
 
-       void film_content_changed (boost::shared_ptr<Content>, int);
+       void film_content_changed (
+               boost::shared_ptr<Content>,
+               boost::shared_ptr<SubtitleContent>,
+               boost::shared_ptr<FFmpegContent>,
+               int);
        
 private:
        void start_changed ();
index ebd284567b41268fa24734f66e3e4d14a414e69a..8e3272ca4e054237e816b445fa3526be878744e4 100644 (file)
@@ -24,6 +24,7 @@ sources = """
           properties_dialog.cc
           repeat_dialog.cc
           server_dialog.cc
+          subtitle_panel.cc
           timecode.cc
           timeline.cc
           timeline_dialog.cc