X-Git-Url: https://cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fzoomblur%2Fzoomblur.C;h=1c64d7bc6239c03f9adda6469c32f47b152f7d90;hb=1a2c313b568030b465b165089f0b90730d17884d;hp=ad67e5407d23c62a75ea31e397fe5c2794c9201a;hpb=e375434717622cc3198a6bf9f7b7fb9fde555c21;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/zoomblur/zoomblur.C b/cinelerra-5.1/plugins/zoomblur/zoomblur.C index ad67e540..1c64d7bc 100644 --- a/cinelerra-5.1/plugins/zoomblur/zoomblur.C +++ b/cinelerra-5.1/plugins/zoomblur/zoomblur.C @@ -30,19 +30,42 @@ REGISTER_PLUGIN(ZoomBlurMain) ZoomBlurConfig::ZoomBlurConfig() { - reset(); + reset(RESET_DEFAULT_SETTINGS); } -void ZoomBlurConfig::reset() +void ZoomBlurConfig::reset(int clear) { - x = 50; - y = 50; - radius = 10; - steps = 10; - r = 1; - g = 1; - b = 1; - a = 1; + switch(clear) { + case RESET_ALL : + x = 50; + y = 50; + radius = 0; + steps = 1; + r = 1; + g = 1; + b = 1; + a = 1; + break; + case RESET_XSLIDER : x = 50; + break; + case RESET_YSLIDER : y = 50; + break; + case RESET_RADIUS : radius = 0; + break; + case RESET_STEPS : steps = 1; + break; + case RESET_DEFAULT_SETTINGS : + default: + x = 50; + y = 50; + radius = 10; + steps = 10; + r = 1; + g = 1; + b = 1; + a = 1; + break; + } } int ZoomBlurConfig::equivalent(ZoomBlurConfig &that) @@ -101,10 +124,10 @@ void ZoomBlurConfig::interpolate(ZoomBlurConfig &prev, ZoomBlurWindow::ZoomBlurWindow(ZoomBlurMain *plugin) : PluginClientWindow(plugin, - 230, - 370, - 230, - 370, + xS(420), + yS(230), + xS(420), + yS(230), 0) { this->plugin = plugin; @@ -116,49 +139,122 @@ ZoomBlurWindow::~ZoomBlurWindow() void ZoomBlurWindow::create_objects() { - int x = 10, y = 10; + int xs10 = xS(10), xs100 = xS(100), xs200 = xS(200); + 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 + int defaultBtn_w = xs100; + + BC_Bar *bar; + y += ys10; add_subwindow(new BC_Title(x, y, _("X:"))); - y += 20; - add_subwindow(this->x = new ZoomBlurSize(plugin, x, y, &plugin->config.x, 0, 100)); - y += 30; + x_text = new ZoomBlurIText(this, plugin, + 0, &plugin->config.x, (x + x2), y, XY_MIN, XY_MAX); + x_text->create_objects(); + x_slider = new ZoomBlurISlider(plugin, + x_text, &plugin->config.x, x3, y, XY_MIN, XY_MAX, xs200); + add_subwindow(x_slider); + x_text->slider = x_slider; + clr_x = x3 + x_slider->get_w() + x; + add_subwindow(x_Clr = new ZoomBlurClr(plugin, this, clr_x, y, RESET_XSLIDER)); + y += ys30; + add_subwindow(new BC_Title(x, y, _("Y:"))); - y += 20; - add_subwindow(this->y = new ZoomBlurSize(plugin, x, y, &plugin->config.y, 0, 100)); - y += 30; + y_text = new ZoomBlurIText(this, plugin, + 0, &plugin->config.y, (x + x2), y, XY_MIN, XY_MAX); + y_text->create_objects(); + y_slider = new ZoomBlurISlider(plugin, + y_text, &plugin->config.y, x3, y, XY_MIN, XY_MAX, xs200); + add_subwindow(y_slider); + y_text->slider = y_slider; + add_subwindow(y_Clr = new ZoomBlurClr(plugin, this, clr_x, y, RESET_YSLIDER)); + y += ys30; + add_subwindow(new BC_Title(x, y, _("Radius:"))); - y += 20; - add_subwindow(radius = new ZoomBlurSize(plugin, x, y, &plugin->config.radius, -100, 100)); - y += 30; + radius_text = new ZoomBlurIText(this, plugin, + 0, &plugin->config.radius, (x + x2), y, -RADIUS_MAX, RADIUS_MAX); + radius_text->create_objects(); + radius_slider = new ZoomBlurISlider(plugin, + radius_text, &plugin->config.radius, x3, y, -RADIUS_MAX, RADIUS_MAX, xs200); + add_subwindow(radius_slider); + radius_text->slider = radius_slider; + add_subwindow(radius_Clr = new ZoomBlurClr(plugin, this, clr_x, y, RESET_RADIUS)); + y += ys30; + add_subwindow(new BC_Title(x, y, _("Steps:"))); - y += 20; - add_subwindow(steps = new ZoomBlurSize(plugin, x, y, &plugin->config.steps, 1, 100)); - y += 30; - add_subwindow(r = new ZoomBlurToggle(plugin, x, y, &plugin->config.r, _("Red"))); - y += 30; - add_subwindow(g = new ZoomBlurToggle(plugin, x, y, &plugin->config.g, _("Green"))); - y += 30; - add_subwindow(b = new ZoomBlurToggle(plugin, x, y, &plugin->config.b, _("Blue"))); - y += 30; - add_subwindow(a = new ZoomBlurToggle(plugin, x, y, &plugin->config.a, _("Alpha"))); - y += 40; + steps_text = new ZoomBlurIText(this, plugin, + 0, &plugin->config.steps, (x + x2), y, STEPS_MIN, STEPS_MAX); + steps_text->create_objects(); + steps_slider = new ZoomBlurISlider(plugin, + steps_text, &plugin->config.steps, x3, y, STEPS_MIN, STEPS_MAX, xs200); + add_subwindow(steps_slider); + steps_text->slider = steps_slider; + add_subwindow(steps_Clr = new ZoomBlurClr(plugin, this, clr_x, y, RESET_STEPS)); + y += ys40; + + add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x)); + y += ys10; + int x1 = x; + int toggle_w = (get_w()-2*x) / 4; + add_subwindow(r = new ZoomBlurToggle(plugin, x1, y, &plugin->config.r, _("Red"))); + x1 += toggle_w; + add_subwindow(g = new ZoomBlurToggle(plugin, x1, y, &plugin->config.g, _("Green"))); + x1 += toggle_w; + add_subwindow(b = new ZoomBlurToggle(plugin, x1, y, &plugin->config.b, _("Blue"))); + x1 += toggle_w; + add_subwindow(a = new ZoomBlurToggle(plugin, x1, y, &plugin->config.a, _("Alpha"))); + y += ys30; + +// Reset section + add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x)); + y += ys10; add_subwindow(reset = new ZoomBlurReset(plugin, this, x, y)); + add_subwindow(default_settings = new ZoomBlurDefaultSettings(plugin, this, + (get_w() - xs10 - defaultBtn_w), y, defaultBtn_w)); show_window(); flush(); } // for Reset button -void ZoomBlurWindow::update() +void ZoomBlurWindow::update_gui(int clear) { - this->x->update(plugin->config.x); - this->y->update(plugin->config.x); - radius->update(plugin->config.radius); - steps->update(plugin->config.steps); - r->update(plugin->config.r); - g->update(plugin->config.g); - b->update(plugin->config.b); - a->update(plugin->config.a); + switch(clear) { + case RESET_XSLIDER : + x_text->update((int64_t)plugin->config.x); + x_slider->update(plugin->config.x); + break; + case RESET_YSLIDER : + y_text->update((int64_t)plugin->config.y); + y_slider->update(plugin->config.y); + break; + case RESET_RADIUS : + radius_text->update((int64_t)plugin->config.radius); + radius_slider->update(plugin->config.radius); + break; + case RESET_STEPS : + steps_text->update((int64_t)plugin->config.steps); + steps_slider->update(plugin->config.steps); + break; + case RESET_ALL : + case RESET_DEFAULT_SETTINGS : + default: + x_text->update((int64_t)plugin->config.x); + x_slider->update(plugin->config.x); + y_text->update((int64_t)plugin->config.y); + y_slider->update(plugin->config.y); + radius_text->update((int64_t)plugin->config.radius); + radius_slider->update(plugin->config.radius); + steps_text->update((int64_t)plugin->config.steps); + steps_slider->update(plugin->config.steps); + r->update(plugin->config.r); + g->update(plugin->config.g); + b->update(plugin->config.b); + a->update(plugin->config.a); + break; + } } @@ -189,25 +285,53 @@ int ZoomBlurToggle::handle_event() } +ZoomBlurIText::ZoomBlurIText(ZoomBlurWindow *window, ZoomBlurMain *plugin, + ZoomBlurISlider *slider, int *output, int x, int y, int min, int max) + : BC_TumbleTextBox(window, *output, + min, max, x, y, xS(60), 0) +{ + this->window = window; + this->plugin = plugin; + this->output = output; + this->slider = slider; + this->min = min; + this->max = max; + set_increment(1); +} +ZoomBlurIText::~ZoomBlurIText() +{ +} +int ZoomBlurIText::handle_event() +{ + *output = atoi(get_text()); + if(*output > max) *output = max; + if(*output < min) *output = min; + slider->update(*output); + plugin->send_configure_change(); + return 1; +} - -ZoomBlurSize::ZoomBlurSize(ZoomBlurMain *plugin, - int x, - int y, - int *output, - int min, - int max) - : BC_ISlider(x, y, 0, 200, 200, min, max, *output) +ZoomBlurISlider::ZoomBlurISlider(ZoomBlurMain *plugin, + ZoomBlurIText *text, int *output, int x, int y, int min, int max, int w) + : BC_ISlider(x, y, 0, w, w, min, max, *output) { this->plugin = plugin; this->output = output; + this->text = text; + enable_show_value(0); // Hide caption } -int ZoomBlurSize::handle_event() + +ZoomBlurISlider::~ZoomBlurISlider() +{ +} + +int ZoomBlurISlider::handle_event() { *output = get_value(); + text->update((int64_t)*output); plugin->send_configure_change(); return 1; } @@ -224,13 +348,52 @@ ZoomBlurReset::~ZoomBlurReset() } int ZoomBlurReset::handle_event() { - plugin->config.reset(); - window->update(); + plugin->config.reset(RESET_ALL); + window->update_gui(RESET_ALL); plugin->send_configure_change(); return 1; } +ZoomBlurDefaultSettings::ZoomBlurDefaultSettings(ZoomBlurMain *plugin, ZoomBlurWindow *window, int x, int y, int w) + : BC_GenericButton(x, y, w, _("Default")) +{ + this->plugin = plugin; + this->window = window; +} +ZoomBlurDefaultSettings::~ZoomBlurDefaultSettings() +{ +} +int ZoomBlurDefaultSettings::handle_event() +{ + plugin->config.reset(RESET_DEFAULT_SETTINGS); + window->update_gui(RESET_DEFAULT_SETTINGS); + plugin->send_configure_change(); + return 1; +} + + +ZoomBlurClr::ZoomBlurClr(ZoomBlurMain *plugin, ZoomBlurWindow *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; +} +ZoomBlurClr::~ZoomBlurClr() +{ +} +int ZoomBlurClr::handle_event() +{ + // clear==1 ==> X slider + // clear==2 ==> Y slider + // clear==3 ==> Radius slider + // clear==4 ==> Steps slider + plugin->config.reset(clear); + window->update_gui(clear); + plugin->send_configure_change(); + return 1; +} @@ -446,10 +609,14 @@ void ZoomBlurMain::update_gui() { load_configuration(); thread->window->lock_window(); - ((ZoomBlurWindow*)thread->window)->x->update(config.x); - ((ZoomBlurWindow*)thread->window)->y->update(config.y); - ((ZoomBlurWindow*)thread->window)->radius->update(config.radius); - ((ZoomBlurWindow*)thread->window)->steps->update(config.steps); + ((ZoomBlurWindow*)thread->window)->x_text->update((int64_t)config.x); + ((ZoomBlurWindow*)thread->window)->x_slider->update(config.x); + ((ZoomBlurWindow*)thread->window)->y_text->update((int64_t)config.y); + ((ZoomBlurWindow*)thread->window)->y_slider->update(config.y); + ((ZoomBlurWindow*)thread->window)->radius_text->update((int64_t)config.radius); + ((ZoomBlurWindow*)thread->window)->radius_slider->update(config.radius); + ((ZoomBlurWindow*)thread->window)->steps_text->update((int64_t)config.steps); + ((ZoomBlurWindow*)thread->window)->steps_slider->update(config.steps); ((ZoomBlurWindow*)thread->window)->r->update(config.r); ((ZoomBlurWindow*)thread->window)->g->update(config.g); ((ZoomBlurWindow*)thread->window)->b->update(config.b);