2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/filter_editor.cc
21 * @brief A panel to select FFmpeg filters.
26 #include "lib/filter.h"
27 #include "filter_editor.h"
32 FilterEditor::FilterEditor (wxWindow* parent, vector<Filter const *> const & active)
35 wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
38 vector<Filter const *> filters = Filter::all ();
40 typedef map<string, list<Filter const *> > CategoryMap;
41 CategoryMap categories;
43 for (vector<Filter const *>::iterator i = filters.begin(); i != filters.end(); ++i) {
44 CategoryMap::iterator j = categories.find ((*i)->category ());
45 if (j == categories.end ()) {
46 list<Filter const *> c;
48 categories[(*i)->category()] = c;
50 j->second.push_back (*i);
54 for (CategoryMap::iterator i = categories.begin(); i != categories.end(); ++i) {
56 wxStaticText* c = new wxStaticText (this, wxID_ANY, std_to_wx (i->first));
57 wxFont font = c->GetFont();
58 font.SetWeight(wxFONTWEIGHT_BOLD);
62 for (list<Filter const *>::iterator j = i->second.begin(); j != i->second.end(); ++j) {
63 wxCheckBox* b = new wxCheckBox (this, wxID_ANY, std_to_wx ((*j)->name ()));
64 bool const a = find (active.begin(), active.end(), *j) != active.end ();
67 b->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilterEditor::filter_toggled, this));
76 FilterEditor::filter_toggled ()
82 FilterEditor::active () const
84 vector<Filter const *> active;
85 for (map<Filter const *, wxCheckBox*>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
86 if (i->second->IsChecked ()) {
87 active.push_back (i->first);