X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fyuv%2Fyuv.C;h=275c3394fe72420a4e760aabda0802120a395a97;hb=88e56bf596fc4ed32ebc66b17307a3deeef9b0ea;hp=9e7dce83f0a6bff18d9130dcf6a789a0dda06ea7;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/yuv/yuv.C b/cinelerra-5.1/plugins/yuv/yuv.C index 9e7dce83..275c3394 100644 --- a/cinelerra-5.1/plugins/yuv/yuv.C +++ b/cinelerra-5.1/plugins/yuv/yuv.C @@ -27,19 +27,32 @@ #include "language.h" #include "bccolors.h" #include "pluginvclient.h" +#include "theme.h" #include "vframe.h" #include #include +#define MAXVALUE 100 + +#define RESET_ALL 0 +#define RESET_Y_SLIDER 1 +#define RESET_U_SLIDER 2 +#define RESET_V_SLIDER 3 class YUVEffect; +class YUVWindow; +class YUVFText; +class YUVFSlider; +class YUVReset; +class YUVClr; class YUVConfig { public: YUVConfig(); + void reset(int clear); void copy_from(YUVConfig &src); int equivalent(YUVConfig &src); @@ -52,13 +65,55 @@ public: float y, u, v; }; -class YUVLevel : public BC_FSlider + + + +class YUVFText : public BC_TumbleTextBox { public: - YUVLevel(YUVEffect *plugin, float *output, int x, int y); + YUVFText(YUVWindow *window, YUVEffect *plugin, + YUVFSlider *slider, float *output, int x, int y, float min, float max); + ~YUVFText(); int handle_event(); + YUVWindow *window; YUVEffect *plugin; + YUVFSlider *slider; float *output; + float min, max; +}; + + +class YUVFSlider : public BC_FSlider +{ +public: + YUVFSlider(YUVEffect *plugin, YUVFText *text, float *output, int x, int y); + ~YUVFSlider(); + int handle_event(); + YUVEffect *plugin; + YUVFText *text; + 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 YUVClr : public BC_Button +{ +public: + YUVClr(YUVEffect *plugin, YUVWindow *window, int x, int y, int clear); + ~YUVClr(); + int handle_event(); + YUVEffect *plugin; + YUVWindow *window; + int clear; }; class YUVWindow : public PluginClientWindow @@ -66,8 +121,22 @@ class YUVWindow : public PluginClientWindow public: YUVWindow(YUVEffect *plugin); void create_objects(); - YUVLevel *y, *u, *v; + void update_gui(int clear); + + YUVFText *y_text; + YUVFSlider *y_slider; + YUVClr *y_Clr; + + YUVFText *u_text; + YUVFSlider *u_slider; + YUVClr *u_Clr; + + YUVFText *v_text; + YUVFSlider *v_slider; + YUVClr *v_Clr; + YUVEffect *plugin; + YUVReset *reset; }; @@ -101,9 +170,23 @@ REGISTER_PLUGIN(YUVEffect) 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) @@ -137,59 +220,184 @@ void YUVConfig::interpolate(YUVConfig &prev, -#define MAXVALUE 100 -YUVLevel::YUVLevel(YUVEffect *plugin, float *output, int x, int y) - : BC_FSlider(x, - y, - 0, - 200, - 200, - -MAXVALUE, - MAXVALUE, - *output) + +YUVFText::YUVFText(YUVWindow *window, YUVEffect *plugin, + YUVFSlider *slider, float *output, int x, int y, float min, float max) + : BC_TumbleTextBox(window, *output, + min, max, x, y, xS(60), 2) { + this->window = window; this->plugin = plugin; this->output = output; + this->slider = slider; + this->min = min; + this->max = max; + set_increment(0.1); +} + +YUVFText::~YUVFText() +{ } -int YUVLevel::handle_event() +int YUVFText::handle_event() +{ + *output = atof(get_text()); + if(*output > max) *output = max; + if(*output < min) *output = min; + slider->update(*output); + plugin->send_configure_change(); + return 1; +} + + +YUVFSlider::YUVFSlider(YUVEffect *plugin, YUVFText *text, float *output, int x, int y) + : BC_FSlider(x, y, 0, xS(200), xS(200), -MAXVALUE, MAXVALUE, *output) +{ + this->plugin = plugin; + this->output = output; + this->text = text; + enable_show_value(0); // Hide caption +} + +YUVFSlider::~YUVFSlider() +{ +} + +int YUVFSlider::handle_event() { *output = get_value(); + text->update(*output); + plugin->send_configure_change(); + return 1; +} + + +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; +} + + +YUVClr::YUVClr(YUVEffect *plugin, YUVWindow *window, int x, int y, int clear) + : BC_Button(x, y, plugin->get_theme()->get_image_set("reset_button")) +{ + this->plugin = plugin; + this->window = window; + this->clear = clear; +} +YUVClr::~YUVClr() +{ +} +int YUVClr::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(420), yS(160), xS(420), yS(160), 0) { this->plugin = plugin; } void YUVWindow::create_objects() { - int x = 10, y = 10, x1 = 50; + int xs10 = xS(10); + int ys10 = yS(10), ys30 = yS(30), ys40 = yS(40); + int x = xs10, y = ys10; + int x2 = xS(80), x3 = xS(180); + int clr_x = get_w()-x - xS(22); // note: clrBtn_w = 22 + + BC_Bar *bar; + + y += ys10; add_subwindow(new BC_Title(x, y, _("Y:"))); - add_subwindow(this->y = new YUVLevel(plugin, &plugin->config.y, x1, y)); - y += 30; + y_text = new YUVFText(this, plugin, + 0, &plugin->config.y, (x + x2), y, -MAXVALUE, MAXVALUE); + y_text->create_objects(); + y_slider = new YUVFSlider(plugin, y_text, &plugin->config.y, x3, y); + add_subwindow(y_slider); + y_text->slider = y_slider; + clr_x = x3 + y_slider->get_w() + x; + add_subwindow(y_Clr = new YUVClr(plugin, this, clr_x, y, 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; + u_text = new YUVFText(this, plugin, + 0, &plugin->config.u, (x + x2), y, -MAXVALUE, MAXVALUE); + u_text->create_objects(); + u_slider = new YUVFSlider(plugin, u_text, &plugin->config.u, x3, y); + add_subwindow(u_slider); + u_text->slider = u_slider; + add_subwindow(u_Clr = new YUVClr(plugin, this, clr_x, y, RESET_U_SLIDER)); + y += ys30; + add_subwindow(new BC_Title(x, y, _("V:"))); - add_subwindow(v = new YUVLevel(plugin, &plugin->config.v, x1, y)); + v_text = new YUVFText(this, plugin, + 0, &plugin->config.v, (x + x2), y, -MAXVALUE, MAXVALUE); + v_text->create_objects(); + v_slider = new YUVFSlider(plugin, v_text, &plugin->config.v, x3, y); + add_subwindow(v_slider); + v_text->slider = v_slider; + add_subwindow(v_Clr = new YUVClr(plugin, this, clr_x, y, RESET_V_SLIDER)); + y += ys40; + +// Reset section + add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x)); + y += ys10; + 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 : + y_text->update(plugin->config.y); + y_slider->update(plugin->config.y); + break; + case RESET_U_SLIDER : + u_text->update(plugin->config.u); + u_slider->update(plugin->config.u); + break; + case RESET_V_SLIDER : + v_text->update(plugin->config.v); + v_slider->update(plugin->config.v); + break; + case RESET_ALL : + default: + y_text->update(plugin->config.y); + y_slider->update(plugin->config.y); + u_text->update(plugin->config.u); + u_slider->update(plugin->config.u); + v_text->update(plugin->config.v); + v_slider->update(plugin->config.v); + break; + } +} @@ -219,9 +427,12 @@ void YUVEffect::update_gui() { thread->window->lock_window(); load_configuration(); - ((YUVWindow*)thread->window)->y->update(config.y); - ((YUVWindow*)thread->window)->u->update(config.u); - ((YUVWindow*)thread->window)->v->update(config.v); + ((YUVWindow*)thread->window)->y_text->update(config.y); + ((YUVWindow*)thread->window)->y_slider->update(config.y); + ((YUVWindow*)thread->window)->u_text->update(config.u); + ((YUVWindow*)thread->window)->u_slider->update(config.u); + ((YUVWindow*)thread->window)->v_text->update(config.v); + ((YUVWindow*)thread->window)->v_slider->update(config.v); thread->window->unlock_window(); } }