diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-19 20:45:39 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-19 20:45:39 +0100 |
| commit | 498e3c0ee1da5a4f50bc019e9a760689a930c06c (patch) | |
| tree | 7a2a70ffac1b3ef8249a66fcacf0844a78ef04b4 | |
| parent | e6e20d9b37ebdd50768777d7b603ad4f736d790b (diff) | |
Similarly split subtitle panel.
| -rw-r--r-- | src/wx/film_editor.cc | 163 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 19 | ||||
| -rw-r--r-- | src/wx/film_editor_panel.cc | 34 | ||||
| -rw-r--r-- | src/wx/film_editor_panel.h | 47 | ||||
| -rw-r--r-- | src/wx/subtitle_panel.cc | 197 | ||||
| -rw-r--r-- | src/wx/subtitle_panel.h | 49 | ||||
| -rw-r--r-- | src/wx/timing_panel.cc | 2 | ||||
| -rw-r--r-- | src/wx/timing_panel.h | 6 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
9 files changed, 352 insertions, 166 deletions
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 9030c6cdc..3e2eaa8a2 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -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 &) @@ -506,28 +462,6 @@ FilmEditor::name_changed (wxCommandEvent &) } 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 &) { if (!_film) { @@ -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 ()); @@ -997,36 +913,6 @@ FilmEditor::setup_ratios () } 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 &) { if (!_film) { @@ -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) { diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 7425780f8..be4d14f99 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -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 index 000000000..a637df1fe --- /dev/null +++ b/src/wx/film_editor_panel.cc @@ -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 index 000000000..f238b7fb9 --- /dev/null +++ b/src/wx/film_editor_panel.h @@ -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 index 000000000..22b382ccd --- /dev/null +++ b/src/wx/subtitle_panel.cc @@ -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 index 000000000..b4b20240e --- /dev/null +++ b/src/wx/subtitle_panel.h @@ -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; +}; diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index da62aabdf..3f3788d16 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -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) { diff --git a/src/wx/timing_panel.h b/src/wx/timing_panel.h index b5c9ef026..f9cd482d6 100644 --- a/src/wx/timing_panel.h +++ b/src/wx/timing_panel.h @@ -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 (); diff --git a/src/wx/wscript b/src/wx/wscript index ebd284567..8e3272ca4 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -24,6 +24,7 @@ sources = """ properties_dialog.cc repeat_dialog.cc server_dialog.cc + subtitle_panel.cc timecode.cc timeline.cc timeline_dialog.cc |
