Fix small DCP standard choice (#2475).
[dcpomatic.git] / src / wx / dcp_panel.cc
index d8aa3ac460986acb4e096cdd2b73ac2c31531184..6574bcdb314397c14f388397fc218857b9200671 100644 (file)
@@ -150,17 +150,70 @@ DCPPanel::DCPPanel(wxNotebook* n, shared_ptr<Film> film, FilmViewer& viewer)
        _reel_type->add(_("Split by video content"));
        /// TRANSLATORS: translate the word "Custom" here; do not include the "Reel|" prefix
        _reel_type->add(S_("Reel|Custom"));
+       _reel_type->SetToolTip(_("How the DCP should be split into parts internally.  If in doubt, choose 'Single reel'"));
 
        _reel_length->SetRange (1, 64);
 
-       _standard->add(_("SMPTE"));
-       _standard->add(_("Interop"));
+       add_standards();
+       _standard->SetToolTip(_("Which standard the DCP should use.  Interop is older and SMPTE is the modern standard.  If in doubt, choose 'SMPTE'"));
 
        Config::instance()->Changed.connect (boost::bind(&DCPPanel::config_changed, this, _1));
 
        add_to_grid ();
 }
 
+
+void
+DCPPanel::add_standards()
+{
+       _standard->add(_("SMPTE"), N_("smpte"));
+       if (Config::instance()->allow_smpte_bv20() || (_film && _film->limit_to_smpte_bv20())) {
+               _standard->add(_("SMPTE (Bv2.0 only)"), N_("smpte-bv20"));
+       }
+       _standard->add(_("Interop"), N_("interop"));
+       _sizer->Layout();
+}
+
+
+void
+DCPPanel::set_standard()
+{
+       DCPOMATIC_ASSERT(_film);
+       DCPOMATIC_ASSERT(!_film->limit_to_smpte_bv20() || _standard->GetCount() == 3);
+
+       if (_film->interop()) {
+               checked_set(_standard, "interop");
+       } else {
+               checked_set(_standard, _film->limit_to_smpte_bv20() ? "smpte-bv20" : "smpte");
+       }
+}
+
+
+void
+DCPPanel::standard_changed ()
+{
+       if (!_film || !_standard->get()) {
+               return;
+       }
+
+       auto const data = _standard->get_data();
+       if (!data) {
+               return;
+       }
+
+       if (*data == N_("interop")) {
+               _film->set_interop(true);
+               _film->set_limit_to_smpte_bv20(false);
+       } else if (*data == N_("smpte")) {
+               _film->set_interop(false);
+               _film->set_limit_to_smpte_bv20(false);
+       } else if (*data == N_("smpte-bv20")) {
+               _film->set_interop(false);
+               _film->set_limit_to_smpte_bv20(true);
+       }
+}
+
+
 void
 DCPPanel::add_to_grid ()
 {
@@ -313,26 +366,10 @@ DCPPanel::resolution_changed ()
 }
 
 
-void
-DCPPanel::standard_changed ()
-{
-       if (!_film || !_standard->get()) {
-               return;
-       }
-
-       _film->set_interop(*_standard->get() == 1);
-
-}
-
 void
 DCPPanel::markers_clicked ()
 {
-       if (_markers_dialog) {
-               _markers_dialog->Destroy ();
-               _markers_dialog = nullptr;
-       }
-
-       _markers_dialog = new MarkersDialog (_panel, _film, _viewer);
+       _markers_dialog.reset(_panel, _film, _viewer);
        _markers_dialog->Show();
 }
 
