Tidy up filters dialog; don't show non-existant ones, and categorise them.
authorCarl Hetherington <cth@carlh.net>
Sat, 2 Feb 2013 14:49:02 +0000 (14:49 +0000)
committerCarl Hetherington <cth@carlh.net>
Sat, 2 Feb 2013 14:49:02 +0000 (14:49 +0000)
ChangeLog
src/lib/filter.cc
src/lib/filter.h
src/wx/filter_view.cc

index a6f3009a6dba6c67d6ba30fc732f515a75500670..fc623d7c50d4b9c7f0768ccf4b628eef5ceca492 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2013-02-02  Carl Hetherington  <cth@carlh.net>
 
+       * Tidy up filters dialog by not showing those
+       that are not configured in FFmpeg, and by splitting
+       them up into categories.
+
        * Fix infinite loop of error messages when
        `playing back' using a non-existant filter (#39).
 
index c2388272646307aac9e51e416f0cb1fabd0e15c2..9a662f90fd2b2d990adbc931dc74d6a804187f32 100644 (file)
@@ -33,12 +33,14 @@ vector<Filter const *> Filter::_filters;
 
 /** @param i Our id.
  *  @param n User-visible name.
+ *  @param c User-visible category.
  *  @param v String for a FFmpeg video filter descriptor, or "".
  *  @param p String for a FFmpeg post-processing descriptor, or "".
  */
-Filter::Filter (string i, string n, string v, string p)
+Filter::Filter (string i, string n, string c, string v, string p)
        : _id (i)
        , _name (n)
+       , _category (c)
        , _vf (v)
        , _pp (p)
 {
@@ -61,43 +63,43 @@ Filter::setup_filters ()
 {
        /* Note: "none" is a magic id name, so don't use it here */
           
-       maybe_add ("pphb", "Horizontal deblocking filter", "", "hb");
-       maybe_add ("ppvb", "Vertical deblocking filter", "", "vb");
-       maybe_add ("ppha", "Horizontal deblocking filter A", "", "ha");
-       maybe_add ("ppva", "Vertical deblocking filter A", "", "va");
-       maybe_add ("pph1", "Experimental horizontal deblocking filter 1", "", "h1");
-       maybe_add ("pphv", "Experimental vertical deblocking filter 1", "", "v1");
-       maybe_add ("ppdr", "Deringing filter", "", "dr");
-       maybe_add ("pplb", "Linear blend deinterlacer", "", "lb");
-       maybe_add ("ppli", "Linear interpolating deinterlacer", "", "li");
-       maybe_add ("ppci", "Cubic interpolating deinterlacer", "", "ci");
-       maybe_add ("ppmd", "Median deinterlacer", "", "md");
-       maybe_add ("ppfd", "FFMPEG deinterlacer", "", "fd");
-       maybe_add ("ppl5", "FIR low-pass deinterlacer", "", "l5");
-       maybe_add ("mcdeint", "Motion compensating deinterlacer", "mcdeint", "");
-       maybe_add ("kerndeint", "Kernel deinterlacer", "kerndeint", "");
-       maybe_add ("yadif", "Yet Another Deinterlacing Filter", "yadif", "");
-       maybe_add ("pptn", "Temporal noise reducer", "", "tn");
-       maybe_add ("ppfq", "Force quantizer", "", "fq");
-       maybe_add ("gradfun", "Gradient debander", "gradfun", "");
-       maybe_add ("unsharp", "Unsharp mask and Gaussian blur", "unsharp", "");
-       maybe_add ("denoise3d", "3D denoiser", "denoise3d", "");
-       maybe_add ("hqdn3d", "High quality 3D denoiser", "hqdn3d", "");
-       maybe_add ("telecine", "Telecine filter", "telecine", "");
-       maybe_add ("ow", "Overcomplete wavelet denoiser", "mp=ow", "");
+       maybe_add ("pphb",      "Horizontal deblocking filter",                "De-blocking",     "",          "hb");
+       maybe_add ("ppvb",      "Vertical deblocking filter",                  "De-blocking",     "",          "vb");
+       maybe_add ("ppha",      "Horizontal deblocking filter A",              "De-blocking",     "",          "ha");
+       maybe_add ("ppva",      "Vertical deblocking filter A",                "De-blocking",     "",          "va");
+       maybe_add ("pph1",      "Experimental horizontal deblocking filter 1", "De-blocking",     "",          "h1");
+       maybe_add ("pphv",      "Experimental vertical deblocking filter 1",   "De-blocking",     "",          "v1");
+       maybe_add ("ppdr",      "Deringing filter",                            "Misc",            "",          "dr");
+       maybe_add ("pplb",      "Linear blend deinterlacer",                   "De-interlacing",  "",          "lb");
+       maybe_add ("ppli",      "Linear interpolating deinterlacer",           "De-interlacing",  "",          "li");
+       maybe_add ("ppci",      "Cubic interpolating deinterlacer",            "De-interlacing",  "",          "ci");
+       maybe_add ("ppmd",      "Median deinterlacer",                         "De-interlacing",  "",          "md");
+       maybe_add ("ppfd",      "FFMPEG deinterlacer",                         "De-interlacing",  "",          "fd");
+       maybe_add ("ppl5",      "FIR low-pass deinterlacer",                   "De-interlacing",  "",          "l5");
+       maybe_add ("mcdeint",   "Motion compensating deinterlacer",            "De-interlacing",  "mcdeint",   "");
+       maybe_add ("kerndeint", "Kernel deinterlacer",                         "De-interlacing",  "kerndeint", "");
+       maybe_add ("yadif",     "Yet Another Deinterlacing Filter",            "De-interlacing",  "yadif",     "");
+       maybe_add ("pptn",      "Temporal noise reducer",                      "Noise reduction", "",          "tn");
+       maybe_add ("ppfq",      "Force quantizer",                             "Misc",            "",          "fq");
+       maybe_add ("gradfun",   "Gradient debander",                           "Misc",            "gradfun",   "");
+       maybe_add ("unsharp",   "Unsharp mask and Gaussian blur",              "Misc",            "unsharp",   "");
+       maybe_add ("denoise3d", "3D denoiser",                                 "Noise reduction", "denoise3d", "");
+       maybe_add ("hqdn3d",    "High quality 3D denoiser",                    "Noise reduction", "hqdn3d",    "");
+       maybe_add ("telecine",  "Telecine filter",                             "Misc",            "telecine",  "");
+       maybe_add ("ow",        "Overcomplete wavelet denoiser",               "Noise reduction", "mp=ow",     "");
 }
 
 void
-Filter::maybe_add (string i, string n, string v, string p)
+Filter::maybe_add (string i, string n, string c, string v, string p)
 {
        if (!v.empty ()) {
                if (avfilter_get_by_name (i.c_str())) {
-                       _filters.push_back (new Filter (i, n, v, p));
+                       _filters.push_back (new Filter (i, n, c, v, p));
                }
        } else if (!p.empty ()) {
                pp_mode* m = pp_get_mode_by_name_and_quality (p.c_str(), PP_QUALITY_MAX);
                if (m) {
-                       _filters.push_back (new Filter (i, n, v, p));
+                       _filters.push_back (new Filter (i, n, c, v, p));
                        pp_free_mode (m);
                }
        }
index e7e8b389f217a7c78313a0ce93b427b2a204faec..205d92482b3aa16d3fd134476335e6b6c77336e6 100644 (file)
@@ -33,7 +33,7 @@
 class Filter
 {
 public:
-       Filter (std::string, std::string, std::string, std::string);
+       Filter (std::string, std::string, std::string, std::string, std::string);
 
        /** @return our id */
        std::string id () const {
@@ -54,6 +54,10 @@ public:
        std::string pp () const {
                return _pp;
        }
+
+       std::string category () const {
+               return _category;
+       }
        
        static std::vector<Filter const *> all ();
        static Filter const * from_id (std::string);
@@ -66,6 +70,7 @@ private:
        std::string _id;
        /** user-visible name */
        std::string _name;
+       std::string _category;
        /** string for a FFmpeg video filter descriptor */
        std::string _vf;
        /** string for a FFmpeg post-processing descriptor */
@@ -73,7 +78,7 @@ private:
 
        /** all available filters */
        static std::vector<Filter const *> _filters;
-       static void maybe_add (std::string, std::string, std::string, std::string);
+       static void maybe_add (std::string, std::string, std::string, std::string, std::string);
 };
 
 #endif
index 8d9535d812c300bcfd2ff2f70848ed67af1bbf90..db6728ba58cd45a2ac05ed47148242ae72a89ab7 100644 (file)
@@ -37,13 +37,38 @@ FilterView::FilterView (wxWindow* parent, vector<Filter const *> const & active)
        
        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) {
-               wxCheckBox* b = new wxCheckBox (this, wxID_ANY, std_to_wx ((*i)->name ()));
-               bool const a = find (active.begin(), active.end(), *i) != active.end ();
-               b->SetValue (a);
-               _filters[*i] = b;
-               b->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilterView::filter_toggled), 0, this);
-               sizer->Add (b);
+               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 wxStaticText (this, wxID_ANY, 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 wxCheckBox (this, wxID_ANY, std_to_wx ((*j)->name ()));
+                       bool const a = find (active.begin(), active.end(), *j) != active.end ();
+                       b->SetValue (a);
+                       _filters[*j] = b;
+                       b->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilterView::filter_toggled), 0, this);
+                       sizer->Add (b);
+               }
+
+               sizer->AddSpacer (6);
        }
 }