Update available containers whenever they change, always adding the one that the...
authorCarl Hetherington <cth@carlh.net>
Wed, 3 Apr 2024 21:26:50 +0000 (23:26 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 22 Apr 2024 11:03:04 +0000 (13:03 +0200)
src/lib/config.h
src/wx/dcp_panel.cc
src/wx/full_config_dialog.cc

index 05421c20a7688ddf6b3fc8c4ea7667d16b151931..ff71f8a388e9a4927455d2bbe69a955745cf47c3 100644 (file)
@@ -97,6 +97,7 @@ public:
                AUTO_CROP_THRESHOLD,
                ALLOW_SMPTE_BV20,
                ISDCF_NAME_PART_LENGTH,
+               ALLOW_ANY_CONTAINER,
 #ifdef DCPOMATIC_GROK
                GROK,
 #endif
@@ -742,7 +743,7 @@ public:
        }
 
        void set_allow_any_container (bool a) {
-               maybe_set (_allow_any_container, a);
+               maybe_set(_allow_any_container, a, ALLOW_ANY_CONTAINER);
        }
 
        void set_allow_96hhz_audio (bool a) {
index 5ad719abceacc1957d2e0bfd9ffeff7ea90b2614..2d4e9b3d3b4865f0341bf2baa4062ff9c7a455fd 100644 (file)
@@ -458,6 +458,7 @@ DCPPanel::film_changed(FilmProperty p)
                break;
        case FilmProperty::VIDEO_ENCODING:
                set_standard();
+               setup_container();
                break;
        case FilmProperty::LIMIT_TO_SMPTE_BV20:
                set_standard();
@@ -540,24 +541,28 @@ DCPPanel::film_content_changed (int property)
 void
 DCPPanel::setup_container ()
 {
-       int n = 0;
-       auto ratios = Ratio::containers ();
-       auto i = ratios.begin ();
-       while (i != ratios.end() && *i != _film->container()) {
-               ++i;
-               ++n;
+       auto ratios = Ratio::containers();
+       if (std::find(ratios.begin(), ratios.end(), _film->container()) == ratios.end()) {
+               ratios.push_back(_film->container());
        }
 
-       if (i == ratios.end()) {
-               checked_set (_container, -1);
-               checked_set (_container_size, wxT(""));
-       } else {
-               checked_set (_container, n);
-               auto const size = fit_ratio_within (_film->container()->ratio(), _film->full_frame ());
-               checked_set (_container_size, wxString::Format("%dx%d", size.width, size.height));
+       wxArrayString new_ratios;
+       for (auto ratio: ratios) {
+               new_ratios.Add(std_to_wx(ratio->container_nickname()));
        }
 
+       _container->set_entries(new_ratios);
+
+       auto iter = std::find_if(ratios.begin(), ratios.end(), [this](Ratio const* ratio) { return ratio == _film->container(); });
+       DCPOMATIC_ASSERT(iter != ratios.end());
+
+       checked_set(_container, iter - ratios.begin());
+       auto const size = fit_ratio_within(_film->container()->ratio(), _film->full_frame ());
+       checked_set(_container_size, wxString::Format("%dx%d", size.width, size.height));
+
        setup_dcp_name ();
+
+       _video_grid->Layout();
 }
 
 
@@ -822,10 +827,6 @@ DCPPanel::make_video_panel ()
        _three_d->bind(&DCPPanel::three_d_changed, this);
        _reencode_j2k->bind(&DCPPanel::reencode_j2k_changed, this);
 
-       for (auto i: Ratio::containers()) {
-               _container->add(i->container_nickname());
-       }
-
        for (auto i: Config::instance()->allowed_dcp_frame_rates()) {
                _frame_rate_choice->add_entry(boost::lexical_cast<string>(i));
        }
index 2947d98ebea12effcd13eff83a1a482245f9bdec..092c9ab26821d2468363776986a0dc9cc323bb54 100644 (file)
@@ -1559,13 +1559,7 @@ private:
 
                _allow_any_container = new CheckBox(_panel, _("Allow full-frame and non-standard container ratios"));
                table->Add(_allow_any_container, 1, wxEXPAND | wxLEFT, DCPOMATIC_SIZER_GAP);
-               auto restart = new StaticText(_panel, variant::wx::insert_dcpomatic(_("(restart %s to see all ratios)")));
-               auto font = restart->GetFont();
-               font.SetStyle(wxFONTSTYLE_ITALIC);
-               font.SetPointSize(font.GetPointSize() - 1);
-               restart->SetFont(font);
-               table->Add(restart, 1, wxALIGN_CENTRE_VERTICAL | wxBOTTOM, DCPOMATIC_CHECKBOX_BOTTOM_PAD);
-               restart->SetFont(font);
+               table->AddSpacer(0);
 
                checkbox(_("Allow creation of DCPs with 96kHz audio"), _allow_96khz_audio);
                checkbox(_("Allow mapping to all audio channels"), _use_all_audio_channels);