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& 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>> 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& category: categories) {
59 auto c = new StaticText(panel, std_to_wx(category.first));
60 auto font = c->GetFont();
61 font.SetWeight(wxFONTWEIGHT_BOLD);
63 sizer->Add (c, 1, wxTOP | wxBOTTOM, DCPOMATIC_SIZER_GAP);
65 for (auto const& filter: category.second) {
66 auto b = new CheckBox(panel, std_to_wx(filter.name()));
67 bool const a = find(active.begin(), active.end(), filter) != active.end();
70 b->bind(&FilterDialog::filter_toggled, this);
77 panel->SetSizer (sizer);
79 auto overall_sizer = new wxBoxSizer (wxVERTICAL);
80 overall_sizer->Add (panel, 1, wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
82 auto buttons = CreateSeparatedButtonSizer(wxOK);
84 overall_sizer->Add(buttons, wxSizerFlags().Expand().DoubleBorder());
87 SetSizerAndFit (overall_sizer);
92 FilterDialog::filter_toggled ()
94 ActiveChanged (active());
99 FilterDialog::active () const
101 vector<Filter> active;
102 for (auto const& i: _filters) {
103 if (i.second->IsChecked()) {
104 active.push_back(i.first);