From bd0ea5c90b5fa03224b7f89785c98976d8513d07 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 6 May 2025 01:09:16 +0200 Subject: Limit allowable reel types (#3032). --- src/wx/dcp_timeline.cc | 55 ++++++++++++++++++++++++++++++++++++++++++++++---- src/wx/dcp_timeline.h | 3 +++ 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/wx/dcp_timeline.cc b/src/wx/dcp_timeline.cc index a51c18738..a5b106c00 100644 --- a/src/wx/dcp_timeline.cc +++ b/src/wx/dcp_timeline.cc @@ -31,6 +31,7 @@ #include "lib/atmos_content.h" #include "lib/audio_content.h" #include "lib/constants.h" +#include "lib/dcp_content.h" #include "lib/film.h" #include "lib/text_content.h" #include "lib/video_content.h" @@ -166,6 +167,7 @@ DCPTimeline::DCPTimeline(wxWindow* parent, shared_ptr film) _canvas->Bind(wxEVT_MOTION, boost::bind(&DCPTimeline::mouse_moved, this, _1)); _film_connection = film->Change.connect(boost::bind(&DCPTimeline::film_changed, this, _1, _2)); + _film_content_connection = film->ContentChange.connect(boost::bind(&DCPTimeline::film_content_changed, this, _1, _3)); _menu = new wxMenu; _add_reel_boundary = _menu->Append(ID_add_reel_boundary, _("Add reel boundary")); @@ -220,6 +222,7 @@ DCPTimeline::film_changed(ChangeType type, FilmProperty property) case FilmProperty::CONTENT: case FilmProperty::CONTENT_ORDER: setup_pixels_per_second(); + setup_reel_types(); Refresh(); break; default: @@ -228,6 +231,53 @@ DCPTimeline::film_changed(ChangeType type, FilmProperty property) } +void +DCPTimeline::film_content_changed(ChangeType type, int property) +{ + if (type != ChangeType::DONE) { + return; + } + + if ( + property == DCPContentProperty::NEEDS_KDM || + property == DCPContentProperty::NEEDS_ASSETS || + property == DCPContentProperty::REFERENCE_VIDEO || + property == DCPContentProperty::REFERENCE_AUDIO || + property == DCPContentProperty::REFERENCE_TEXT) { + setup_reel_types(); + } +} + + +void +DCPTimeline::setup_reel_types() +{ + auto const possible = film()->possible_reel_types(); + + if (static_cast(possible.size()) != _reel_type->size()) { + _reel_type->clear(); + for (auto type: possible) { + switch (type) { + case ReelType::SINGLE: + _reel_type->add_entry(_("Single reel"), reel_type_to_string(ReelType::SINGLE)); + break; + case ReelType::BY_VIDEO_CONTENT: + _reel_type->add_entry(_("Split by video content"), reel_type_to_string(ReelType::BY_VIDEO_CONTENT)); + break; + case ReelType::BY_LENGTH: + _reel_type->add_entry(_("Split by maximum reel size"), reel_type_to_string(ReelType::BY_LENGTH)); + break; + case ReelType::CUSTOM: + _reel_type->add_entry(_("Custom"), reel_type_to_string(ReelType::CUSTOM)); + break; + } + } + } + + _reel_type->set_by_data(reel_type_to_string(film()->reel_type())); +} + + void DCPTimeline::setup_sensitivity() { @@ -246,10 +296,7 @@ DCPTimeline::setup_reel_settings() int r = 0; add_label_to_sizer(sizer, _reel_settings, _("Reel mode"), true, wxGBPosition(r, 0)); _reel_type = new Choice(_reel_settings); - _reel_type->add_entry(_("Single reel")); - _reel_type->add_entry(_("Split by video content")); - _reel_type->add_entry(_("Split by maximum reel size")); - _reel_type->add_entry(_("Custom")); + setup_reel_types(); sizer->Add(_reel_type, wxGBPosition(r, 1)); ++r; diff --git a/src/wx/dcp_timeline.h b/src/wx/dcp_timeline.h index e3ab386a8..e74adae8a 100644 --- a/src/wx/dcp_timeline.h +++ b/src/wx/dcp_timeline.h @@ -62,8 +62,10 @@ private: void reel_mode_changed(); void maximum_reel_size_changed(); void film_changed(ChangeType type, FilmProperty property); + void film_content_changed(ChangeType type, int property); std::shared_ptr film() const; void setup_sensitivity(); + void setup_reel_types(); void add_reel_boundary(); void remove_reel_boundary(); @@ -119,6 +121,7 @@ private: wxMenuItem* _remove_reel_boundary; boost::signals2::scoped_connection _film_connection; + boost::signals2::scoped_connection _film_content_connection; std::vector> _reel_boundaries; }; -- cgit v1.2.3