From: Carl Hetherington Date: Sat, 29 Feb 2020 20:42:17 +0000 (+0100) Subject: Allow changing colour conversion settings for multiple pieces of content at the same... X-Git-Tag: v2.14.31 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=99918e4964d696c2cdc6512b8f2ebb9d46db3163;ds=sidebyside Allow changing colour conversion settings for multiple pieces of content at the same time (github #7). Back-ported from c403e757cf0b029954fe18dc969314bfb179412f in v2.15.x. --- diff --git a/src/lib/colour_conversion.cc b/src/lib/colour_conversion.cc index a966963af..2e052060e 100644 --- a/src/lib/colour_conversion.cc +++ b/src/lib/colour_conversion.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2020 Carl Hetherington This file is part of DCP-o-matic. diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index 1dc0185ba..f74157faf 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -38,6 +38,8 @@ #include "lib/video_content.h" #include #include +#include +#include #include #include @@ -309,6 +311,17 @@ VideoPanel::film_changed (Film::Property property) } } +std::size_t +hash_value (boost::optional const & c) +{ + boost::hash hasher; + if (!c) { + return hasher ("none"); + } + return hasher (c->identifier()); +} + + void VideoPanel::film_content_changed (int property) { @@ -326,16 +339,36 @@ VideoPanel::film_content_changed (int property) property == VideoContentProperty::SCALE) { setup_description (); } else if (property == VideoContentProperty::COLOUR_CONVERSION) { - if (vcs && vcs->video->colour_conversion ()) { - optional preset = vcs->video->colour_conversion().get().preset (); - vector cc = PresetColourConversion::all (); - if (preset) { - checked_set (_colour_conversion, preset.get() + 1); + boost::unordered_set > check; + BOOST_FOREACH (shared_ptr i, vc) { + check.insert (i->video->colour_conversion()); + } + + /* Remove any "Many" entry that we might have added previously. There should + * be entries for each preset plus one for "None" and one for "Custom". + */ + vector cc = PresetColourConversion::all (); + if (_colour_conversion->GetCount() > cc.size() + 2) { + _colour_conversion->Delete (_colour_conversion->GetCount() - 1); + } + + if (check.size() == 1) { + if (vcs && vcs->video->colour_conversion ()) { + optional preset = vcs->video->colour_conversion().get().preset (); + if (preset) { + checked_set (_colour_conversion, preset.get() + 1); + } else { + checked_set (_colour_conversion, cc.size() + 1); + } } else { - checked_set (_colour_conversion, cc.size() + 1); + checked_set (_colour_conversion, 0); } - } else { - checked_set (_colour_conversion, 0); + } else if (check.size() > 1) { + /* Add a "many" entry and select it as an indication that multiple different + * colour conversions are present in the selection. + */ + _colour_conversion->Append (_("Many")); + checked_set (_colour_conversion, _colour_conversion->GetCount() - 1); } setup_sensitivity (); @@ -434,19 +467,20 @@ void VideoPanel::colour_conversion_changed () { ContentList vc = _parent->selected_video (); - if (vc.size() != 1) { - return; - } int const s = _colour_conversion->GetSelection (); vector all = PresetColourConversion::all (); - if (s == 0) { - vc.front()->video->unset_colour_conversion (); - } else if (s == int (all.size() + 1)) { + if (s == int(all.size() + 1)) { edit_colour_conversion_clicked (); } else { - vc.front()->video->set_colour_conversion (all[s - 1].conversion); + BOOST_FOREACH (shared_ptr i, _parent->selected_video()) { + if (s == 0) { + i->video->unset_colour_conversion (); + } else if (s != int(all.size() + 2)) { + i->video->set_colour_conversion (all[s - 1].conversion); + } + } } } @@ -454,14 +488,13 @@ void VideoPanel::edit_colour_conversion_clicked () { ContentList vc = _parent->selected_video (); - if (vc.size() != 1) { - return; - } ContentColourConversionDialog* d = new ContentColourConversionDialog (this, vc.front()->video->yuv ()); d->set (vc.front()->video->colour_conversion().get_value_or (PresetColourConversion::all().front().conversion)); if (d->ShowModal() == wxID_OK) { - vc.front()->video->set_colour_conversion (d->get ()); + BOOST_FOREACH (shared_ptr i, vc) { + i->video->set_colour_conversion (d->get ()); + } } else { /* Reset the colour conversion choice */ film_content_changed (VideoContentProperty::COLOUR_CONVERSION); @@ -535,7 +568,7 @@ VideoPanel::setup_sensitivity () _description->Enable (true); _filters->Enable (true); _filters_button->Enable (single && !ffmpeg_sel.empty ()); - _colour_conversion->Enable (single && !video_sel.empty ()); + _colour_conversion->Enable (!video_sel.empty()); } ContentList vc = _parent->selected_video ();