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_dialog.cc
22 * @brief A dialog to select FFmpeg filters.
25 #include "check_box.h"
26 #include "filter_dialog.h"
27 #include "static_text.h"
30 #include "lib/filter.h"
37 FilterDialog::FilterDialog (wxWindow* parent, vector<Filter const *> const & active)
38 : wxDialog (parent, wxID_ANY, wxString(_("Filters")))
40 wxPanel* panel = new wxPanel (this);
41 wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
43 vector<Filter const *> filters = Filter::all ();
45 typedef map<string, list<Filter const *> > CategoryMap;
46 CategoryMap categories;
48 for (auto i: filters) {
49 CategoryMap::iterator j = categories.find (i->category());
50 if (j == categories.end ()) {
51 list<Filter const *> c;
53 categories[i->category()] = c;
55 j->second.push_back (i);
59 for (CategoryMap::iterator i = categories.begin(); i != categories.end(); ++i) {
61 wxStaticText* c = new StaticText (panel, std_to_wx(i->first));
62 wxFont font = c->GetFont();
63 font.SetWeight(wxFONTWEIGHT_BOLD);
65 sizer->Add (c, 1, wxTOP | wxBOTTOM, DCPOMATIC_SIZER_GAP);
67 for (auto j: i->second) {
68 wxCheckBox* b = new CheckBox(panel, std_to_wx(j->name()));
69 bool const a = find (active.begin(), active.end(), j) != active.end();
72 b->Bind (wxEVT_CHECKBOX, boost::bind(&FilterDialog::filter_toggled, this));
79 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
81 sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
84 panel->SetSizer (sizer);
86 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
87 overall_sizer->Add (panel, 1, wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
88 SetSizerAndFit (overall_sizer);
93 FilterDialog::filter_toggled ()
95 ActiveChanged (active());
100 FilterDialog::active () const
102 vector<Filter const *> active;
103 for (map<Filter const *, wxCheckBox*>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
104 if (i->second->IsChecked()) {
105 active.push_back(i->first);