From b4e9d90b9d83c952563ccabc435a5d4310ee4853 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 29 Apr 2015 22:10:50 +0100 Subject: Hand-apply b737b25e10a4bcfb8cb645e95a089192347b4805 from master; more deflickering. --- src/wx/audio_panel.cc | 20 ++++++++++++-------- src/wx/timecode.cc | 10 +++++----- src/wx/timecode.h | 2 +- src/wx/timing_panel.cc | 4 ++-- src/wx/wx_util.cc | 31 +++++++++++++++++++++++++++++++ src/wx/wx_util.h | 2 ++ 6 files changed, 53 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc index 7a7b4674c..2a41aeb2d 100644 --- a/src/wx/audio_panel.cc +++ b/src/wx/audio_panel.cc @@ -17,8 +17,6 @@ */ -#include -#include #include "lib/config.h" #include "lib/ffmpeg_content.h" #include "lib/ffmpeg_audio_stream.h" @@ -30,11 +28,15 @@ #include "wx_util.h" #include "gain_calculator_dialog.h" #include "content_panel.h" +#include +#include +#include using std::vector; using std::cout; using std::string; using std::list; +using std::pair; using boost::dynamic_pointer_cast; using boost::lexical_cast; using boost::shared_ptr; @@ -154,16 +156,18 @@ AudioPanel::film_content_changed (int property) _mapping->set (acs ? acs->audio_mapping () : AudioMapping ()); _sizer->Layout (); } else if (property == FFmpegContentProperty::AUDIO_STREAMS) { - _stream->Clear (); if (fcs) { - vector > a = fcs->audio_streams (); - for (vector >::iterator i = a.begin(); i != a.end(); ++i) { - _stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx ((*i)->identifier ()))); + vector > data; + BOOST_FOREACH (shared_ptr i, fcs->audio_streams ()) { + data.push_back (make_pair (i->name, i->identifier ())); } + checked_set (_stream, data); if (fcs->audio_stream()) { checked_set (_stream, fcs->audio_stream()->identifier ()); } + } else { + _stream->Clear (); } } else if (property == AudioContentProperty::AUDIO_PROCESSOR) { if (acs) { @@ -264,11 +268,11 @@ AudioPanel::setup_description () { AudioContentList ac = _parent->selected_audio (); if (ac.size () != 1) { - _description->SetLabel (""); + checked_set (_description, wxT ("")); return; } - _description->SetLabel (std_to_wx (ac.front()->processing_description ())); + checked_set (_description, ac.front()->processing_description ()); } void diff --git a/src/wx/timecode.cc b/src/wx/timecode.cc index fe6819cd0..291a6ba58 100644 --- a/src/wx/timecode.cc +++ b/src/wx/timecode.cc @@ -83,11 +83,11 @@ TimecodeBase::TimecodeBase (wxWindow* parent) void TimecodeBase::clear () { - checked_set (_hours, ""); - checked_set (_minutes, ""); - checked_set (_seconds, ""); - checked_set (_frames, ""); - _fixed->SetLabel (""); + checked_set (_hours, wxT ("")); + checked_set (_minutes, wxT ("")); + checked_set (_seconds, wxT ("")); + checked_set (_frames, wxT ("")); + checked_set (_fixed, wxT ("")); } void diff --git a/src/wx/timecode.h b/src/wx/timecode.h index 1e66b8d94..620782567 100644 --- a/src/wx/timecode.h +++ b/src/wx/timecode.h @@ -76,7 +76,7 @@ public: checked_set (_seconds, boost::lexical_cast (s)); checked_set (_frames, boost::lexical_cast (f)); - _fixed->SetLabel (std_to_wx (t.timecode (fps))); + checked_set (_fixed, t.timecode (fps)); } T get (int fps) const diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 55c53e79d..cafb06dfc 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -247,10 +247,10 @@ TimingPanel::film_content_changed (int property) } } if (check.size() == 1) { - _video_frame_rate->SetValue (std_to_wx (raw_convert (vc->video_frame_rate (), 5))); + checked_set (_video_frame_rate, raw_convert (vc->video_frame_rate (), 5)); _video_frame_rate->Enable (true); } else { - _video_frame_rate->SetValue (""); + checked_set (_video_frame_rate, wxT ("")); _video_frame_rate->Enable (false); } } diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index cd3d39c67..a46ba98e2 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -179,6 +179,29 @@ checked_set (wxChoice* widget, string value) } } +void +checked_set (wxChoice* widget, vector > items) +{ + vector > current; + for (unsigned int i = 0; i < widget->GetCount(); ++i) { + current.push_back ( + make_pair ( + wx_to_std (widget->GetString (i)), + string_client_data (widget->GetClientObject (i)) + ) + ); + } + + if (current == items) { + return; + } + + widget->Clear (); + for (vector >::const_iterator i = items.begin(); i != items.end(); ++i) { + widget->Append (std_to_wx (i->first), new wxStringClientData (std_to_wx (i->second))); + } +} + void checked_set (wxTextCtrl* widget, string value) { @@ -187,6 +210,14 @@ checked_set (wxTextCtrl* widget, string value) } } +void +checked_set (wxTextCtrl* widget, wxString value) +{ + if (widget->GetValue() != value) { + widget->ChangeValue (value); + } +} + void checked_set (wxStaticText* widget, string value) { diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index f55ecbd52..dfa0fca5e 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -71,7 +71,9 @@ extern void checked_set (wxSpinCtrl* widget, int value); extern void checked_set (wxSpinCtrlDouble* widget, double value); extern void checked_set (wxChoice* widget, int value); extern void checked_set (wxChoice* widget, std::string value); +extern void checked_set (wxChoice* widget, std::vector > items); extern void checked_set (wxTextCtrl* widget, std::string value); +extern void checked_set (wxTextCtrl* widget, wxString value); extern void checked_set (wxCheckBox* widget, bool value); extern void checked_set (wxRadioButton* widget, bool value); extern void checked_set (wxStaticText* widget, std::string value); -- cgit v1.2.3