modify clr btn 16 plugins, add regdmp for sigtraps, rework mask_engine, mask rotate...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / unsharp / unsharpwindow.C
index 6341b5cdb3e11ff5b52cdf053b15795956d0cbee..18a0403dc68604764fbedce748cab0815edda4e7 100644 (file)
 
 #include "bcdisplayinfo.h"
 #include "language.h"
+#include "theme.h"
 #include "unsharp.h"
 #include "unsharpwindow.h"
 
 
-
-
-
-
-
-
-
-
 UnsharpWindow::UnsharpWindow(UnsharpMain *plugin)
- : PluginClientWindow(plugin, 285, 160, 285, 160, 0)
+ : PluginClientWindow(plugin, 285, 170, 285, 170, 0)
 {
        this->plugin = plugin;
 }
@@ -45,36 +38,53 @@ UnsharpWindow::~UnsharpWindow()
 
 void UnsharpWindow::create_objects()
 {
-       int x = 10, y = 10;
+       int x = 10, y = 10, x1 = 90;
+       int x2 = 0; int clrBtn_w = 50;
+       int defaultBtn_w = 100;
        BC_Title *title;
 
        add_subwindow(title = new BC_Title(x, y + 10, _("Radius:")));
-       add_subwindow(radius = new UnsharpRadius(plugin,
-               x + title->get_w() + 10,
-               y));
+       add_subwindow(radius = new UnsharpRadius(plugin, x + x1, y));
+       x2 = 285 - 10 - clrBtn_w;
+       add_subwindow(radiusClr = new UnsharpSliderClr(plugin, this, x2, y + 10, clrBtn_w, RESET_RADIUS));
 
        y += 40;
        add_subwindow(title = new BC_Title(x, y + 10, _("Amount:")));
-       add_subwindow(amount = new UnsharpAmount(plugin,
-               x + title->get_w() + 10,
-               y));
+       add_subwindow(amount = new UnsharpAmount(plugin, x + x1, y));
+       add_subwindow(amountClr = new UnsharpSliderClr(plugin, this, x2, y + 10, clrBtn_w, RESET_AMOUNT));
 
        y += 40;
        add_subwindow(title = new BC_Title(x, y + 10, _("Threshold:")));
-       add_subwindow(threshold = new UnsharpThreshold(plugin,
-               x + title->get_w() + 10,
-               y));
+       add_subwindow(threshold = new UnsharpThreshold(plugin, x + x1, y));
+       add_subwindow(thresholdClr = new UnsharpSliderClr(plugin, this, x2, y + 10, clrBtn_w, RESET_THRESHOLD));
+
+       y += 50;
+       add_subwindow(reset = new UnsharpReset(plugin, this, x, y));
+       add_subwindow(default_settings = new UnsharpDefaultSettings(plugin, this,
+               (285 - 10 - defaultBtn_w), y, defaultBtn_w));
 
        show_window();
        flush();
 }
 
 
-void UnsharpWindow::update()
+void UnsharpWindow::update_gui(int clear)
 {
-       radius->update(plugin->config.radius);
-       amount->update(plugin->config.amount);
-       threshold->update(plugin->config.threshold);
+       switch(clear) {
+               case RESET_RADIUS : radius->update(plugin->config.radius);
+                       break;
+               case RESET_AMOUNT : amount->update(plugin->config.amount);
+                       break;
+               case RESET_THRESHOLD : threshold->update(plugin->config.threshold);
+                       break;
+               case RESET_ALL :
+               case RESET_DEFAULT_SETTINGS :
+               default:
+                       radius->update(plugin->config.radius);
+                       amount->update(plugin->config.amount);
+                       threshold->update(plugin->config.threshold);
+                       break;
+       }
 }
 
 
@@ -122,6 +132,57 @@ int UnsharpThreshold::handle_event()
        return 1;
 }
 
+UnsharpReset::UnsharpReset(UnsharpMain *plugin, UnsharpWindow *window, int x, int y)
+ : BC_GenericButton(x, y, _("Reset"))
+{
+       this->plugin = plugin;
+       this->window = window;
+}
+UnsharpReset::~UnsharpReset()
+{
+}
+int UnsharpReset::handle_event()
+{
+       plugin->config.reset(RESET_ALL);
+       window->update_gui(RESET_ALL);
+       plugin->send_configure_change();
+       return 1;
+}
 
+UnsharpDefaultSettings::UnsharpDefaultSettings(UnsharpMain *plugin, UnsharpWindow *window, int x, int y, int w)
+ : BC_GenericButton(x, y, w, _("Default"))
+{
+       this->plugin = plugin;
+       this->window = window;
+}
+UnsharpDefaultSettings::~UnsharpDefaultSettings()
+{
+}
+int UnsharpDefaultSettings::handle_event()
+{
+       plugin->config.reset(RESET_DEFAULT_SETTINGS);
+       window->update_gui(RESET_DEFAULT_SETTINGS);
+       plugin->send_configure_change();
+       return 1;
+}
 
-
+UnsharpSliderClr::UnsharpSliderClr(UnsharpMain *plugin, UnsharpWindow *window, int x, int y, int w, int clear)
+ : BC_Button(x, y, w, plugin->get_theme()->get_image_set("reset_button"))
+{
+       this->plugin = plugin;
+       this->window = window;
+       this->clear = clear;
+}
+UnsharpSliderClr::~UnsharpSliderClr()
+{
+}
+int UnsharpSliderClr::handle_event()
+{
+       // clear==1 ==> Radius slider
+       // clear==2 ==> Amount slider
+       // clear==3 ==> Threshold slider
+       plugin->config.reset(clear);
+       window->update_gui(clear);
+       plugin->send_configure_change();
+       return 1;
+}