Remove x264 dependency; add options to help building on mageia.
[dcpomatic.git] / src / wx / filter_view.cc
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 /** @file  src/filter_view.cc
21  *  @brief A panel to select FFmpeg filters.
22  */
23
24 #include <iostream>
25 #include <algorithm>
26 #include "lib/filter.h"
27 #include "filter_view.h"
28 #include "wx_util.h"
29
30 using namespace std;
31
32 FilterView::FilterView (wxWindow* parent, vector<Filter const *> const & active)
33         : wxPanel (parent)
34 {
35         wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
36         SetSizer (sizer);
37         
38         vector<Filter const *> filters = Filter::all ();
39
40         for (vector<Filter const *>::iterator i = filters.begin(); i != filters.end(); ++i) {
41                 wxCheckBox* b = new wxCheckBox (this, wxID_ANY, std_to_wx ((*i)->name ()));
42                 bool const a = find (active.begin(), active.end(), *i) != active.end ();
43                 b->SetValue (a);
44                 _filters[*i] = b;
45                 b->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilterView::filter_toggled), 0, this);
46                 sizer->Add (b);
47         }
48 }
49
50 void
51 FilterView::filter_toggled (wxCommandEvent &)
52 {
53         ActiveChanged ();
54 }
55
56 vector<Filter const*>
57 FilterView::active () const
58 {
59         vector<Filter const *> active;
60         for (map<Filter const *, wxCheckBox*>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
61                 if (i->second->IsChecked ()) {
62                         active.push_back (i->first);
63                 }
64         }
65
66         return active;
67 }