version update
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / rgbshift / rgbshift.C
index d558687b106ad68c2b30e0929fc1d0252ba47f10..95d120580a682f02a0b2a5f026e695c36eae95c1 100644 (file)
  *
  */
 
-#include "bcdisplayinfo.h"
-#include "clip.h"
-#include "bchash.h"
-#include "filexml.h"
-#include "guicast.h"
-#include "language.h"
-#include "bccolors.h"
-#include "pluginvclient.h"
-#include "vframe.h"
-
-#include <stdint.h>
-#include <string.h>
-
-
-class RGBShiftEffect;
-
-
-class RGBShiftConfig
-{
-public:
-       RGBShiftConfig();
-
-       void copy_from(RGBShiftConfig &src);
-       int equivalent(RGBShiftConfig &src);
-       void interpolate(RGBShiftConfig &prev,
-               RGBShiftConfig &next,
-               long prev_frame,
-               long next_frame,
-               long current_frame);
-
-       int r_dx, r_dy, g_dx, g_dy, b_dx, b_dy;
-};
-
-class RGBShiftLevel : public BC_ISlider
-{
-public:
-       RGBShiftLevel(RGBShiftEffect *plugin, int *output, int x, int y);
-       int handle_event();
-       RGBShiftEffect *plugin;
-       int *output;
-};
-
-class RGBShiftWindow : public PluginClientWindow
-{
-public:
-       RGBShiftWindow(RGBShiftEffect *plugin);
-       void create_objects();
-       RGBShiftLevel *r_dx, *r_dy, *g_dx, *g_dy, *b_dx, *b_dy;
-       RGBShiftEffect *plugin;
-};
-
-
-
-class RGBShiftEffect : public PluginVClient
-{
-       VFrame *temp_frame;
-public:
-       RGBShiftEffect(PluginServer *server);
-       ~RGBShiftEffect();
-
-
-       PLUGIN_CLASS_MEMBERS(RGBShiftConfig)
-       int process_realtime(VFrame *input, VFrame *output);
-       int is_realtime();
-       void save_data(KeyFrame *keyframe);
-       void read_data(KeyFrame *keyframe);
-       void update_gui();
-};
-
-
+#include "rgbshift.h"
 
 
 
@@ -99,12 +30,33 @@ REGISTER_PLUGIN(RGBShiftEffect)
 
 
 
-
 RGBShiftConfig::RGBShiftConfig()
 {
-       r_dx = r_dy = 0;
-       g_dx = g_dy = 0;
-       b_dx = b_dy = 0;
+       reset(RESET_ALL);
+}
+
+void RGBShiftConfig::reset(int clear)
+{
+       switch(clear) {
+               case RESET_R_DX : r_dx = 0;
+                       break;
+               case RESET_R_DY : r_dy = 0;
+                       break;
+               case RESET_G_DX : g_dx = 0;
+                       break;
+               case RESET_G_DY : g_dy = 0;
+                       break;
+               case RESET_B_DX : b_dx = 0;
+                       break;
+               case RESET_B_DY : b_dy = 0;
+                       break;
+               case RESET_ALL :
+               default:
+                       r_dx = r_dy = 0;
+                       g_dx = g_dy = 0;
+                       b_dx = b_dy = 0;
+                       break;
+       }
 }
 
 void RGBShiftConfig::copy_from(RGBShiftConfig &src)
