Add new "copy markers from this DCP" option (#2628).
authorCarl Hetherington <cth@carlh.net>
Mon, 9 Oct 2023 23:05:27 +0000 (01:05 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 9 Oct 2023 23:05:30 +0000 (01:05 +0200)
Also stop the "copy settings" options from doing this, as Carsten points
out that it could be confusing and potentially very bad if you copy
markers from an OV to an edited VF which then bring house lights up at
the wrong time or whatever.

src/lib/copy_dcp_details_to_film.cc
src/lib/copy_dcp_details_to_film.h
src/wx/content_menu.cc
src/wx/content_menu.h

index 206475ed6965b59300bfd4306bebdc2c9ae17977..669fc8ac9df9313b814be9fd710626f8f415b864 100644 (file)
@@ -61,12 +61,17 @@ copy_dcp_settings_to_film(shared_ptr<const DCPContent> dcp, shared_ptr<Film> fil
                film->set_audio_channels (dcp->audio->stream()->channels());
        }
 
+       film->set_ratings (dcp->ratings());
+       film->set_content_versions (dcp->content_versions());
+}
+
+
+void
+copy_dcp_markers_to_film(shared_ptr<const DCPContent> dcp, shared_ptr<Film> film)
+{
        film->clear_markers ();
        for (auto const& i: dcp->markers()) {
-               film->set_marker (i.first, dcpomatic::DCPTime(i.second.get()));
+               film->set_marker(i.first, dcpomatic::DCPTime(i.second.get()));
        }
-
-       film->set_ratings (dcp->ratings());
-       film->set_content_versions (dcp->content_versions());
 }
 
index 99f9cdeb7cd39ff1e5ed30e5e8d809e6e34eb2e6..0948cbec161b1ba693d654d080a31437d9391ef0 100644 (file)
@@ -27,3 +27,4 @@ class Film;
 
 
 extern void copy_dcp_settings_to_film(std::shared_ptr<const DCPContent> dcp, std::shared_ptr<Film> film);
+extern void copy_dcp_markers_to_film(std::shared_ptr<const DCPContent> dcp, std::shared_ptr<Film> film);
index 722f4563b0b07114d9361b06a05da4cc13525137..8bb7e3526f73b0c52488bfcfa57695159bf2612c 100644 (file)
@@ -83,6 +83,7 @@ enum {
        ID_ov,
        ID_choose_cpl,
        ID_set_dcp_settings,
+       ID_set_dcp_markers,
        ID_remove
 };
 
@@ -106,6 +107,7 @@ ContentMenu::ContentMenu(wxWindow* p, FilmViewer& viewer)
        _cpl_menu = new wxMenu ();
        _choose_cpl = _menu->Append (ID_choose_cpl, _("Choose CPL..."), _cpl_menu);
        _set_dcp_settings = _menu->Append (ID_set_dcp_settings, _("Set project DCP settings from this DCP"));
+       _set_dcp_markers = _menu->Append(ID_set_dcp_markers, _("Set project markers from this DCP"));
        _menu->AppendSeparator ();
        _remove = _menu->Append (ID_remove, _("Remove"));
 
@@ -119,6 +121,7 @@ ContentMenu::ContentMenu(wxWindow* p, FilmViewer& viewer)
        _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::kdm, this), ID_kdm);
        _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::ov, this), ID_ov);
        _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::set_dcp_settings, this), ID_set_dcp_settings);
+       _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::set_dcp_markers, this), ID_set_dcp_markers);
        _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::remove, this), ID_remove);
        _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::cpl_selected, this, _1), 1, ID_repeat - 1);
 }
@@ -158,6 +161,7 @@ ContentMenu::popup (weak_ptr<Film> film, ContentList c, TimelineContentViewList
                        _kdm->Enable (dcp->encrypted ());
                        _ov->Enable (dcp->needs_assets ());
                        _set_dcp_settings->Enable (static_cast<bool>(dcp));
+                       _set_dcp_markers->Enable(static_cast<bool>(dcp));
                        try {
                                auto cpls = dcp::find_and_resolve_cpls (dcp->directories(), true);
                                _choose_cpl->Enable (cpls.size() > 1);
@@ -186,10 +190,12 @@ ContentMenu::popup (weak_ptr<Film> film, ContentList c, TimelineContentViewList
                        _ov->Enable (false);
                        _choose_cpl->Enable (false);
                        _set_dcp_settings->Enable (false);
+                       _set_dcp_markers->Enable(false);
                }
        } else {
                _kdm->Enable (false);
                _set_dcp_settings->Enable (false);
+               _set_dcp_markers->Enable(false);
        }
 
        _remove->Enable (!_content.empty ());
@@ -215,6 +221,21 @@ ContentMenu::set_dcp_settings ()
 }
 
 
+void
+ContentMenu::set_dcp_markers()
+{
+       auto film = _film.lock();
+       if (!film) {
+               return;
+       }
+
+       DCPOMATIC_ASSERT(_content.size() == 1);
+       auto dcp = dynamic_pointer_cast<DCPContent>(_content.front());
+       DCPOMATIC_ASSERT(dcp);
+       copy_dcp_markers_to_film(dcp, film);
+}
+
+
 void
 ContentMenu::repeat ()
 {
index c750ae852d982c6f327cee7fbafc4f0dc4b17f53..2f32502848ba7e960faf89a7bec40915c5a7d9dd 100644 (file)
@@ -61,6 +61,7 @@ private:
        void kdm ();
        void ov ();
        void set_dcp_settings ();
+       void set_dcp_markers();
        void remove ();
        void cpl_selected (wxCommandEvent& ev);
 
@@ -84,6 +85,7 @@ private:
        wxMenuItem* _ov;
        wxMenuItem* _choose_cpl;
        wxMenuItem* _set_dcp_settings;
+       wxMenuItem* _set_dcp_markers;
        wxMenuItem* _remove;
 
        wx_ptr<AutoCropDialog> _auto_crop_dialog;