2 Copyright (C) 2012 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.
27 #include "lib/filter.h"
28 #include "filter_editor.h"
33 FilterEditor::FilterEditor (wxWindow* parent, vector<Filter const *> const & active)
36 wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
39 vector<Filter const *> filters = Filter::all ();
41 typedef map<string, list<Filter const *> > CategoryMap;
42 CategoryMap categories;
44 for (vector<Filter const *>::iterator i = filters.begin(); i != filters.end(); ++i) {
45 CategoryMap::iterator j = categories.find ((*i)->category ());
46 if (j == categories.end ()) {
47 list<Filter const *> c;
49 categories[(*i)->category()] = c;
51 j->second.push_back (*i);
55 for (CategoryMap::iterator i = categories.begin(); i != categories.end(); ++i) {
57 wxStaticText* c = new wxStaticText (this, wxID_ANY, std_to_wx (i->first));
58 wxFont font = c->GetFont();
59 font.SetWeight(wxFONTWEIGHT_BOLD);
63 for (list<Filter const *>::iterator j = i->second.begin(); j != i->second.end(); ++j) {
64 wxCheckBox* b = new wxCheckBox (this, wxID_ANY, std_to_wx ((*j)->name ()));
65 bool const a = find (active.begin(), active.end(), *j) != active.end ();
68 b->Bind (wxEVT_CHECKBOX, boost::bind (&FilterEditor::filter_toggled, this));
77 FilterEditor::filter_toggled ()
83 FilterEditor::active () const
85 vector<Filter const *> active;
86 for (map<Filter const *, wxCheckBox*>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
87 if (i->second->IsChecked ()) {
88 active.push_back (i->first);