X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Fwx%2Ffilter_dialog.cc;h=a65f5153a2f95e9733619123997bc2d1180285bc;hp=bd844845298bcdd3012eed9308ea732c33b4e765;hb=a5d004b0773f633401528392fc28e66d70e13ac8;hpb=5fa99824e1bf31f569245e5f2640aeecd84de42d diff --git a/src/wx/filter_dialog.cc b/src/wx/filter_dialog.cc index bd8448452..a65f5153a 100644 --- a/src/wx/filter_dialog.cc +++ b/src/wx/filter_dialog.cc @@ -1,19 +1,20 @@ /* Copyright (C) 2012 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ @@ -21,34 +22,90 @@ * @brief A dialog to select FFmpeg filters. */ -#include "lib/film.h" +#include "check_box.h" #include "filter_dialog.h" -#include "filter_view.h" +#include "static_text.h" +#include "wx_util.h" +#include "lib/film.h" +#include "lib/filter.h" + using namespace std; +using boost::bind; + -FilterDialog::FilterDialog (wxWindow* parent, vector const & f) - : wxDialog (parent, wxID_ANY, _("Filters")) - , _filters (new FilterView (this, f)) +FilterDialog::FilterDialog (wxWindow* parent, vector const & active) + : wxDialog (parent, wxID_ANY, wxString(_("Filters"))) { + wxPanel* panel = new wxPanel (this); wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); - sizer->Add (_filters, 1, wxEXPAND); - _filters->ActiveChanged.connect (sigc::mem_fun (*this, &FilterDialog::active_changed)); + vector filters = Filter::all (); + + typedef map > CategoryMap; + CategoryMap categories; + + for (auto i: filters) { + CategoryMap::iterator j = categories.find (i->category()); + if (j == categories.end ()) { + list c; + c.push_back (i); + categories[i->category()] = c; + } else { + j->second.push_back (i); + } + } + + for (CategoryMap::iterator i = categories.begin(); i != categories.end(); ++i) { + + wxStaticText* c = new StaticText (panel, std_to_wx(i->first)); + wxFont font = c->GetFont(); + font.SetWeight(wxFONTWEIGHT_BOLD); + c->SetFont(font); + sizer->Add (c, 1, wxTOP | wxBOTTOM, DCPOMATIC_SIZER_GAP); + + for (auto j: i->second) { + wxCheckBox* b = new CheckBox(panel, std_to_wx(j->name())); + bool const a = find (active.begin(), active.end(), j) != active.end(); + b->SetValue (a); + _filters[j] = b; + b->Bind (wxEVT_CHECKBOX, boost::bind(&FilterDialog::filter_toggled, this)); + sizer->Add (b); + } + + sizer->AddSpacer (6); + } wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); if (buttons) { sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); } - SetSizer (sizer); - sizer->Layout (); - sizer->SetSizeHints (this); + panel->SetSizer (sizer); + + wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); + overall_sizer->Add (panel, 1, wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP); + SetSizerAndFit (overall_sizer); } - + void -FilterDialog::active_changed () +FilterDialog::filter_toggled () { - ActiveChanged (_filters->active ()); + ActiveChanged (active()); } + + +vector +FilterDialog::active () const +{ + vector active; + for (map::const_iterator i = _filters.begin(); i != _filters.end(); ++i) { + if (i->second->IsChecked()) { + active.push_back(i->first); + } + } + + return active; +} +