#include "language.h"
#include "bccolors.h"
#include "pluginvclient.h"
+#include "theme.h"
#include "vframe.h"
#include <stdint.h>
#include <string.h>
+#define RESET_ALL 0
+#define RESET_Y_SLIDER 1
+#define RESET_U_SLIDER 2
+#define RESET_V_SLIDER 3
class YUVEffect;
+class YUVWindow;
+class YUVReset;
+class YUVSliderClr;
class YUVConfig
{
public:
YUVConfig();
+ void reset(int clear);
void copy_from(YUVConfig &src);
int equivalent(YUVConfig &src);
float *output;
};
+class YUVReset : public BC_GenericButton
+{
+public:
+ YUVReset(YUVEffect *plugin, YUVWindow *window, int x, int y);
+ ~YUVReset();
+ int handle_event();
+ YUVEffect *plugin;
+ YUVWindow *window;
+};
+
+class YUVSliderClr : public BC_Button
+{
+public:
+ YUVSliderClr(YUVEffect *plugin, YUVWindow *window, int x, int y, int w, int clear);
+ ~YUVSliderClr();
+ int handle_event();
+ YUVEffect *plugin;
+ YUVWindow *window;
+ int clear;
+};
+
class YUVWindow : public PluginClientWindow
{
public:
YUVWindow(YUVEffect *plugin);
void create_objects();
+ void update_gui(int clear);
YUVLevel *y, *u, *v;
YUVEffect *plugin;
+ YUVReset *reset;
+ YUVSliderClr *yClr, *uClr, *vClr;
};
YUVConfig::YUVConfig()
{
- y = 0;
- u = 0;
- v = 0;
+ reset(RESET_ALL);
+}
+
+void YUVConfig::reset(int clear)
+{
+ switch(clear) {
+ case RESET_Y_SLIDER : y = 0;
+ break;
+ case RESET_U_SLIDER : u = 0;
+ break;
+ case RESET_V_SLIDER : v = 0;
+ break;
+ case RESET_ALL :
+ default:
+ y = u = v = 0;
+ break;
+ }
}
void YUVConfig::copy_from(YUVConfig &src)
: BC_FSlider(x,
y,
0,
- 200,
- 200,
+ xS(200),
+ yS(200),
-MAXVALUE,
MAXVALUE,
*output)
}
+YUVReset::YUVReset(YUVEffect *plugin, YUVWindow *window, int x, int y)
+ : BC_GenericButton(x, y, _("Reset"))
+{
+ this->plugin = plugin;
+ this->window = window;
+}
+YUVReset::~YUVReset()
+{
+}
+int YUVReset::handle_event()
+{
+ plugin->config.reset(RESET_ALL);
+ window->update_gui(RESET_ALL);
+ plugin->send_configure_change();
+ return 1;
+}
+
+
+YUVSliderClr::YUVSliderClr(YUVEffect *plugin, YUVWindow *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;
+}
+YUVSliderClr::~YUVSliderClr()
+{
+}
+int YUVSliderClr::handle_event()
+{
+ // clear==1 ==> Y slider
+ // clear==2 ==> U slider
+ // clear==3 ==> V slider
+ plugin->config.reset(clear);
+ window->update_gui(clear);
+ plugin->send_configure_change();
+ return 1;
+}
+
+
YUVWindow::YUVWindow(YUVEffect *plugin)
- : PluginClientWindow(plugin,
- 260,
- 100,
- 260,
- 100,
- 0)
+ : PluginClientWindow(plugin, xS(310), yS(135), xS(310), yS(135), 0)
{
this->plugin = plugin;
}
void YUVWindow::create_objects()
{
- int x = 10, y = 10, x1 = 50;
+ int xs10 = xS(10), xs40 = xS(40), xs50 = xS(50);
+ int ys10 = yS(10), ys30 = yS(30), ys35 = yS(35);
+ int x = xs10, y = ys10, x1 = xs40;
+ int x2 = 0; int clrBtn_w = xs50;
+
add_subwindow(new BC_Title(x, y, _("Y:")));
add_subwindow(this->y = new YUVLevel(plugin, &plugin->config.y, x1, y));
- y += 30;
+ x2 = x1 + this->y->get_w() + xs10;
+ add_subwindow(yClr = new YUVSliderClr(plugin, this, x2, y, clrBtn_w, RESET_Y_SLIDER));
+
+ y += ys30;
add_subwindow(new BC_Title(x, y, _("U:")));
add_subwindow(u = new YUVLevel(plugin, &plugin->config.u, x1, y));
- y += 30;
+ add_subwindow(uClr = new YUVSliderClr(plugin, this, x2, y, clrBtn_w, RESET_U_SLIDER));
+
+ y += ys30;
add_subwindow(new BC_Title(x, y, _("V:")));
add_subwindow(v = new YUVLevel(plugin, &plugin->config.v, x1, y));
+ add_subwindow(vClr = new YUVSliderClr(plugin, this, x2, y, clrBtn_w, RESET_V_SLIDER));
+
+ y += ys35;
+ add_subwindow(reset = new YUVReset(plugin, this, x, y));
show_window();
flush();
}
-
+// for Reset button
+void YUVWindow::update_gui(int clear)
+{
+ switch(clear) {
+ case RESET_Y_SLIDER : this->y->update(plugin->config.y);
+ break;
+ case RESET_U_SLIDER : u->update(plugin->config.u);
+ break;
+ case RESET_V_SLIDER : v->update(plugin->config.v);
+ break;
+ case RESET_ALL :
+ default:
+ this->y->update(plugin->config.y);
+ u->update(plugin->config.u);
+ v->update(plugin->config.v);
+ break;
+ }
+}