add BC_SCALE env var for hi def monitors, cleanup theme data
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / huesaturation / huesaturation.C
index 7f050232d92eb206172a0a140d9543ff3317e4ec..bbaf2ca6f96f505db0206a8fca7a5e036acd24fc 100644 (file)
@@ -31,6 +31,7 @@
 #include "bccolors.h"
 #include "playback3d.h"
 #include "pluginvclient.h"
+#include "theme.h"
 #include "vframe.h"
 
 #include <stdint.h>
@@ -46,12 +47,23 @@ REGISTER_PLUGIN(HueEffect)
 
 HueConfig::HueConfig()
 {
-       reset();
+       reset(RESET_ALL);
 }
 
-void HueConfig::reset()
+void HueConfig::reset(int clear)
 {
-       hue = saturation = value = 0;
+       switch(clear) {
+               case RESET_HUV : hue = 0;
+                       break;
+               case RESET_SAT : saturation = 0;
+                       break;
+               case RESET_VAL : value = 0;
+                       break;
+               case RESET_ALL :
+               default:
+                       hue = saturation = value = 0;
+                       break;
+       }
 }
 
 void HueConfig::copy_from(HueConfig &src)
@@ -183,8 +195,30 @@ HueReset::~HueReset()
 }
 int HueReset::handle_event()
 {
-       plugin->config.reset();
-       gui->update();
+       plugin->config.reset(RESET_ALL); // clear=0 ==> reset all
+       gui->update_gui(RESET_ALL);
+       plugin->send_configure_change();
+       return 1;
+}
+
+
+HueSliderClr::HueSliderClr(HueEffect *plugin, HueWindow *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;
+}
+HueSliderClr::~HueSliderClr()
+{
+}
+int HueSliderClr::handle_event()
+{
+       // clear==1 ==> Hue slider
+       // clear==2 ==> Saturation slider
+       // clear==3 ==> Value slider
+       plugin->config.reset(clear);
+       gui->update_gui(clear);
        plugin->send_configure_change();
        return 1;
 }
@@ -193,22 +227,33 @@ int HueReset::handle_event()
 
 
 HueWindow::HueWindow(HueEffect *plugin)
- : PluginClientWindow(plugin, 345, 145, 345, 145, 0)
+ : PluginClientWindow(plugin, xS(370), yS(140), xS(370), yS(140), 0)
 {
        this->plugin = plugin;
 }
 void HueWindow::create_objects()
 {
-       int x = 10, y = 10, x1 = 100;
+       int xs10 = xS(10), xs50 = xS(50), xs100 = xS(100), xs200 = xS(200);
+       int ys10 = yS(10), ys30 = yS(30), ys40 = yS(40);
+       int x = xs10, y = ys10, x1 = xs100;
+       int x2 = 0; int clrBtn_w = xs50;
+
        add_subwindow(new BC_Title(x, y, _("Hue:")));
-       add_subwindow(hue = new HueSlider(plugin, x1, y, 200));
-       y += 30;
+       add_subwindow(hue = new HueSlider(plugin, x1, y, xs200));
+       x2 = x1 + hue->get_w() + xs10;
+       add_subwindow(hueClr = new HueSliderClr(plugin, this, x2, y, clrBtn_w, RESET_HUV));
+
+       y += ys30;
        add_subwindow(new BC_Title(x, y, _("Saturation:")));
-       add_subwindow(saturation = new SaturationSlider(plugin, x1, y, 200));
-       y += 30;
+       add_subwindow(saturation = new SaturationSlider(plugin, x1, y, xs200));
+       add_subwindow(satClr = new HueSliderClr(plugin, this, x2, y, clrBtn_w, RESET_SAT));
+
+       y += ys30;
        add_subwindow(new BC_Title(x, y, _("Value:")));
-       add_subwindow(value = new ValueSlider(plugin, x1, y, 200));
-       y += 40;
+       add_subwindow(value = new ValueSlider(plugin, x1, y, xs200));
+       add_subwindow(valClr = new HueSliderClr(plugin, this, x2, y, clrBtn_w, RESET_VAL));
+
+       y += ys40;
        add_subwindow(reset = new HueReset(plugin, this, x, y));
        show_window();
        flush();
@@ -216,11 +261,22 @@ void HueWindow::create_objects()
 
 
 // for Reset button
-void HueWindow::update()
+void HueWindow::update_gui(int clear)
 {
-       hue->update(plugin->config.hue);
-       saturation->update(plugin->config.saturation);
-       value->update(plugin->config.value);
+       switch(clear) {
+               case RESET_HUV : hue->update(plugin->config.hue);
+                       break;
+               case RESET_SAT : saturation->update(plugin->config.saturation);
+                       break;
+               case RESET_VAL : value->update(plugin->config.value);
+                       break;
+               case RESET_ALL :
+               default:
+                       hue->update(plugin->config.hue);
+                       saturation->update(plugin->config.saturation);
+                       value->update(plugin->config.value);
+                       break;
+       }
 }