#include <boost/lexical_cast.hpp>
#include <wx/spinctrl.h>
+#include "lib/ffmpeg_content.h"
#include "subtitle_panel.h"
#include "film_editor.h"
#include "wx_util.h"
_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);
+ _with_subtitles->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::with_subtitles_toggled, this));
+ _offset->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::offset_changed, this));
+ _scale->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::scale_changed, this));
+ _stream->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&SubtitlePanel::stream_changed, this));
}
void
{
switch (property) {
case Film::CONTENT:
- setup_control_sensitivity ();
+ setup_sensitivity ();
break;
case Film::WITH_SUBTITLES:
checked_set (_with_subtitles, _editor->film()->with_subtitles ());
- setup_control_sensitivity ();
+ setup_sensitivity ();
break;
default:
break;
}
void
-SubtitlePanel::film_content_changed (shared_ptr<Content> c, int property)
+SubtitlePanel::film_content_changed (int property)
{
- shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c);
- shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+ FFmpegContentList fc = _editor->selected_ffmpeg_content ();
+ SubtitleContentList sc = _editor->selected_subtitle_content ();
+
+ shared_ptr<FFmpegContent> fcs;
+ if (fc.size() == 1) {
+ fcs = fc.front ();
+ }
+
+ shared_ptr<SubtitleContent> scs;
+ if (sc.size() == 1) {
+ scs = sc.front ();
+ }
if (property == FFmpegContentProperty::SUBTITLE_STREAMS) {
_stream->Clear ();
- if (fc) {
- vector<shared_ptr<FFmpegSubtitleStream> > s = fc->subtitle_streams ();
+ if (fcs) {
+ vector<shared_ptr<FFmpegSubtitleStream> > s = fcs->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 (fc->subtitle_stream()) {
- checked_set (_stream, lexical_cast<string> (fc->subtitle_stream()->id));
+ if (fcs->subtitle_stream()) {
+ checked_set (_stream, lexical_cast<string> (fcs->subtitle_stream()->id));
} else {
_stream->SetSelection (wxNOT_FOUND);
}
}
- setup_control_sensitivity ();
+ setup_sensitivity ();
} else if (property == SubtitleContentProperty::SUBTITLE_OFFSET) {
- checked_set (_offset, sc ? (sc->subtitle_offset() * 100) : 0);
+ checked_set (_offset, scs ? (scs->subtitle_offset() * 100) : 0);
} else if (property == SubtitleContentProperty::SUBTITLE_SCALE) {
- checked_set (_scale, sc ? (sc->subtitle_scale() * 100) : 100);
+ checked_set (_scale, scs ? (scs->subtitle_scale() * 100) : 100);
}
-
}
void
-SubtitlePanel::with_subtitles_toggled (wxCommandEvent &)
+SubtitlePanel::with_subtitles_toggled ()
{
if (!_editor->film()) {
return;
}
void
-SubtitlePanel::setup_control_sensitivity ()
+SubtitlePanel::setup_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()) {
+ h = _editor->film()->has_subtitles ();
j = _editor->film()->with_subtitles ();
}
+ _with_subtitles->Enable (h);
_offset->Enable (j);
_scale->Enable (j);
_stream->Enable (j);
}
void
-SubtitlePanel::stream_changed (wxCommandEvent &)
+SubtitlePanel::stream_changed ()
{
- shared_ptr<Content> c = _editor->selected_content ();
- if (!c) {
- return;
- }
-
- shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
- if (!fc) {
+ FFmpegContentList fc = _editor->selected_ffmpeg_content ();
+ if (fc.size() != 1) {
return;
}
+
+ shared_ptr<FFmpegContent> fcs = fc.front ();
- vector<shared_ptr<FFmpegSubtitleStream> > a = fc->subtitle_streams ();
+ vector<shared_ptr<FFmpegSubtitleStream> > a = fcs->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) {
}
if (i != a.end ()) {
- fc->set_subtitle_stream (*i);
+ fcs->set_subtitle_stream (*i);
}
}
void
-SubtitlePanel::offset_changed (wxCommandEvent &)
+SubtitlePanel::offset_changed ()
{
- shared_ptr<SubtitleContent> c = _editor->selected_subtitle_content ();
- if (!c) {
- return;
+ SubtitleContentList c = _editor->selected_subtitle_content ();
+ if (c.size() == 1) {
+ c.front()->set_subtitle_offset (_offset->GetValue() / 100.0);
}
-
- c->set_subtitle_offset (_offset->GetValue() / 100.0);
}
void
-SubtitlePanel::scale_changed (wxCommandEvent &)
+SubtitlePanel::scale_changed ()
{
- shared_ptr<SubtitleContent> c = _editor->selected_subtitle_content ();
- if (!c) {
- return;
+ SubtitleContentList c = _editor->selected_subtitle_content ();
+ if (c.size() == 1) {
+ c.front()->set_subtitle_scale (_scale->GetValue() / 100.0);
}
-
- c->set_subtitle_scale (_scale->GetValue() / 100.0);
}
+void
+SubtitlePanel::content_selection_changed ()
+{
+ film_content_changed (FFmpegContentProperty::SUBTITLE_STREAMS);
+ film_content_changed (SubtitleContentProperty::SUBTITLE_OFFSET);
+ film_content_changed (SubtitleContentProperty::SUBTITLE_SCALE);
+}