diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-02-29 21:42:17 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-02-29 21:46:03 +0100 |
| commit | 99918e4964d696c2cdc6512b8f2ebb9d46db3163 (patch) | |
| tree | 3b7458f8db025a491d11933df991762a7999a2ef | |
| parent | 5e7f9bc19280faa3506fd8cdd319ccd6001de1de (diff) | |
Allow changing colour conversion settings for multiple pieces of content at the same time (github #7).v2.14.31
Back-ported from c403e757cf0b029954fe18dc969314bfb179412f in v2.15.x.
| -rw-r--r-- | src/lib/colour_conversion.cc | 2 | ||||
| -rw-r--r-- | src/wx/video_panel.cc | 73 |
2 files changed, 54 insertions, 21 deletions
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 <cth@carlh.net> + Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net> 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 <wx/spinctrl.h> #include <boost/foreach.hpp> +#include <boost/unordered_set.hpp> +#include <boost/functional/hash.hpp> #include <set> #include <iostream> @@ -309,6 +311,17 @@ VideoPanel::film_changed (Film::Property property) } } +std::size_t +hash_value (boost::optional<ColourConversion> const & c) +{ + boost::hash<string> 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<size_t> preset = vcs->video->colour_conversion().get().preset (); - vector<PresetColourConversion> cc = PresetColourConversion::all (); - if (preset) { - checked_set (_colour_conversion, preset.get() + 1); + boost::unordered_set<optional<ColourConversion> > check; + BOOST_FOREACH (shared_ptr<const Content> 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<PresetColourConversion> 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<size_t> 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<PresetColourConversion> 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<Content> 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<Content> 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 (); |
