2 Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "lib/colour_conversion.h"
22 #include "lib/config.h"
25 #include "content_colour_conversion_dialog.h"
26 #include "colour_conversion_editor.h"
27 #include <wx/statline.h>
28 #include <boost/foreach.hpp>
34 using boost::optional;
36 ContentColourConversionDialog::ContentColourConversionDialog (wxWindow* parent, bool yuv)
37 : wxDialog (parent, wxID_ANY, _("Colour conversion"))
38 , _editor (new ColourConversionEditor (this, yuv))
41 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
42 SetSizer (overall_sizer);
44 wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_Y_GAP - 2, DCPOMATIC_SIZER_X_GAP);
45 _preset_check = new wxCheckBox (this, wxID_ANY, _("Use preset"));
46 table->Add (_preset_check, 0, wxALIGN_CENTER_VERTICAL);
47 _preset_choice = new wxChoice (this, wxID_ANY);
48 table->Add (_preset_choice);
50 overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
51 overall_sizer->Add (new wxStaticLine (this, wxID_ANY), 0, wxEXPAND);
52 overall_sizer->Add (_editor);
54 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
56 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
59 overall_sizer->Layout ();
60 overall_sizer->SetSizeHints (this);
62 _preset_check->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ContentColourConversionDialog::preset_check_clicked, this));
63 _preset_choice->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&ContentColourConversionDialog::preset_choice_changed, this));
65 _editor_connection = _editor->Changed.connect (boost::bind (&ContentColourConversionDialog::check_for_preset, this));
67 BOOST_FOREACH (PresetColourConversion const &i, PresetColourConversion::all ()) {
68 _preset_choice->Append (std_to_wx (i.name));
73 ContentColourConversionDialog::get () const
75 return _editor->get ();
79 ContentColourConversionDialog::set (ColourConversion c)
89 ContentColourConversionDialog::check_for_preset ()
95 optional<size_t> preset = _editor->get().preset ();
97 _preset_check->SetValue (static_cast<bool>(preset));
98 _preset_choice->Enable (static_cast<bool>(preset));
100 _preset_choice->SetSelection (preset.get ());
102 _preset_choice->SetSelection (-1);
107 ContentColourConversionDialog::preset_check_clicked ()
109 if (_preset_check->GetValue ()) {
110 _preset_choice->SetSelection (0);
111 preset_choice_changed ();
113 _preset_choice->SetSelection (-1);
114 _preset_choice->Enable (false);
119 ContentColourConversionDialog::preset_choice_changed ()
121 vector<PresetColourConversion> presets = PresetColourConversion::all ();
122 int const s = _preset_choice->GetCurrentSelection();
124 set (presets[s].conversion);