2 Copyright (C) 2012-2021 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/>.
22 /** @file src/filter_dialog.cc
23 * @brief A dialog to select FFmpeg filters.
27 #include "check_box.h"
28 #include "filter_dialog.h"
29 #include "static_text.h"
32 #include "lib/filter.h"
39 FilterDialog::FilterDialog (wxWindow* parent, vector<Filter const *> const & active)
40 : wxDialog (parent, wxID_ANY, wxString(_("Filters")))
42 auto panel = new wxPanel (this);
43 auto sizer = new wxBoxSizer (wxVERTICAL);
45 auto filters = Filter::all ();
47 map<string, list<Filter const *>> categories;
49 for (auto i: filters) {
50 auto j = categories.find (i->category());
51 if (j == categories.end ()) {
52 categories[i->category()] = { i };
54 j->second.push_back (i);
58 for (auto const& i: categories) {
59 auto c = new StaticText (panel, std_to_wx(i.first));
60 auto font = c->GetFont();
61 font.SetWeight(wxFONTWEIGHT_BOLD);
63 sizer->Add (c, 1, wxTOP | wxBOTTOM, DCPOMATIC_SIZER_GAP);
65 for (auto j: i.second) {
66 auto b = new CheckBox(panel, std_to_wx(j->name()));
67 bool const a = find (active.begin(), active.end(), j) != active.end();
70 b->Bind (wxEVT_CHECKBOX, boost::bind(&FilterDialog::filter_toggled, this));
77 auto buttons = CreateSeparatedButtonSizer (wxOK);
79 sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
82 panel->SetSizer (sizer);
84 auto overall_sizer = new wxBoxSizer (wxVERTICAL);
85 overall_sizer->Add (panel, 1, wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
86 SetSizerAndFit (overall_sizer);
91 FilterDialog::filter_toggled ()
93 ActiveChanged (active());
98 FilterDialog::active () const
100 vector<Filter const *> active;
101 for (auto const& i: _filters) {
102 if (i.second->IsChecked()) {
103 active.push_back(i.first);