Merge FilterEditor and FilterDialog.
authorCarl Hetherington <cth@carlh.net>
Sat, 20 Jun 2020 19:17:37 +0000 (21:17 +0200)
committerCarl Hetherington <cth@carlh.net>
Sat, 27 Jun 2020 19:47:18 +0000 (21:47 +0200)
src/wx/filter_dialog.cc
src/wx/filter_dialog.h
src/wx/filter_editor.cc [deleted file]
src/wx/filter_editor.h [deleted file]
src/wx/wscript

index ac3e354045718516f97109a6b55a1c4c408511bf..6f479e5466c68f58783104a73ee4a529693e41f1 100644 (file)
  *  @brief A dialog to select FFmpeg filters.
  */
 
-#include "lib/film.h"
+#include "check_box.h"
 #include "filter_dialog.h"
-#include "filter_editor.h"
+#include "static_text.h"
+#include "wx_util.h"
+#include "lib/film.h"
+#include "lib/filter.h"
+#include <boost/foreach.hpp>
+
 
 using namespace std;
 using boost::bind;
 
-FilterDialog::FilterDialog (wxWindow* parent, vector<Filter const *> const & f)
-       : wxDialog (parent, wxID_ANY, wxString (_("Filters")))
-       , _filters (new FilterEditor (this, f))
+
+FilterDialog::FilterDialog (wxWindow* parent, vector<Filter const *> const & active)
+       : wxDialog (parent, wxID_ANY, wxString(_("Filters")))
 {
+       wxPanel* panel = new wxPanel (this);
        wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
-       sizer->Add (_filters, 1, wxEXPAND | wxALL, 6);
 
-       _filters->ActiveChanged.connect (bind (&FilterDialog::active_changed, this));
+       vector<Filter const *> filters = Filter::all ();
+
+       typedef map<string, list<Filter const *> > CategoryMap;
+       CategoryMap categories;
+
+       BOOST_FOREACH (Filter const* i, filters) {
+               CategoryMap::iterator j = categories.find (i->category());
+               if (j == categories.end ()) {
+                       list<Filter const *> 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);
+
+               BOOST_FOREACH (Filter const* 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 (active());
+}
+
+
+vector<Filter const*>
+FilterDialog::active () const
 {
-       ActiveChanged (_filters->active ());
+       vector<Filter const *> active;
+       for (map<Filter const *, wxCheckBox*>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
+               if (i->second->IsChecked()) {
+                       active.push_back(i->first);
+               }
+       }
+
+       return active;
 }
+
index a71adb6927f595e57233cd7a3ea894ce07c85648..3ba4a09f5992342ef2e0e8593a20e80d872bde7f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -26,7 +26,6 @@
 #include <boost/signals2.hpp>
 
 class Film;
-class FilterEditor;
 class Filter;
 
 /** @class FilterDialog
@@ -41,6 +40,8 @@ public:
 
 private:
        void active_changed ();
+       void filter_toggled ();
+       std::vector<Filter const *> active () const;
 
-       FilterEditor* _filters;
+       std::map<Filter const *, wxCheckBox *> _filters;
 };
diff --git a/src/wx/filter_editor.cc b/src/wx/filter_editor.cc
deleted file mode 100644 (file)
index 32faee3..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
-    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
-
-    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.
-
-    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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-/** @file  src/filter_editor.cc
- *  @brief A panel to select FFmpeg filters.
- */
-
-#include "filter_editor.h"
-#include "wx_util.h"
-#include "static_text.h"
-#include "check_box.h"
-#include "lib/filter.h"
-#include <iostream>
-#include <algorithm>
-
-using namespace std;
-
-FilterEditor::FilterEditor (wxWindow* parent, vector<Filter const *> const & active)
-       : wxPanel (parent)
-{
-       wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
-       SetSizer (sizer);
-
-       vector<Filter const *> filters = Filter::all ();
-
-       typedef map<string, list<Filter const *> > CategoryMap;
-       CategoryMap categories;
-
-       for (vector<Filter const *>::iterator i = filters.begin(); i != filters.end(); ++i) {
-               CategoryMap::iterator j = categories.find ((*i)->category ());
-               if (j == categories.end ()) {
-                       list<Filter const *> 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 (this, std_to_wx(i->first));
-               wxFont font = c->GetFont();
-               font.SetWeight(wxFONTWEIGHT_BOLD);
-               c->SetFont(font);
-               sizer->Add (c);
-
-               for (list<Filter const *>::iterator j = i->second.begin(); j != i->second.end(); ++j) {
-                       wxCheckBox* b = new CheckBox (this, 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 (&FilterEditor::filter_toggled, this));
-                       sizer->Add (b);
-               }
-
-               sizer->AddSpacer (6);
-       }
-}
-
-void
-FilterEditor::filter_toggled ()
-{
-       ActiveChanged ();
-}
-
-vector<Filter const*>
-FilterEditor::active () const
-{
-       vector<Filter const *> active;
-       for (map<Filter const *, wxCheckBox*>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
-               if (i->second->IsChecked ()) {
-                       active.push_back (i->first);
-               }
-       }
-
-       return active;
-}
diff --git a/src/wx/filter_editor.h b/src/wx/filter_editor.h
deleted file mode 100644 (file)
index 3018b57..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
-    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.
-
-    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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-/** @file  src/filter_editor.h
- *  @brief A panel to select FFmpeg filters.
- */
-
-#include <boost/signals2.hpp>
-#include <vector>
-#include <map>
-#include <wx/wx.h>
-
-class Filter;
-
-/** @class FilterEditor
- *  @brief A panel to select FFmpeg filters.
- */
-class FilterEditor : public wxPanel
-{
-public:
-       FilterEditor (wxWindow *, std::vector<Filter const *> const &);
-
-       std::vector<Filter const *> active () const;
-
-       boost::signals2::signal<void()> ActiveChanged;
-
-private:
-       void filter_toggled ();
-
-       std::map<Filter const *, wxCheckBox *> _filters;
-};
index 7acbcc56f89073302735a3a804028e880cacd9cc..c2d4357fb6ce4f8f1e9553e5b02020912f0d6d6d 100644 (file)
@@ -71,7 +71,6 @@ sources = """
           film_name_location_dialog.cc
           film_viewer.cc
           filter_dialog.cc
-          filter_editor.cc
           focus_manager.cc
           fonts_dialog.cc
           full_config_dialog.cc