Tidy up; rename add_label_to_grid_bag_sizer -> add_label_to_sizer.
[dcpomatic.git] / src / wx / audio_panel.cc
index a4976b8c1bca172e888692f0aff3f78c71c3d429..8e13225c76cd32da086d7c7dcf8829b5ba691bde 100644 (file)
@@ -66,7 +66,7 @@ AudioPanel::AudioPanel (ContentPanel* p)
                ++r;
        }
 
-       add_label_to_grid_bag_sizer (grid, this, _("Gain"), true, wxGBPosition (r, 0));
+       add_label_to_sizer (grid, this, _("Gain"), true, wxGBPosition (r, 0));
        _gain = new ContentSpinCtrlDouble<AudioContent> (
                this,
                new wxSpinCtrlDouble (this),
@@ -76,12 +76,12 @@ AudioPanel::AudioPanel (ContentPanel* p)
                );
 
        _gain->add (grid, wxGBPosition (r, 1));
-       add_label_to_grid_bag_sizer (grid, this, _("dB"), false, wxGBPosition (r, 2));
+       add_label_to_sizer (grid, this, _("dB"), false, wxGBPosition (r, 2));
        _gain_calculate_button = new wxButton (this, wxID_ANY, _("Calculate..."));
        grid->Add (_gain_calculate_button, wxGBPosition (r, 3));
        ++r;
 
-       add_label_to_grid_bag_sizer (grid, this, _("Delay"), true, wxGBPosition (r, 0));
+       add_label_to_sizer (grid, this, _("Delay"), true, wxGBPosition (r, 0));
        _delay = new ContentSpinCtrl<AudioContent> (
                this,
                new wxSpinCtrl (this),
@@ -92,7 +92,7 @@ AudioPanel::AudioPanel (ContentPanel* p)
 
        _delay->add (grid, wxGBPosition (r, 1));
        /// TRANSLATORS: this is an abbreviation for milliseconds, the unit of time
-       add_label_to_grid_bag_sizer (grid, this, _("ms"), false, wxGBPosition (r, 2));
+       add_label_to_sizer (grid, this, _("ms"), false, wxGBPosition (r, 2));
        ++r;
 
        _mapping = new AudioMappingView (this);
@@ -141,6 +141,8 @@ AudioPanel::film_changed (Film::Property property)
        case Film::VIDEO_FRAME_RATE:
                setup_description ();
                break;
+       case Film::REEL_TYPE:
+               setup_sensitivity ();
        default:
                break;
        }
@@ -230,6 +232,7 @@ AudioPanel::content_selection_changed ()
        _delay->set_content (sel);
 
        film_content_changed (AudioContentProperty::AUDIO_STREAMS);
+       film_content_changed (DCPContentProperty::REFERENCE_AUDIO);
 
        setup_sensitivity ();
 }
@@ -238,7 +241,24 @@ void
 AudioPanel::setup_sensitivity ()
 {
        AudioContentList sel = _parent->selected_audio ();
-       _reference->Enable (sel.size() == 1 && dynamic_pointer_cast<DCPContent> (sel.front ()));
+
+       shared_ptr<DCPContent> dcp;
+       if (sel.size() == 1) {
+               dcp = dynamic_pointer_cast<DCPContent> (sel.front ());
+       }
+
+       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);
 
        if (_reference->GetValue ()) {
                _gain->wrapped()->Enable (false);