2 Copyright (C) 2012-2018 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 /** @file src/filter_editor.cc
22 * @brief A panel to select FFmpeg filters.
25 #include "filter_editor.h"
27 #include "static_text.h"
28 #include "check_box.h"
29 #include "lib/filter.h"
35 FilterEditor::FilterEditor (wxWindow* parent, vector<Filter const *> const & active)
38 wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
41 vector<Filter const *> filters = Filter::all ();
43 typedef map<string, list<Filter const *> > CategoryMap;
44 CategoryMap categories;
46 for (vector<Filter const *>::iterator i = filters.begin(); i != filters.end(); ++i) {
47 CategoryMap::iterator j = categories.find ((*i)->category ());
48 if (j == categories.end ()) {
49 list<Filter const *> c;
51 categories[(*i)->category()] = c;
53 j->second.push_back (*i);
57 for (CategoryMap::iterator i = categories.begin(); i != categories.end(); ++i) {
59 wxStaticText* c = new StaticText (this, std_to_wx(i->first));
60 wxFont font = c->GetFont();
61 font.SetWeight(wxFONTWEIGHT_BOLD);
65 for (list<Filter const *>::iterator j = i->second.begin(); j != i->second.end(); ++j) {
66 wxCheckBox* b = new CheckBox (this, std_to_wx ((*j)->name ()));
67 bool const a = find (active.begin(), active.end(), *j) != active.end ();
70 b->Bind (wxEVT_CHECKBOX, boost::bind (&FilterEditor::filter_toggled, this));
79 FilterEditor::filter_toggled ()
85 FilterEditor::active () const
87 vector<Filter const *> active;
88 for (map<Filter const *, wxCheckBox*>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
89 if (i->second->IsChecked ()) {
90 active.push_back (i->first);