From 3e2e2fa63ce6e42efba734ced0099a2d87cd3290 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 24 May 2013 15:01:41 +0100 Subject: [PATCH] Better updating on content selection change. --- src/wx/film_editor.cc | 78 ++++++++++++++++++++----------------------- src/wx/film_editor.h | 1 - 2 files changed, 36 insertions(+), 43 deletions(-) diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 004bcb922..bc814fcbc 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -671,9 +671,11 @@ FilmEditor::film_content_changed (weak_ptr weak_content, int property) shared_ptr content = weak_content.lock (); shared_ptr video_content; shared_ptr audio_content; + shared_ptr ffmpeg_content; if (content) { video_content = dynamic_pointer_cast (content); audio_content = dynamic_pointer_cast (content); + ffmpeg_content = dynamic_pointer_cast (content); } if (property == VideoContentProperty::VIDEO_CROP) { @@ -687,8 +689,35 @@ FilmEditor::film_content_changed (weak_ptr weak_content, int property) } else if (property == AudioContentProperty::AUDIO_DELAY) { checked_set (_audio_delay, audio_content ? audio_content->audio_delay() : 0); } else if (property == FFmpegContentProperty::SUBTITLE_STREAMS) { + _subtitle_stream->Clear (); + if (ffmpeg_content) { + vector > s = ffmpeg_content->subtitle_streams (); + if (s.empty ()) { + _subtitle_stream->Enable (false); + } + for (vector >::iterator i = s.begin(); i != s.end(); ++i) { + _subtitle_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast ((*i)->id)))); + } + + if (ffmpeg_content->subtitle_stream()) { + checked_set (_subtitle_stream, lexical_cast (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) { + vector > a = ffmpeg_content->audio_streams (); + for (vector >::iterator i = a.begin(); i != a.end(); ++i) { + _audio_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast ((*i)->id)))); + } + + if (ffmpeg_content->audio_stream()) { + checked_set (_audio_stream, lexical_cast (ffmpeg_content->audio_stream()->id)); + } + } setup_show_audio_sensitivity (); } else if (property == FFmpegContentProperty::AUDIO_STREAM) { setup_dcp_name (); @@ -1099,6 +1128,13 @@ void FilmEditor::content_selection_changed (wxListEvent &) { setup_content_sensitivity (); + shared_ptr s = selected_content (); + film_content_changed (s, VideoContentProperty::VIDEO_CROP); + film_content_changed (s, AudioContentProperty::AUDIO_GAIN); + film_content_changed (s, AudioContentProperty::AUDIO_DELAY); + film_content_changed (s, FFmpegContentProperty::AUDIO_STREAM); + film_content_changed (s, FFmpegContentProperty::AUDIO_STREAMS); + film_content_changed (s, FFmpegContentProperty::SUBTITLE_STREAM); } void @@ -1249,48 +1285,6 @@ FilmEditor::content_timeline_clicked (wxCommandEvent &) _timeline_dialog->Show (); } -void -FilmEditor::setup_content_properties () -{ - _audio_stream->Clear (); - _subtitle_stream->Clear (); - - shared_ptr c = selected_content (); - if (!c) { - return; - } - - shared_ptr fc = dynamic_pointer_cast (c); - if (fc) { - - vector > a = fc->audio_streams (); - for (vector >::iterator i = a.begin(); i != a.end(); ++i) { - _audio_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast ((*i)->id)))); - } - - if (fc->audio_stream()) { - checked_set (_audio_stream, lexical_cast (fc->audio_stream()->id)); - } - - vector > s = fc->subtitle_streams (); - if (s.empty ()) { - _subtitle_stream->Enable (false); - } - for (vector >::iterator i = s.begin(); i != s.end(); ++i) { - _subtitle_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast ((*i)->id)))); - } - - if (fc->subtitle_stream()) { - checked_set (_subtitle_stream, lexical_cast (fc->subtitle_stream()->id)); - } else { - _subtitle_stream->SetSelection (wxNOT_FOUND); - } - - /* XXX: should be general audiocontent */ - _audio_mapping->set_mapping (fc->audio_mapping ()); - } -} - void FilmEditor::audio_stream_changed (wxCommandEvent &) { diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 6238aadc6..89065c97d 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -107,7 +107,6 @@ private: void setup_container (); void setup_content_sensitivity (); void setup_loop_sensitivity (); - void setup_content_properties (); void active_jobs_changed (bool); boost::shared_ptr selected_content (); -- 2.30.2