diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-01-07 16:02:33 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-01-07 16:02:33 +0000 |
| commit | f61777543c611ed3ba818bf1c564322cb71b3009 (patch) | |
| tree | 64368e19346a821e363fa8b93a6dc8ee65d2cae3 /src | |
| parent | c51f4dd82ada91d5e1c2c6a9b61089195e1fa85d (diff) | |
Factor out some common stuff and give a better tooltip on the 'refer' buttons when no DCP is selected.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/audio_panel.cc | 11 | ||||
| -rw-r--r-- | src/wx/content_sub_panel.cc | 22 | ||||
| -rw-r--r-- | src/wx/content_sub_panel.h | 4 | ||||
| -rw-r--r-- | src/wx/subtitle_panel.cc | 11 | ||||
| -rw-r--r-- | src/wx/video_panel.cc | 13 |
5 files changed, 29 insertions, 32 deletions
diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc index ff62acc67..34d6ac885 100644 --- a/src/wx/audio_panel.cc +++ b/src/wx/audio_panel.cc @@ -245,16 +245,7 @@ AudioPanel::setup_sensitivity () list<string> why_not; bool const can_reference = dcp && dcp->can_reference_audio (why_not); - _reference->Enable (can_reference); - - wxString s; - if (!can_reference) { - s = _("Cannot reference this DCP. "); - BOOST_FOREACH (string i, why_not) { - s += std_to_wx(i) + wxT(" "); - } - } - _reference->SetToolTip (s); + setup_refer_button (_reference, dcp, can_reference, why_not); if (_reference->GetValue ()) { _gain->wrapped()->Enable (false); diff --git a/src/wx/content_sub_panel.cc b/src/wx/content_sub_panel.cc index 7ea17c15c..780f31efb 100644 --- a/src/wx/content_sub_panel.cc +++ b/src/wx/content_sub_panel.cc @@ -17,10 +17,14 @@ */ -#include <wx/notebook.h> #include "content_sub_panel.h" #include "content_panel.h" +#include "wx_util.h" +#include <wx/notebook.h> +#include <boost/foreach.hpp> +using std::list; +using std::string; using boost::shared_ptr; ContentSubPanel::ContentSubPanel (ContentPanel* p, wxString name) @@ -32,3 +36,19 @@ ContentSubPanel::ContentSubPanel (ContentPanel* p, wxString name) SetSizer (_sizer); } +void +ContentSubPanel::setup_refer_button (wxCheckBox* button, shared_ptr<DCPContent> dcp, bool can_reference, list<string> why_not) const +{ + button->Enable (can_reference); + + wxString s; + if (!dcp) { + s = _("No DCP selected."); + } else if (!can_reference) { + s = _("Cannot reference this DCP. "); + BOOST_FOREACH (string i, why_not) { + s += std_to_wx(i) + wxT(" "); + } + } + button->SetToolTip (s); +} diff --git a/src/wx/content_sub_panel.h b/src/wx/content_sub_panel.h index 5a1b739ef..0ad628f0c 100644 --- a/src/wx/content_sub_panel.h +++ b/src/wx/content_sub_panel.h @@ -26,6 +26,7 @@ class ContentPanel; class Content; +class DCPContent; class ContentSubPanel : public wxPanel { @@ -39,6 +40,9 @@ public: virtual void content_selection_changed () = 0; protected: + + void setup_refer_button (wxCheckBox* button, boost::shared_ptr<DCPContent> dcp, bool can_reference, std::list<std::string> why_not) const; + ContentPanel* _parent; wxSizer* _sizer; }; diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index 74a110349..591166a9e 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -270,16 +270,7 @@ SubtitlePanel::setup_sensitivity () list<string> why_not; bool const can_reference = dcp && dcp->can_reference_subtitle (why_not); - _reference->Enable (can_reference); - - wxString s; - if (!can_reference) { - s = _("Cannot reference this DCP. "); - BOOST_FOREACH (string i, why_not) { - s += std_to_wx(i) + wxT(" "); - } - } - _reference->SetToolTip (s); + setup_refer_button (_reference, dcp, can_reference, why_not); bool const reference = _reference->GetValue (); diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index 5c6658888..fa791550c 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -440,17 +440,8 @@ VideoPanel::setup_sensitivity () } list<string> why_not; - bool const can_reference = dcp && dcp->can_reference_video(why_not); - _reference->Enable (can_reference); - - wxString s; - if (!can_reference) { - s = _("Cannot reference this DCP. "); - BOOST_FOREACH (string i, why_not) { - s += std_to_wx(i) + wxT(" "); - } - } - _reference->SetToolTip (s); + bool const can_reference = dcp && dcp->can_reference_video (why_not); + setup_refer_button (_reference, dcp, can_reference, why_not); if (_reference->GetValue ()) { _frame_type->wrapped()->Enable (false); |
