Factor out some common stuff and give a better tooltip on the 'refer' buttons when...
authorCarl Hetherington <cth@carlh.net>
Thu, 7 Jan 2016 16:02:33 +0000 (16:02 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 7 Jan 2016 16:02:33 +0000 (16:02 +0000)
src/wx/audio_panel.cc
src/wx/content_sub_panel.cc
src/wx/content_sub_panel.h
src/wx/subtitle_panel.cc
src/wx/video_panel.cc

index ff62acc6764505b60fc7239d72d911bb771fffbc..34d6ac885be65d410f10df59ad9348e12e1c0b93 100644 (file)
@@ -245,16 +245,7 @@ AudioPanel::setup_sensitivity ()
 
        list<string> why_not;
        bool const can_reference = dcp && dcp->can_reference_audio (why_not);
 
        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);
 
        if (_reference->GetValue ()) {
                _gain->wrapped()->Enable (false);
index 7ea17c15cf15c3f9de5929116737163dbf1c18e0..780f31efb9903cfb46185b2798e640df77f8f442 100644 (file)
 
 */
 
 
 */
 
-#include <wx/notebook.h>
 #include "content_sub_panel.h"
 #include "content_panel.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)
 using boost::shared_ptr;
 
 ContentSubPanel::ContentSubPanel (ContentPanel* p, wxString name)
@@ -32,3 +36,19 @@ ContentSubPanel::ContentSubPanel (ContentPanel* p, wxString name)
        SetSizer (_sizer);
 }
 
        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);
+}
index 5a1b739ef30cac9a0015a444c79019e0eff9a8cb..0ad628f0c284e212c1cafa15706853e989075c4e 100644 (file)
@@ -26,6 +26,7 @@
 
 class ContentPanel;
 class Content;
 
 class ContentPanel;
 class Content;
+class DCPContent;
 
 class ContentSubPanel : public wxPanel
 {
 
 class ContentSubPanel : public wxPanel
 {
@@ -39,6 +40,9 @@ public:
        virtual void content_selection_changed () = 0;
 
 protected:
        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;
 };
        ContentPanel* _parent;
        wxSizer* _sizer;
 };
index 74a1103499a656a97ef469ed9950ff11297b7f9b..591166a9e8d08ac20ccaf1d4493681e7a8f07ae4 100644 (file)
@@ -270,16 +270,7 @@ SubtitlePanel::setup_sensitivity ()
 
        list<string> why_not;
        bool const can_reference = dcp && dcp->can_reference_subtitle (why_not);
 
        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 ();
 
 
        bool const reference = _reference->GetValue ();
 
index 5c66588888a1c8f4a3a0f831d22972d0204dfafb..fa791550cce0aeb49c2ea07ffb37ea1e611276de 100644 (file)
@@ -440,17 +440,8 @@ VideoPanel::setup_sensitivity ()
        }
 
        list<string> why_not;
        }
 
        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);
 
        if (_reference->GetValue ()) {
                _frame_type->wrapped()->Enable (false);