+ _x_offset->SetRange (-100, 100);
+ _y_offset->SetRange (-100, 100);
+ _x_scale->SetRange (0, 1000);
+ _y_scale->SetRange (0, 1000);
+ _line_spacing->SetRange (0, 1000);
+
+ _reference->bind(&TextPanel::reference_clicked, this);
+ _use->bind(&TextPanel::use_toggled, this);
+ _type->Bind (wxEVT_CHOICE, boost::bind (&TextPanel::type_changed, this));
+ _burn->bind(&TextPanel::burn_toggled, this);
+ _x_offset->Bind (wxEVT_SPINCTRL, boost::bind (&TextPanel::x_offset_changed, this));
+ _y_offset->Bind (wxEVT_SPINCTRL, boost::bind (&TextPanel::y_offset_changed, this));
+ _x_scale->Bind (wxEVT_SPINCTRL, boost::bind (&TextPanel::x_scale_changed, this));
+ _y_scale->Bind (wxEVT_SPINCTRL, boost::bind (&TextPanel::y_scale_changed, this));
+ _line_spacing->Bind (wxEVT_SPINCTRL, boost::bind (&TextPanel::line_spacing_changed, this));
+ _stream->Bind (wxEVT_CHOICE, boost::bind (&TextPanel::stream_changed, this));
+ _text_view_button->Bind (wxEVT_BUTTON, boost::bind (&TextPanel::text_view_clicked, this));
+ _fonts_dialog_button->Bind (wxEVT_BUTTON, boost::bind (&TextPanel::fonts_dialog_clicked, this));
+ _appearance_dialog_button->Bind (wxEVT_BUTTON, boost::bind (&TextPanel::appearance_dialog_clicked, this));
+
+ add_to_grid();
+ content_selection_changed ();
+
+ _sizer->Layout ();
+}
+
+
+void
+TextPanel::setup_visibility ()
+{
+ switch (current_type()) {
+ case TextType::OPEN_SUBTITLE:
+ if (_dcp_track_label) {
+ _dcp_track_label->Destroy ();
+ _dcp_track_label = nullptr;
+ }
+ if (_dcp_track) {
+ _dcp_track->Destroy ();
+ _dcp_track = nullptr;
+ }
+ if (!_outline_subtitles) {
+ _outline_subtitles = new CheckBox (this, _("Show subtitle area"));
+ _outline_subtitles->bind(&TextPanel::outline_subtitles_changed, this);
+ _grid->Add (_outline_subtitles, wxGBPosition(_outline_subtitles_row, 0), wxGBSpan(1, 2));
+ }
+ if (!_language) {
+ _language_label = create_label (this, _("Language"), true);
+ add_label_to_sizer (_grid, _language_label, true, wxGBPosition(_ccap_track_or_language_row, 0));
+ _language_sizer = new wxBoxSizer (wxHORIZONTAL);
+ _language = new LanguageTagWidget (this, _("Language of these subtitles"), boost::none, wxString("en-US-"));
+ _language->Changed.connect (boost::bind(&TextPanel::language_changed, this));
+ _language_sizer->Add (_language->sizer(), 1, wxRIGHT, DCPOMATIC_SIZER_GAP);
+ _language_type = new wxChoice (this, wxID_ANY);
+ /// TRANSLATORS: Main and Additional here are a choice for whether a set of subtitles is in the "main" language of the
+ /// film or an "additional" language.
+ _language_type->Append (_("Main"));
+ _language_type->Append (_("Additional"));
+ _language_type->Bind (wxEVT_CHOICE, boost::bind(&TextPanel::language_is_additional_changed, this));
+ _language_sizer->Add (_language_type, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_CHOICE_TOP_PAD);
+ _grid->Add (_language_sizer, wxGBPosition(_ccap_track_or_language_row, 1), wxGBSpan(1, 2));
+ film_content_changed (TextContentProperty::LANGUAGE);
+ film_content_changed (TextContentProperty::LANGUAGE_IS_ADDITIONAL);
+ }
+ break;
+ case TextType::CLOSED_CAPTION:
+ if (_language_label) {
+ _language_label->Destroy ();
+ _language_label = nullptr;
+ _grid->Remove (_language->sizer());
+ delete _language;
+ _grid->Remove (_language_sizer);
+ _language_sizer = nullptr;
+ _language = nullptr;
+ _language_type->Destroy ();
+ _language_type = nullptr;
+ }
+ if (!_dcp_track_label) {
+ _dcp_track_label = create_label (this, _("CCAP track"), true);
+ add_label_to_sizer (_grid, _dcp_track_label, true, wxGBPosition(_ccap_track_or_language_row, 0));
+ }
+ if (!_dcp_track) {
+ _dcp_track = new wxChoice (this, wxID_ANY);
+ _dcp_track->Bind (wxEVT_CHOICE, boost::bind(&TextPanel::dcp_track_changed, this));
+ _grid->Add (_dcp_track, wxGBPosition(_ccap_track_or_language_row, 1), wxDefaultSpan, wxEXPAND);
+ update_dcp_tracks ();
+ film_content_changed (TextContentProperty::DCP_TRACK);
+ }
+ if (_outline_subtitles) {
+ _outline_subtitles->Destroy ();
+ _outline_subtitles = nullptr;
+ clear_outline_subtitles ();
+ }
+ break;
+ default:
+ break;
+ }
+
+ _grid->Layout ();
+}
+
+
+void
+TextPanel::add_to_grid ()
+{