diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-06-02 16:26:54 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-06-02 16:26:54 +0100 |
| commit | dcf3d9cc30592457f2485cb71aed29bd0da67e60 (patch) | |
| tree | 6a2252e1d2127b3b1c4dcf1a7c7ac83a7b303011 /src | |
| parent | c83860a39065c9b5d767e134a4f8ed494305960f (diff) | |
21cb435ed5eb250a7f94887ddd75f6b367ea231f from master; better colour conversion selection.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/video_panel.cc | 97 | ||||
| -rw-r--r-- | src/wx/video_panel.h | 7 |
2 files changed, 57 insertions, 47 deletions
diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index 9ddfd6714..5030f7837 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ #include "content_widget.h" #include "content_panel.h" #include <wx/spinctrl.h> +#include <boost/foreach.hpp> #include <set> using std::vector; @@ -168,13 +169,28 @@ VideoPanel::VideoPanel (ContentPanel* p) _filters_button = new wxButton (this, wxID_ANY, _("Edit...")); grid->Add (_filters_button, wxGBPosition (r, 3), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); ++r; - - _enable_colour_conversion = new wxCheckBox (this, wxID_ANY, _("Colour conversion")); - grid->Add (_enable_colour_conversion, wxGBPosition (r, 0), wxGBSpan (1, 2), wxALIGN_CENTER_VERTICAL); - _colour_conversion = new wxStaticText (this, wxID_ANY, wxT (""), wxDefaultPosition, size); - grid->Add (_colour_conversion, wxGBPosition (r, 2), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); - _colour_conversion_button = new wxButton (this, wxID_ANY, _("Edit...")); - grid->Add (_colour_conversion_button, wxGBPosition (r, 3), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); + + add_label_to_grid_bag_sizer (grid, this, _("Colour conversion"), true, wxGBPosition (r, 0)); + { + wxSizer* s = new wxBoxSizer (wxHORIZONTAL); + + wxClientDC dc (this); + wxSize size = dc.GetTextExtent (wxT ("A quite long-ish name")); + size.SetHeight (-1); + + _colour_conversion = new wxChoice (this, wxID_ANY, wxDefaultPosition, size); + _colour_conversion->Append (_("None")); + BOOST_FOREACH (PresetColourConversion const & i, PresetColourConversion::all()) { + _colour_conversion->Append (std_to_wx (i.name)); + } + _colour_conversion->Append (_("Custom")); + s->Add (_colour_conversion, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6); + + _edit_colour_conversion_button = new wxButton (this, wxID_ANY, _("Edit...")); + s->Add (_edit_colour_conversion_button, 0, wxALIGN_CENTER_VERTICAL); + + grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); + } ++r; _description = new wxStaticText (this, wxID_ANY, wxT ("\n \n \n \n \n"), wxDefaultPosition, wxDefaultSize); @@ -206,9 +222,9 @@ VideoPanel::VideoPanel (ContentPanel* p) _fade_in->Changed.connect (boost::bind (&VideoPanel::fade_in_changed, this)); _fade_out->Changed.connect (boost::bind (&VideoPanel::fade_out_changed, this)); - _filters_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_filters_clicked, this)); - _enable_colour_conversion->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&VideoPanel::enable_colour_conversion_clicked, this)); - _colour_conversion_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_colour_conversion_clicked, this)); + _filters_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_filters_clicked, this)); + _colour_conversion->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::colour_conversion_changed, this)); + _edit_colour_conversion_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_colour_conversion_clicked, this)); } void @@ -246,23 +262,21 @@ VideoPanel::film_content_changed (int property) setup_description (); } else if (property == VideoContentProperty::COLOUR_CONVERSION) { if (!vcs) { - checked_set (_colour_conversion, wxT ("")); + checked_set (_colour_conversion, 0); + _edit_colour_conversion_button->Enable (false); } else if (vcs->colour_conversion ()) { optional<size_t> preset = vcs->colour_conversion().get().preset (); vector<PresetColourConversion> cc = PresetColourConversion::all (); if (preset) { - checked_set (_colour_conversion, std_to_wx (cc[preset.get()].name)); + checked_set (_colour_conversion, preset.get() + 1); + _edit_colour_conversion_button->Enable (false); } else { - checked_set (_colour_conversion, _("Custom")); + checked_set (_colour_conversion, cc.size() + 1); + _edit_colour_conversion_button->Enable (true); } - _enable_colour_conversion->SetValue (true); - _colour_conversion->Enable (true); - _colour_conversion_button->Enable (true); } else { - checked_set (_colour_conversion, _("None")); - _enable_colour_conversion->SetValue (false); - _colour_conversion->Enable (false); - _colour_conversion_button->Enable (false); + checked_set (_colour_conversion, 0); + _edit_colour_conversion_button->Enable (false); } } else if (property == FFmpegContentProperty::FILTERS) { if (fcs) { @@ -340,22 +354,36 @@ VideoPanel::setup_description () } void -VideoPanel::edit_colour_conversion_clicked () +VideoPanel::colour_conversion_changed () { VideoContentList vc = _parent->selected_video (); if (vc.size() != 1) { return; } - if (!vc.front()->colour_conversion ()) { + int const s = _colour_conversion->GetSelection (); + vector<PresetColourConversion> all = PresetColourConversion::all (); + + if (s == 0) { + vc.front()->unset_colour_conversion (); + } else if (s == int (all.size() + 1)) { + edit_colour_conversion_clicked (); + } else { + vc.front()->set_colour_conversion (all[s - 1].conversion); + } +} + +void +VideoPanel::edit_colour_conversion_clicked () +{ + VideoContentList vc = _parent->selected_video (); + if (vc.size() != 1) { return; } - ColourConversion conversion = vc.front()->colour_conversion().get (); ContentColourConversionDialog* d = new ContentColourConversionDialog (this); - d->set (conversion); + d->set (vc.front()->colour_conversion().get_value_or (PresetColourConversion::all().front ().conversion)); d->ShowModal (); - vc.front()->set_colour_conversion (d->get ()); d->Destroy (); } @@ -378,8 +406,6 @@ VideoPanel::content_selection_changed () _scale->set_content (video_sel); _filters_button->Enable (single && !ffmpeg_sel.empty ()); - _enable_colour_conversion->Enable (single); - _colour_conversion_button->Enable (single); film_content_changed (VideoContentProperty::VIDEO_CROP); film_content_changed (VideoContentProperty::VIDEO_FRAME_RATE); @@ -408,18 +434,3 @@ VideoPanel::fade_out_changed () (*i)->set_fade_out (_fade_out->get (vfr).frames (vfr)); } } - -void -VideoPanel::enable_colour_conversion_clicked () -{ - VideoContentList vc = _parent->selected_video (); - if (vc.size() != 1) { - return; - } - - if (_enable_colour_conversion->GetValue()) { - vc.front()->set_default_colour_conversion (); - } else { - vc.front()->unset_colour_conversion (); - } -} diff --git a/src/wx/video_panel.h b/src/wx/video_panel.h index 9c496c4ee..d90612fdd 100644 --- a/src/wx/video_panel.h +++ b/src/wx/video_panel.h @@ -45,7 +45,7 @@ public: private: void edit_filters_clicked (); - void enable_colour_conversion_clicked (); + void colour_conversion_changed (); void edit_colour_conversion_clicked (); void fade_in_changed (); void fade_out_changed (); @@ -63,7 +63,6 @@ private: wxStaticText* _description; wxStaticText* _filters; wxButton* _filters_button; - wxCheckBox* _enable_colour_conversion; - wxStaticText* _colour_conversion; - wxButton* _colour_conversion_button; + wxChoice* _colour_conversion; + wxButton* _edit_colour_conversion_button; }; |
