X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fpolar%2Fpolar.C;h=25da0ea77b3dc7e7e7f8a548a4ebee45e35b0149;hb=HEAD;hp=cfae601ada8b49e07e51c9f5994f2e94b87e10fb;hpb=e375434717622cc3198a6bf9f7b7fb9fde555c21;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/polar/polar.C b/cinelerra-5.1/plugins/polar/polar.C index cfae601a..25da0ea7 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,11 +39,23 @@ #define WITHIN(a, b, c) ((((a) <= (b)) && ((b) <= (c))) ? 1 : 0) +#define RESET_ALL 0 +#define RESET_DEPTH 1 +#define RESET_ANGLE 2 + +#define DEPTH_MIN 1.00 +#define DEPTH_MAX 100.00 +#define ANGLE_MIN 1.00 +#define ANGLE_MAX 360.00 + class PolarEffect; class PolarEngine; class PolarWindow; +class PolarFText; +class PolarFSlider; class PolarReset; +class PolarClr; class PolarConfig @@ -50,7 +63,7 @@ class PolarConfig public: PolarConfig(); - void reset(); + void reset(int clear); void copy_from(PolarConfig &src); int equivalent(PolarConfig &src); void interpolate(PolarConfig &prev, @@ -68,22 +81,34 @@ public: -class PolarDepth : public BC_FSlider +class PolarFText : public BC_TumbleTextBox { public: - PolarDepth(PolarEffect *plugin, int x, int y); + PolarFText(PolarWindow *window, PolarEffect *plugin, + PolarFSlider *slider, float *output, int x, int y, float min, float max); + ~PolarFText(); int handle_event(); + PolarWindow *window; PolarEffect *plugin; + PolarFSlider *slider; + float *output; + float min, max; }; -class PolarAngle : public BC_FSlider +class PolarFSlider : public BC_FSlider { public: - PolarAngle(PolarEffect *plugin, int x, int y); + PolarFSlider(PolarEffect *plugin, + PolarFText *text, float *output, int x, int y, + float min, float max, int w); + ~PolarFSlider(); int handle_event(); PolarEffect *plugin; + PolarFText *text; + float *output; }; + class PolarReset : public BC_GenericButton { public: @@ -94,15 +119,33 @@ public: PolarWindow *window; }; +class PolarClr : public BC_Button +{ +public: + PolarClr(PolarEffect *plugin, PolarWindow *window, int x, int y, int clear); + ~PolarClr(); + int handle_event(); + PolarEffect *plugin; + PolarWindow *window; + int clear; +}; + class PolarWindow : public PluginClientWindow { public: PolarWindow(PolarEffect *plugin); void create_objects(); - void update(); + void update_gui(int clear); PolarEffect *plugin; - PolarDepth *depth; - PolarAngle *angle; + + PolarFText *depth_text; + PolarFSlider *depth_slider; + PolarClr *depth_Clr; + + PolarFText *angle_text; + PolarFSlider *angle_slider; + PolarClr *angle_Clr; + PolarReset *reset; }; @@ -162,16 +205,25 @@ REGISTER_PLUGIN(PolarEffect) PolarConfig::PolarConfig() { - reset(); + reset(RESET_ALL); } -void PolarConfig::reset() +void PolarConfig::reset(int clear) { - angle = 1.0; // 0.0; - depth = 1.0; // 0.0; - backwards = 0; - invert = 0; - polar_to_rectangular = 1; + 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) @@ -208,10 +260,10 @@ void PolarConfig::interpolate(PolarConfig &prev, PolarWindow::PolarWindow(PolarEffect *plugin) : PluginClientWindow(plugin, - 270, - 122, - 270, - 122, + xS(420), + yS(130), + xS(420), + yS(130), 0) { this->plugin = plugin; @@ -219,13 +271,41 @@ PolarWindow::PolarWindow(PolarEffect *plugin) void PolarWindow::create_objects() { - int x = 10, y = 10; + int xs10 = xS(10), 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 + + BC_Bar *bar; + + y += ys10; add_subwindow(new BC_Title(x, y, _("Depth:"))); - add_subwindow(depth = new PolarDepth(plugin, x + 50, y)); - y += 40; + depth_text = new PolarFText(this, plugin, + 0, &plugin->config.depth, (x + x2), y, DEPTH_MIN, DEPTH_MAX); + depth_text->create_objects(); + depth_slider = new PolarFSlider(plugin, + depth_text, &plugin->config.depth, x3, y, DEPTH_MIN, DEPTH_MAX, xs200); + add_subwindow(depth_slider); + depth_text->slider = depth_slider; + clr_x = x3 + depth_slider->get_w() + x; + add_subwindow(depth_Clr = new PolarClr(plugin, this, clr_x, y, RESET_DEPTH)); + y += ys30; + add_subwindow(new BC_Title(x, y, _("Angle:"))); - add_subwindow(angle = new PolarAngle(plugin, x + 50, y)); - y += 40; + angle_text = new PolarFText(this, plugin, + 0, &plugin->config.angle, (x + x2), y, ANGLE_MIN, ANGLE_MAX); + angle_text->create_objects(); + angle_slider = new PolarFSlider(plugin, + angle_text, &plugin->config.angle, x3, y, ANGLE_MIN, ANGLE_MAX, xs200); + add_subwindow(angle_slider); + angle_text->slider = angle_slider; + add_subwindow(angle_Clr = new PolarClr(plugin, this, clr_x, y, RESET_ANGLE)); + y += ys40; + +// Reset section + add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x)); + y += ys10; add_subwindow(reset = new PolarReset(plugin, this, x, y)); show_window(); @@ -233,60 +313,83 @@ void PolarWindow::create_objects() } // for Reset button -void PolarWindow::update() +void PolarWindow::update_gui(int clear) { - depth->update(plugin->config.depth); - angle->update(plugin->config.angle); + switch(clear) { + case RESET_DEPTH : + depth_text->update(plugin->config.depth); + depth_slider->update(plugin->config.depth); + break; + case RESET_ANGLE : + angle_text->update(plugin->config.angle); + angle_slider->update(plugin->config.angle); + break; + case RESET_ALL : + default: + depth_text->update(plugin->config.depth); + depth_slider->update(plugin->config.depth); + angle_text->update(plugin->config.angle); + angle_slider->update(plugin->config.angle); + break; + } } -PolarDepth::PolarDepth(PolarEffect *plugin, int x, int y) - : BC_FSlider(x, - y, - 0, - 200, - 200, - (float)1, - (float)100, - plugin->config.depth) +PolarFText::PolarFText(PolarWindow *window, PolarEffect *plugin, + PolarFSlider *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); } -int PolarDepth::handle_event() + +PolarFText::~PolarFText() { - plugin->config.depth = get_value(); +} + +int PolarFText::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; } - - - -PolarAngle::PolarAngle(PolarEffect *plugin, int x, int y) - : BC_FSlider(x, - y, - 0, - 200, - 200, - (float)1, - (float)360, - plugin->config.angle) +PolarFSlider::PolarFSlider(PolarEffect *plugin, + PolarFText *text, float *output, int x, int y, float min, float max, int w) + : BC_FSlider(x, y, 0, w, w, min, max, *output) { this->plugin = plugin; + this->output = output; + this->text = text; + enable_show_value(0); // Hide caption +} + +PolarFSlider::~PolarFSlider() +{ } -int PolarAngle::handle_event() + +int PolarFSlider::handle_event() { - plugin->config.angle = get_value(); + *output = get_value(); + text->update(*output); plugin->send_configure_change(); return 1; } - PolarReset::PolarReset(PolarEffect *plugin, PolarWindow *window, int x, int y) : BC_GenericButton(x, y, _("Reset")) { @@ -298,8 +401,29 @@ PolarReset::~PolarReset() } int PolarReset::handle_event() { - plugin->config.reset(); - window->update(); + plugin->config.reset(RESET_ALL); + window->update_gui(RESET_ALL); + plugin->send_configure_change(); + return 1; +} + + +PolarClr::PolarClr(PolarEffect *plugin, PolarWindow *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; +} +PolarClr::~PolarClr() +{ +} +int PolarClr::handle_event() +{ + // clear==1 ==> Depth slider + // clear==2 ==> Angle slider + plugin->config.reset(clear); + window->update_gui(clear); plugin->send_configure_change(); return 1; } @@ -339,8 +463,10 @@ void PolarEffect::update_gui() { load_configuration(); thread->window->lock_window(); - ((PolarWindow*)thread->window)->angle->update(config.angle); - ((PolarWindow*)thread->window)->depth->update(config.depth); + ((PolarWindow*)thread->window)->angle_text->update(config.angle); + ((PolarWindow*)thread->window)->angle_slider->update(config.angle); + ((PolarWindow*)thread->window)->depth_text->update(config.depth); + ((PolarWindow*)thread->window)->depth_slider->update(config.depth); thread->window->unlock_window(); } }