@@ -145,7 +97,7 @@ void RGBShiftConfig::interpolate(RGBShiftConfig &prev,
 #define MAXVALUE 100
 
 RGBShiftLevel::RGBShiftLevel(RGBShiftEffect *plugin, int *output, int x, int y)
- : BC_ISlider(x, y, 0, 200, 200, -MAXVALUE, MAXVALUE, *output)
+ : BC_ISlider(x, y, 0, xS(200), yS(200), -MAXVALUE, MAXVALUE, *output)
 {
        this->plugin = plugin;
        this->output = output;
@@ -159,39 +111,124 @@ int RGBShiftLevel::handle_event()
 }
 
 
+RGBShiftReset::RGBShiftReset(RGBShiftEffect *plugin, RGBShiftWindow *window, int x, int y)
+ : BC_GenericButton(x, y, _("Reset"))
+{
+       this->plugin = plugin;
+       this->window = window;
+}
+RGBShiftReset::~RGBShiftReset()
+{
+}
+int RGBShiftReset::handle_event()
+{
+       plugin->config.reset(RESET_ALL);
+       window->update_gui(RESET_ALL);
+       plugin->send_configure_change();
+       return 1;
+}
+
+
+RGBShiftSliderClr::RGBShiftSliderClr(RGBShiftEffect *plugin, RGBShiftWindow *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;
+}
+RGBShiftSliderClr::~RGBShiftSliderClr()
+{
+}
+int RGBShiftSliderClr::handle_event()
+{
+       // clear==1 ==> r_dx slider --- clear==2 ==> r_dy slider
+       // clear==3 ==> g_dx slider --- clear==4 ==> g_dy slider
+       // clear==5 ==> b_dx slider --- clear==6 ==> b_dy slider
+       plugin->config.reset(clear);
+       window->update_gui(clear);
+       plugin->send_configure_change();
+       return 1;
+}
+
+
 RGBShiftWindow::RGBShiftWindow(RGBShiftEffect *plugin)
- : PluginClientWindow(plugin, 300, 200, 300, 200, 0)
+ : PluginClientWindow(plugin, xS(320), yS(230), xS(320), yS(230), 0)
 {
        this->plugin = plugin;
 }
 
 void RGBShiftWindow::create_objects()
 {
-       int x = 10, y = 10, x1 = 50;
+       int xs10 = xS(10), xs50 = xS(50);
+       int ys10 = yS(10), ys30 = yS(30), ys40 = yS(40);
+       int x = xs10, y = ys10, x1 = xs50;
+       int x2 = 0; int clrBtn_w = xs50;
+
        add_subwindow(new BC_Title(x, y, _("R_dx:")));
        add_subwindow(r_dx = new RGBShiftLevel(plugin, &plugin->config.r_dx, x1, y));
-       y += 30;
+       x2 = x1 + r_dx->get_w() + xs10;
+       add_subwindow(r_dxClr = new RGBShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_R_DX));
+
+       y += ys30;
        add_subwindow(new BC_Title(x, y, _("R_dy:")));
        add_subwindow(r_dy = new RGBShiftLevel(plugin, &plugin->config.r_dy, x1, y));
-       y += 30;
+       add_subwindow(r_dyClr = new RGBShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_R_DY));
+
+       y += ys30;
        add_subwindow(new BC_Title(x, y, _("G_dx:")));
        add_subwindow(g_dx = new RGBShiftLevel(plugin, &plugin->config.g_dx, x1, y));
-       y += 30;
+       add_subwindow(g_dxClr = new RGBShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_G_DX));
+
+       y += ys30;
        add_subwindow(new BC_Title(x, y, _("G_dy:")));
        add_subwindow(g_dy = new RGBShiftLevel(plugin, &plugin->config.g_dy, x1, y));
-       y += 30;
+       add_subwindow(g_dyClr = new RGBShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_G_DY));
+
+       y += ys30;
        add_subwindow(new BC_Title(x, y, _("B_dx:")));
        add_subwindow(b_dx = new RGBShiftLevel(plugin, &plugin->config.b_dx, x1, y));
-       y += 30;
+       add_subwindow(b_dxClr = new RGBShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_B_DX));
+
+       y += ys30;
        add_subwindow(new BC_Title(x, y, _("B_dy:")));
        add_subwindow(b_dy = new RGBShiftLevel(plugin, &plugin->config.b_dy, x1, y));
+       add_subwindow(b_dyClr = new RGBShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_B_DY));
+
+       y += ys40;
+       add_subwindow(reset = new RGBShiftReset(plugin, this, x, y));
 
        show_window();
        flush();
 }
 
 
-
+// for Reset button
+void RGBShiftWindow::update_gui(int clear)
+{
+       switch(clear) {
+               case RESET_R_DX : r_dx->update(plugin->config.r_dx);
+                       break;
+               case RESET_R_DY : r_dy->update(plugin->config.r_dy);
+                       break;
+               case RESET_G_DX : g_dx->update(plugin->config.g_dx);
+                       break;
+               case RESET_G_DY : g_dy->update(plugin->config.g_dy);
+                       break;
+               case RESET_B_DX : b_dx->update(plugin->config.b_dx);
+                       break;
+               case RESET_B_DY : b_dy->update(plugin->config.b_dy);
+                       break;
+               case RESET_ALL :
+               default:
+                       r_dx->update(plugin->config.r_dx);
+                       r_dy->update(plugin->config.r_dy);
+                       g_dx->update(plugin->config.g_dx);
+                       g_dy->update(plugin->config.g_dy);
+                       b_dx->update(plugin->config.b_dx);
+                       b_dy->update(plugin->config.b_dy);
+                       break;
+       }
+}