add BC_SCALE env var for hi def monitors, cleanup theme data
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / radialblur / radialblur.C
index 035ab0af196781b2a49658055c1756436d3cec86..8f25f176b358eaa6a110f6cf71f9c5f4e2bac30d 100644 (file)
@@ -30,20 +30,43 @@ REGISTER_PLUGIN(RadialBlurMain)
 
 RadialBlurConfig::RadialBlurConfig()
 {
-       reset();
+       reset(RESET_DEFAULT_SETTINGS);
 }
 
 
-void RadialBlurConfig::reset()
+void RadialBlurConfig::reset(int clear)
 {
-       x = 50;
-       y = 50;
-       steps = 10;
-       angle = 33;
-       r = 1;
-       g = 1;
-       b = 1;
-       a = 1;
+       switch(clear) {
+               case RESET_ALL :
+                       x = xS(50);
+                       y = yS(50);
+                       angle = 0;
+                       steps = 1;
+                       r = 1;
+                       g = 1;
+                       b = 1;
+                       a = 1;
+                       break;
+               case RESET_XSLIDER : x = xS(50);
+                       break;
+               case RESET_YSLIDER : y = yS(50);
+                       break;
+               case RESET_ANGLE : angle = 0;
+                       break;
+               case RESET_STEPS : steps = 1;
+                       break;
+               case RESET_DEFAULT_SETTINGS :
+               default:
+                       x = xS(50);
+                       y = yS(50);
+                       angle = 33;
+                       steps = 10;
+                       r = 1;
+                       g = 1;
+                       b = 1;
+                       a = 1;
+                       break;
+       }
 }
 
 int RadialBlurConfig::equivalent(RadialBlurConfig &that)
@@ -103,10 +126,10 @@ void RadialBlurConfig::interpolate(RadialBlurConfig &prev,
 
 RadialBlurWindow::RadialBlurWindow(RadialBlurMain *plugin)
  : PluginClientWindow(plugin,
-       230,
-       370,
-       230,
-       370,
+       xS(280),
+       yS(370),
+       xS(280),
+       yS(370),
        0)
 {
        this->plugin = plugin;
@@ -118,49 +141,78 @@ RadialBlurWindow::~RadialBlurWindow()
 
 void RadialBlurWindow::create_objects()
 {
-       int x = 10, y = 10;
+       int xs10 = xS(10), xs50 = xS(50), xs100 = xS(100);
+       int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(45);
+       int x = xs10, y = ys10;
+       int x1 = 0; int clrBtn_w = xs50;
+       int defaultBtn_w = xs100;
 
        add_subwindow(new BC_Title(x, y, _("X:")));
-       y += 20;
+       y += ys20;
        add_subwindow(this->x = new RadialBlurSize(plugin, x, y, &plugin->config.x, 0, 100));
-       y += 30;
+       x1 = x + this->x->get_w() + xs10;
+       add_subwindow(xClr = new RadialBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_XSLIDER));
+
+       y += ys30;
        add_subwindow(new BC_Title(x, y, _("Y:")));
-       y += 20;
+       y += ys20;
        add_subwindow(this->y = new RadialBlurSize(plugin, x, y, &plugin->config.y, 0, 100));
-       y += 30;
+       add_subwindow(yClr = new RadialBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_YSLIDER));
+
+       y += ys30;
        add_subwindow(new BC_Title(x, y, _("Angle:")));
-       y += 20;
+       y += ys20;
        add_subwindow(angle = new RadialBlurSize(plugin, x, y, &plugin->config.angle, 0, 360));
-       y += 30;
+       add_subwindow(angleClr = new RadialBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_ANGLE));
+
+       y += ys30;
        add_subwindow(new BC_Title(x, y, _("Steps:")));
-       y += 20;
+       y += ys20;
        add_subwindow(steps = new RadialBlurSize(plugin, x, y, &plugin->config.steps, 1, 100));
-       y += 30;
+       add_subwindow(stepsClr = new RadialBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_STEPS));
+
+       y += ys30;
        add_subwindow(r = new RadialBlurToggle(plugin, x, y, &plugin->config.r, _("Red")));
