X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fpolar%2Fpolar.C;h=417afc71d0c71f7f6c9f23dba9a27e82502f4b4d;hb=53f919f88484c8611457fbcd552f6931218cc219;hp=08933b59bf7c052ac5e8a4171c3eb2de5556eef9;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/polar/polar.C b/cinelerra-5.1/plugins/polar/polar.C index 08933b59..417afc71 100644 --- a/cinelerra-5.1/plugins/polar/polar.C +++ b/cinelerra-5.1/plugins/polar/polar.C @@ -28,6 +28,7 @@ #include "language.h" #include "loadbalance.h" #include "pluginvclient.h" +#include "theme.h" #include "vframe.h" @@ -38,10 +39,15 @@ #define WITHIN(a, b, c) ((((a) <= (b)) && ((b) <= (c))) ? 1 : 0) +#define RESET_ALL 0 +#define RESET_DEPTH 1 +#define RESET_ANGLE 2 class PolarEffect; class PolarEngine; class PolarWindow; +class PolarReset; +class PolarSliderClr; class PolarConfig @@ -49,6 +55,7 @@ class PolarConfig public: PolarConfig(); + void reset(int clear); void copy_from(PolarConfig &src); int equivalent(PolarConfig &src); void interpolate(PolarConfig &prev, @@ -82,14 +89,39 @@ public: PolarEffect *plugin; }; +class PolarReset : public BC_GenericButton +{ +public: + PolarReset(PolarEffect *plugin, PolarWindow *window, int x, int y); + ~PolarReset(); + int handle_event(); + PolarEffect *plugin; + PolarWindow *window; +}; + +class PolarSliderClr : public BC_Button +{ +public: + PolarSliderClr(PolarEffect *plugin, PolarWindow *window, int x, int y, int w, int clear); + ~PolarSliderClr(); + int handle_event(); + PolarEffect *plugin; + PolarWindow *window; + int clear; +}; + class PolarWindow : public PluginClientWindow { public: PolarWindow(PolarEffect *plugin); void create_objects(); + void update_gui(int clear); PolarEffect *plugin; PolarDepth *depth; PolarAngle *angle; + PolarReset *reset; + PolarSliderClr *depthClr; + PolarSliderClr *angleClr; }; @@ -148,13 +180,26 @@ REGISTER_PLUGIN(PolarEffect) PolarConfig::PolarConfig() { - angle = 0.0; - depth = 0.0; - backwards = 0; - invert = 0; - polar_to_rectangular = 1; + reset(RESET_ALL); } +void PolarConfig::reset(int clear) +{ + switch(clear) { + case RESET_DEPTH : depth = 1.0; + break; + case RESET_ANGLE : angle = 1.0; + break; + case RESET_ALL : + default: + angle = 1.0; + depth = 1.0; + backwards = 0; + invert = 0; + polar_to_rectangular = 1; + break; + } +} void PolarConfig::copy_from(PolarConfig &src) { @@ -190,10 +235,10 @@ void PolarConfig::interpolate(PolarConfig &prev, PolarWindow::PolarWindow(PolarEffect *plugin) : PluginClientWindow(plugin, - 270, - 100, - 270, - 100, + xS(330), + yS(122), + xS(330), + yS(122), 0) { this->plugin = plugin; @@ -201,18 +246,42 @@ PolarWindow::PolarWindow(PolarEffect *plugin) void PolarWindow::create_objects() { - int x = 10, y = 10; + int xs10 = xS(10), xs50 = xS(50); + int ys10 = yS(10), ys40 = yS(40); + int x = xs10, y = ys10, x1 = x + xs50; + int x2 = 0; int clrBtn_w = xs50; + add_subwindow(new BC_Title(x, y, _("Depth:"))); - add_subwindow(depth = new PolarDepth(plugin, x + 50, y)); - y += 40; + add_subwindow(depth = new PolarDepth(plugin, x1, y)); + x2 = x1 + depth->get_w() + xs10; + add_subwindow(depthClr = new PolarSliderClr(plugin, this, x2, y, clrBtn_w, RESET_DEPTH)); + + y += ys40; add_subwindow(new BC_Title(x, y, _("Angle:"))); - add_subwindow(angle = new PolarAngle(plugin, x + 50, y)); + add_subwindow(angle = new PolarAngle(plugin, x1, y)); + add_subwindow(angleClr = new PolarSliderClr(plugin, this, x2, y, clrBtn_w, RESET_ANGLE)); + y += ys40; + add_subwindow(reset = new PolarReset(plugin, this, x, y)); show_window(); flush(); } - +// for Reset button +void PolarWindow::update_gui(int clear) +{ + switch(clear) { + case RESET_DEPTH : depth->update(plugin->config.depth); + break; + case RESET_ANGLE : angle->update(plugin->config.angle); + break; + case RESET_ALL : + default: + depth->update(plugin->config.depth); + angle->update(plugin->config.angle); + break; + } +} @@ -222,8 +291,8 @@ PolarDepth::PolarDepth(PolarEffect *plugin, int x, int y) : BC_FSlider(x, y, 0, - 200, - 200, + xS(200), + yS(200), (float)1, (float)100, plugin->config.depth) @@ -245,8 +314,8 @@ PolarAngle::PolarAngle(PolarEffect *plugin, int x, int y) : BC_FSlider(x, y, 0, - 200, - 200, + xS(200), + yS(200), (float)1, (float)360, plugin->config.angle) @@ -262,6 +331,45 @@ int PolarAngle::handle_event() +PolarReset::PolarReset(PolarEffect *plugin, PolarWindow *window, int x, int y) + : BC_GenericButton(x, y, _("Reset")) +{ + this->plugin = plugin; + this->window = window; +} +PolarReset::~PolarReset() +{ +} +int PolarReset::handle_event() +{ + plugin->config.reset(RESET_ALL); + window->update_gui(RESET_ALL); + plugin->send_configure_change(); + return 1; +} + + +PolarSliderClr::PolarSliderClr(PolarEffect *plugin, PolarWindow *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; +} +PolarSliderClr::~PolarSliderClr() +{ +} +int PolarSliderClr::handle_event() +{ + // clear==1 ==> Depth slider + // clear==2 ==> Angle slider + plugin->config.reset(clear); + window->update_gui(clear); + plugin->send_configure_change(); + return 1; +} + + PolarEffect::PolarEffect(PluginServer *server)