X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fboxblur%2Fboxblur.C;h=7c8fb1e96f5fc531c761d0699764c545bc5754e2;hp=6646bc16e32927762eee78788b4bd80579ad041c;hb=fbdd13b462256ed4f3b35dc114385fe0b0de0dcd;hpb=6fad9caf0395455570ac0d87f31faf022204d852 diff --git a/cinelerra-5.1/plugins/boxblur/boxblur.C b/cinelerra-5.1/plugins/boxblur/boxblur.C index 6646bc16..7c8fb1e9 100644 --- a/cinelerra-5.1/plugins/boxblur/boxblur.C +++ b/cinelerra-5.1/plugins/boxblur/boxblur.C @@ -62,6 +62,7 @@ public: void interpolate(BoxBlurConfig &prev, BoxBlurConfig &next, int64_t prev_frame, int64_t next_frame, int64_t current_frame); void reset(); + void preset(); int horz_radius, vert_radius, power; float box_x, box_y; @@ -186,6 +187,16 @@ public: BoxBlurWindow *gui; }; +class BoxBlurPreset : public BC_GenericButton +{ +public: + BoxBlurPreset(BoxBlurWindow *gui, int x, int y); + int handle_event(); + static int calculate_w(BoxBlurWindow *gui); + + BoxBlurWindow *gui; +}; + class BoxBlurWindow : public PluginClientWindow { public: @@ -197,6 +208,7 @@ public: BoxBlurEffect *plugin; BoxBlurReset *reset; + BoxBlurPreset *preset; BoxBlurRadius *blur_horz; BoxBlurRadius *blur_vert; BoxBlurPower *blur_power; @@ -228,6 +240,16 @@ public: void BoxBlurConfig::reset() +{ + horz_radius = 0; + vert_radius = 0; + power = 1; + drag = 0; + box_x = box_y = 0.0; + box_w = box_h = 0; +} + +void BoxBlurConfig::preset() { horz_radius = 2; vert_radius = 2; @@ -237,9 +259,10 @@ void BoxBlurConfig::reset() box_w = box_h = 0; } + BoxBlurConfig::BoxBlurConfig() { - reset(); + preset(); } void BoxBlurConfig::copy_from(BoxBlurConfig &that) @@ -268,12 +291,12 @@ void BoxBlurConfig::interpolate(BoxBlurConfig &prev, BoxBlurConfig &next, double v = 1. - u; this->horz_radius = u*prev.horz_radius + v*next.horz_radius; this->vert_radius = u*prev.vert_radius + v*next.vert_radius; - this->power = u*prev.power + v*next.power; + this->power = u*prev.power + v*next.power + 1e-6; // avoid truncation jitter this->drag = prev.drag; this->box_x = u*prev.box_x + v*next.box_x; this->box_y = u*prev.box_y + v*next.box_y; - this->box_w = u*prev.box_w + v*next.box_w; - this->box_h = u*prev.box_h + v*next.box_h; + this->box_w = u*prev.box_w + v*next.box_w + 1e-6; + this->box_h = u*prev.box_h + v*next.box_h + 1e-6; } @@ -291,6 +314,7 @@ int BoxBlurNumISlider::handle_event() { int iv = get_value(); num->update(iv); + num->gui->update_drag(); return 1; } @@ -305,6 +329,7 @@ int BoxBlurNumIText::handle_event() { int iv = atoi(get_text()); num->update(iv); + num->gui->update_drag(); return 1; } @@ -324,6 +349,7 @@ int BoxBlurNumClear::handle_event() { int v = num->imn; num->update(v); + num->gui->update_drag(); return 1; } @@ -379,7 +405,6 @@ void BoxBlurNum::update(int value) text->update((int64_t)value); slider->update(value); *ivalue = value; - gui->update_drag(); } @@ -396,7 +421,7 @@ BoxBlurPower::BoxBlurPower(BoxBlurWindow *gui, int x, int y, int w, } BoxBlurWindow::BoxBlurWindow(BoxBlurEffect *plugin) - : PluginClientWindow(plugin, xS(360), yS(240), xS(360), yS(240), 0) + : PluginClientWindow(plugin, xS(360), yS(260), xS(360), yS(260), 0) { this->plugin = plugin; blur_horz = 0; @@ -420,53 +445,58 @@ BoxBlurWindow::~BoxBlurWindow() void BoxBlurWindow::create_objects() { int x = xS(10), y = yS(10); + int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(40); int t1 = x, t2 = t1+xS(24), t3 = t2+xS(100), t4 = t3+xS(24); int ww = get_w() - 2*x, bar_o = xS(30), bar_m = xS(15); int margin = plugin->get_theme()->widget_border; - BC_Title *title; - add_subwindow(title = new BC_Title(x, y, _("Box Blur"), MEDIUMFONT_3D)); - int x1 = ww - BoxBlurReset::calculate_w(this) - margin; - add_subwindow(reset = new BoxBlurReset(this, x1, y)); - y += bmax(title->get_h(), reset->get_h()) + 2*margin; - BC_TitleBar *tbar; - add_subwindow(tbar = new BC_TitleBar(x, y, ww, bar_o, bar_m, _("Position"))); - y += tbar->get_h() + margin; - x1 = ww - BoxBlurDrag::calculate_w(this) - margin; + BC_TitleBar *tbar; + add_subwindow(tbar = new BC_TitleBar(x, y, ww, bar_o, bar_m, _("Position & Size"))); + y += ys20; + int x1 = ww - BoxBlurDrag::calculate_w(this) - margin; add_subwindow(drag = new BoxBlurDrag(this, plugin, x1, y)); drag->create_objects(); if( plugin->config.drag && drag->drag_activate() ) eprintf("drag enabled, but compositor already grabbed\n"); + BC_Title *title; add_subwindow(title = new BC_Title(t1, y, _("X:"))); box_x = new BoxBlurX(this, t2, y); box_x->create_objects(); add_subwindow(title = new BC_Title(t3, y, _("W:"))); box_w = new BoxBlurW(this, t4, y); box_w->create_objects(); - y += bmax(title->get_h(), box_w->get_h()) + margin; + y += ys30; add_subwindow(title = new BC_Title(t1, y, _("Y:"))); box_y = new BoxBlurY(this, t2, y); box_y->create_objects(); add_subwindow(title = new BC_Title(t3, y, _("H:"))); box_h = new BoxBlurH(this, t4, y); box_h->create_objects(); - y += bmax(title->get_h(), box_h->get_h()) + 2*margin; + y += ys40; add_subwindow(tbar = new BC_TitleBar(x, y, ww, bar_o, bar_m, _("Blur"))); - y += tbar->get_h() + margin; + y += ys20; blur_horz = new BoxBlurRadius(this, x, y, ww, _("Horz:"), &plugin->config.horz_radius); blur_horz->create_objects(); - y += blur_horz->get_h() + margin; + y += ys30; blur_vert = new BoxBlurRadius(this, x, y, ww, _("Vert:"), &plugin->config.vert_radius); blur_vert->create_objects(); - y += blur_vert->get_h() + margin; + y += ys30; blur_power = new BoxBlurPower(this, x, y, ww, _("Power:"), &plugin->config.power); blur_power->create_objects(); - y += blur_power->get_h() + margin; + y += ys40; + BC_Bar *bar; + add_subwindow(bar = new BC_Bar(x, y, ww)); + y += ys10; + + add_subwindow(reset = new BoxBlurReset(this, x, y)); + x1 = x + ww - BoxBlurPreset::calculate_w(this); + add_subwindow(preset = new BoxBlurPreset(this, x1, y)); + y += bmax(title->get_h(), reset->get_h()) + 2*margin; show_window(1); } @@ -731,3 +761,25 @@ int BoxBlurReset::handle_event() return 1; } +BoxBlurPreset::BoxBlurPreset(BoxBlurWindow *gui, int x, int y) + : BC_GenericButton(x, y, _("Default")) +{ + this->gui = gui; +} + +int BoxBlurPreset::calculate_w(BoxBlurWindow *gui) +{ + return BC_GenericButton::calculate_w(gui,_("Default")); +} + +int BoxBlurPreset::handle_event() +{ + BoxBlurEffect *plugin = gui->plugin; + plugin->config.preset(); + gui->drag->update(0); + gui->drag->drag_deactivate(); + gui->update_gui(); + gui->update_drag(); + return 1; +} +