-       y += 30;
+       y += ys30;
        add_subwindow(g = new RadialBlurToggle(plugin, x, y, &plugin->config.g, _("Green")));
-       y += 30;
+       y += ys30;
        add_subwindow(b = new RadialBlurToggle(plugin, x, y, &plugin->config.b, _("Blue")));
-       y += 30;
+       y += ys30;
        add_subwindow(a = new RadialBlurToggle(plugin, x, y, &plugin->config.a, _("Alpha")));
-       y += 40;
+       y += ys40;
        add_subwindow(reset = new RadialBlurReset(plugin, this, x, y));
+       add_subwindow(default_settings = new RadialBlurDefaultSettings(plugin, this,
+               (280 - 10 - defaultBtn_w), y, defaultBtn_w));
 
        show_window();
        flush();
 }
 
 // for Reset button
-void RadialBlurWindow::update()
+void RadialBlurWindow::update_gui(int clear)
 {
-       this->x->update(plugin->config.x);
-       this->y->update(plugin->config.y);
-       angle->update(plugin->config.angle);
-       steps->update(plugin->config.steps);
-       r->update(plugin->config.r);
-       g->update(plugin->config.g);
-       b->update(plugin->config.b);
-       a->update(plugin->config.a);
+       switch(clear) {
+               case RESET_XSLIDER : this->x->update(plugin->config.x);
+                       break;
+               case RESET_YSLIDER : this->y->update(plugin->config.y);
+                       break;
+               case RESET_ANGLE : angle->update(plugin->config.angle);
+                       break;
+               case RESET_STEPS : steps->update(plugin->config.steps);
+                       break;
+               case RESET_ALL :
+               case RESET_DEFAULT_SETTINGS :
+               default:
+                       this->x->update(plugin->config.x);
+                       this->y->update(plugin->config.y);
+                       angle->update(plugin->config.angle);
+                       steps->update(plugin->config.steps);
+                       r->update(plugin->config.r);
+                       g->update(plugin->config.g);
+                       b->update(plugin->config.b);
+                       a->update(plugin->config.a);
+                       break;
+       }
 }
 
 
@@ -201,7 +253,7 @@ RadialBlurSize::RadialBlurSize(RadialBlurMain *plugin,
        int *output,
        int min,
        int max)
- : BC_ISlider(x, y, 0, 200, 200, min, max, *output)
+ : BC_ISlider(x, y, 0, xS(200), yS(200), min, max, *output)
 {
        this->plugin = plugin;
        this->output = output;
@@ -230,14 +282,52 @@ RadialBlurReset::~RadialBlurReset()
 }
 int RadialBlurReset::handle_event()
 {
-       plugin->config.reset();
-       gui->update();
+       plugin->config.reset(RESET_ALL);
+       gui->update_gui(RESET_ALL);
        plugin->send_configure_change();
        return 1;
 }
 
 
+RadialBlurDefaultSettings::RadialBlurDefaultSettings(RadialBlurMain *plugin, RadialBlurWindow *gui, int x, int y, int w)
+ : BC_GenericButton(x, y, w, _("Default"))
+{
+       this->plugin = plugin;
+       this->gui = gui;
+}
+RadialBlurDefaultSettings::~RadialBlurDefaultSettings()
+{
+}
+int RadialBlurDefaultSettings::handle_event()
+{
+       plugin->config.reset(RESET_DEFAULT_SETTINGS);
+       gui->update_gui(RESET_DEFAULT_SETTINGS);
+       plugin->send_configure_change();
+       return 1;
+}
+
 
+RadialBlurSliderClr::RadialBlurSliderClr(RadialBlurMain *plugin, RadialBlurWindow *gui, 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->gui = gui;
+       this->clear = clear;
+}
+RadialBlurSliderClr::~RadialBlurSliderClr()
+{
+}
+int RadialBlurSliderClr::handle_event()
+{
+       // clear==1 ==> X slider
+       // clear==2 ==> Y slider
+       // clear==3 ==> Angle slider
+       // clear==4 ==> Steps slider
+       plugin->config.reset(clear);
+       gui->update_gui(clear);
+       plugin->send_configure_change();
+       return 1;
+}