X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fyuv%2Fyuv.C;h=275c3394fe72420a4e760aabda0802120a395a97;hb=fdf615e4b9eb6ce8faecc7f138c28edf0efac3be;hp=75139b9d98225cb9096c5f955d71dd9f9b0fd861;hpb=54cc56bff09f5004b2a6cd454375f06e56acf5a0;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/yuv/yuv.C b/cinelerra-5.1/plugins/yuv/yuv.C index 75139b9d..275c3394 100644 --- a/cinelerra-5.1/plugins/yuv/yuv.C +++ b/cinelerra-5.1/plugins/yuv/yuv.C @@ -27,22 +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(); + void reset(int clear); void copy_from(YUVConfig &src); int equivalent(YUVConfig &src); @@ -55,15 +65,36 @@ public: float y, u, v; }; -class YUVLevel : public BC_FSlider + + + +class YUVFText : public BC_TumbleTextBox +{ +public: + 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: - YUVLevel(YUVEffect *plugin, float *output, int x, int y); + 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: @@ -74,13 +105,36 @@ public: 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 { public: YUVWindow(YUVEffect *plugin); void create_objects(); - void update(); - 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; }; @@ -116,14 +170,23 @@ REGISTER_PLUGIN(YUVEffect) YUVConfig::YUVConfig() { - reset(); + reset(RESET_ALL); } -void YUVConfig::reset() +void YUVConfig::reset(int clear) { - y = 0; - u = 0; - v = 0; + 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) @@ -157,25 +220,54 @@ 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 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 } -int YUVLevel::handle_event() +YUVFSlider::~YUVFSlider() +{ +} + +int YUVFSlider::handle_event() { *output = get_value(); + text->update(*output); plugin->send_configure_change(); return 1; } @@ -192,36 +284,86 @@ YUVReset::~YUVReset() } int YUVReset::handle_event() { - plugin->config.reset(); - window->update(); + 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, - 135, - 260, - 135, - 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 = 40; + 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)); - y += 35; + 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(); @@ -230,11 +372,31 @@ void YUVWindow::create_objects() // for Reset button -void YUVWindow::update() +void YUVWindow::update_gui(int clear) { - this->y->update(plugin->config.y); - u->update(plugin->config.u); - v->update(plugin->config.v); + 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; + } } @@ -265,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(); } }