@@ -341,21 +378,11 @@ void
 DCPPanel::metadata_clicked ()
 {
        if (_film->interop()) {
-               if (_interop_metadata_dialog) {
-                       _interop_metadata_dialog->Destroy ();
-                       _interop_metadata_dialog = nullptr;
-               }
-
-               _interop_metadata_dialog = new InteropMetadataDialog (_panel, _film);
+               _interop_metadata_dialog.reset(_panel, _film);
                _interop_metadata_dialog->setup ();
                _interop_metadata_dialog->Show ();
        } else {
-               if (_smpte_metadata_dialog) {
-                       _smpte_metadata_dialog->Destroy ();
-                       _smpte_metadata_dialog = nullptr;
-               }
-
-               _smpte_metadata_dialog = new SMPTEMetadataDialog (_panel, _film);
+               _smpte_metadata_dialog.reset(_panel, _film);
                _smpte_metadata_dialog->setup ();
                _smpte_metadata_dialog->Show ();
        }
@@ -447,10 +474,13 @@ DCPPanel::film_changed (Film::Property p)
                checked_set (_reencode_j2k, _film->reencode_j2k());
                break;
        case Film::Property::INTEROP:
-               checked_set (_standard, _film->interop() ? 1 : 0);
+               set_standard();
                setup_dcp_name ();
                _markers->Enable (!_film->interop());
                break;
+       case Film::Property::LIMIT_TO_SMPTE_BV20:
+               set_standard();
+               break;
        case Film::Property::AUDIO_PROCESSOR:
                if (_film->audio_processor()) {
                        checked_set (_audio_processor, _film->audio_processor()->id());
@@ -586,22 +616,10 @@ void
 DCPPanel::set_film (shared_ptr<Film> film)
 {
        /* We are changing film, so destroy any dialogs for the old one */
-       if (_audio_dialog) {
-               _audio_dialog->Destroy ();
-               _audio_dialog = nullptr;
-       }
-       if (_markers_dialog) {
-               _markers_dialog->Destroy ();
-               _markers_dialog = nullptr;
-       }
-       if (_interop_metadata_dialog) {
-               _interop_metadata_dialog->Destroy ();
-               _interop_metadata_dialog = nullptr;
-       }
-       if (_smpte_metadata_dialog) {
-               _smpte_metadata_dialog->Destroy ();
-               _smpte_metadata_dialog = nullptr;
-       }
+       _audio_dialog.reset();
+       _markers_dialog.reset();
+       _interop_metadata_dialog.reset();
+       _smpte_metadata_dialog.reset();
 
        _film = film;
 
@@ -612,6 +630,9 @@ DCPPanel::set_film (shared_ptr<Film> film)
                return;
        }
 
+       _standard->Clear();
+       add_standards();
+
        film_changed (Film::Property::NAME);
        film_changed (Film::Property::USE_ISDCF_NAME);
        film_changed (Film::Property::CONTENT);
@@ -631,6 +652,7 @@ DCPPanel::set_film (shared_ptr<Film> film)
        film_changed (Film::Property::REENCODE_J2K);
        film_changed (Film::Property::AUDIO_LANGUAGE);
        film_changed (Film::Property::AUDIO_FRAME_RATE);
+       film_changed (Film::Property::LIMIT_TO_SMPTE_BV20);
 
        set_general_sensitivity(static_cast<bool>(_film));
 }
@@ -751,6 +773,13 @@ DCPPanel::config_changed (Config::Property p)
                if (_film) {
                        film_changed (Film::Property::AUDIO_PROCESSOR);
                }
+       } else if (p == Config::ALLOW_SMPTE_BV20) {
+               _standard->Clear();
+               add_standards();
+               if (_film) {
+                       film_changed(Film::Property::INTEROP);
+                       film_changed(Film::Property::LIMIT_TO_SMPTE_BV20);
+               }
        }
 }
 
@@ -765,6 +794,7 @@ DCPPanel::setup_frame_rate_widget ()
                _frame_rate_choice->Show ();
                _frame_rate_spin->Hide ();
        }
+       _frame_rate_sizer->Layout();
 }
 
 
@@ -787,7 +817,6 @@ DCPPanel::make_video_panel ()
        _frame_rate_label = create_label (panel, _("Frame Rate"), true);
        _frame_rate_choice = new Choice(panel);
        _frame_rate_spin = new SpinCtrl (panel, DCPOMATIC_SPIN_CTRL_WIDTH);
-       setup_frame_rate_widget ();
        _best_frame_rate = new Button (panel, _("Use best"));
 
        _three_d = new CheckBox (panel, _("3D"));
@@ -824,6 +853,7 @@ DCPPanel::make_video_panel ()
        _resolution->add(_("4K"));
 
        add_video_panel_to_grid ();
+       setup_frame_rate_widget();
 
        return panel;
 }
@@ -979,13 +1009,8 @@ DCPPanel::show_audio_clicked ()
                return;
        }
 
-       if (_audio_dialog) {
-               _audio_dialog->Destroy ();
-               _audio_dialog = nullptr;
-       }
-
-       auto d = new AudioDialog (_panel, _film, _viewer);
-       d->Show ();
+       _audio_dialog.reset(_panel, _film, _viewer);
+       _audio_dialog->Show();
 }
 
 
@@ -1039,11 +1064,10 @@ void
 DCPPanel::edit_audio_language_clicked ()
 {
        DCPOMATIC_ASSERT (_film->audio_language());
-       auto d = new LanguageTagDialog (_panel, *_film->audio_language());
+       auto d = make_wx<LanguageTagDialog>(_panel, *_film->audio_language());
        if (d->ShowModal() == wxID_OK) {
               _film->set_audio_language(d->get());
        }
-       d->Destroy ();
 }