Disable bits of TextPanel when we are making closed captions.
[dcpomatic.git] / src / wx / text_panel.cc
index 81ea9c9418f0cd831406f095a7fbb5c75570947b..7c2ddd7f9575c1b6dd2d0b0a26456ab7649808fc 100644 (file)
@@ -42,8 +42,10 @@ using std::string;
 using std::list;
 using std::cout;
 using boost::shared_ptr;
+using boost::optional;
 using boost::dynamic_pointer_cast;
 
+/** @param t Original text type of the content, if known */
 TextPanel::TextPanel (ContentPanel* p, TextType t)
        : ContentSubPanel (p, std_to_wx(text_type_to_name(t)))
        , _text_view (0)
@@ -52,7 +54,12 @@ TextPanel::TextPanel (ContentPanel* p, TextType t)
 {
        wxBoxSizer* reference_sizer = new wxBoxSizer (wxVERTICAL);
 
-       _reference = new wxCheckBox (this, wxID_ANY, _("Use this DCP's subtitle as OV and make VF"));
+       wxString refer = _("Use this DCP's subtitle as OV and make VF");
+       if (t == TEXT_CLOSED_CAPTION) {
+               refer = _("Use this DCP's closed caption as OV and make VF");
+       }
+
+       _reference = new wxCheckBox (this, wxID_ANY, refer);
        reference_sizer->Add (_reference, 0, wxLEFT | wxRIGHT | wxTOP, DCPOMATIC_SIZER_GAP);
 
        _reference_note = new wxStaticText (this, wxID_ANY, _(""));
@@ -278,18 +285,25 @@ TextPanel::use_toggled ()
        }
 }
 
+/** @return the text type that is currently selected in the drop-down */
+TextType
+TextPanel::current_type () const
+{
+       switch (_type->GetSelection()) {
+       case 0:
+               return TEXT_OPEN_SUBTITLE;
+       case 1:
+               return TEXT_CLOSED_CAPTION;
+       }
+
+       return TEXT_UNKNOWN;
+}
+
 void
 TextPanel::type_changed ()
 {
        BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text()) {
-               switch (_type->GetSelection()) {
-               case 0:
-                       i->text_of_original_type(_original_type)->set_type (TEXT_OPEN_SUBTITLE);
-                       break;
-               case 1:
-                       i->text_of_original_type(_original_type)->set_type (TEXT_CLOSED_CAPTION);
-                       break;
-               }
+               i->text_of_original_type(_original_type)->set_type (current_type ());
        }
 }
 
@@ -337,21 +351,23 @@ TextPanel::setup_sensitivity ()
 
        bool const reference = _reference->GetValue ();
 
+       TextType const type = current_type ();
+
        /* Set up sensitivity */
        _use->Enable (!reference && any_subs > 0);
        bool const use = _use->GetValue ();
        _type->Enable (!reference && any_subs > 0 && use);
-       _burn->Enable (!reference && any_subs > 0 && use && _type->GetSelection() == 0);
-       _x_offset->Enable (!reference && any_subs > 0 && use);
-       _y_offset->Enable (!reference && any_subs > 0 && use);
-       _x_scale->Enable (!reference && any_subs > 0 && use);
-       _y_scale->Enable (!reference && any_subs > 0 && use);
-       _line_spacing->Enable (!reference && use);
+       _burn->Enable (!reference && any_subs > 0 && use && type == TEXT_OPEN_SUBTITLE);
+       _x_offset->Enable (!reference && any_subs > 0 && use && type == TEXT_OPEN_SUBTITLE);
+       _y_offset->Enable (!reference && any_subs > 0 && use && type == TEXT_OPEN_SUBTITLE);
+       _x_scale->Enable (!reference && any_subs > 0 && use && type == TEXT_OPEN_SUBTITLE);
+       _y_scale->Enable (!reference && any_subs > 0 && use && type == TEXT_OPEN_SUBTITLE);
+       _line_spacing->Enable (!reference && use && type == TEXT_OPEN_SUBTITLE);
        _language->Enable (!reference && any_subs > 0 && use);
        _stream->Enable (!reference && ffmpeg_subs == 1);
        _text_view_button->Enable (!reference);
-       _fonts_dialog_button->Enable (!reference);
-       _appearance_dialog_button->Enable (!reference && any_subs > 0 && use);
+       _fonts_dialog_button->Enable (!reference && type == TEXT_OPEN_SUBTITLE);
+       _appearance_dialog_button->Enable (!reference && any_subs > 0 && use && type == TEXT_OPEN_SUBTITLE);
 }
 
 void