#include "language.h"
#include "loadbalance.h"
#include "pluginvclient.h"
+#include "theme.h"
#include "vframe.h"
#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
public:
PolarConfig();
+ void reset(int clear);
void copy_from(PolarConfig &src);
int equivalent(PolarConfig &src);
void interpolate(PolarConfig &prev,
-class PolarDepth : public BC_FSlider
+class PolarFText : public BC_TumbleTextBox
+{
+public:
+ 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 PolarFSlider : public BC_FSlider
+{
+public:
+ 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:
- PolarDepth(PolarEffect *plugin, int x, int y);
+ PolarReset(PolarEffect *plugin, PolarWindow *window, int x, int y);
+ ~PolarReset();
int handle_event();
PolarEffect *plugin;
+ PolarWindow *window;
};
-class PolarAngle : public BC_FSlider
+class PolarClr : public BC_Button
{
public:
- PolarAngle(PolarEffect *plugin, int x, int y);
+ 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_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;
};
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)
{
PolarWindow::PolarWindow(PolarEffect *plugin)
: PluginClientWindow(plugin,
- 270,
- 100,
- 270,
- 100,
+ xS(420),
+ yS(130),
+ xS(420),
+ yS(130),
0)
{
this->plugin = 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));
+ 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();
flush();
}
+// for Reset button
+void PolarWindow::update_gui(int clear)
+{
+ 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()
+{
+}
+
+int PolarFText::handle_event()
{
- plugin->config.depth = get_value();
+ *output = atof(get_text());
+ if(*output > max) *output = max;
+ if(*output < min) *output = min;
+ slider->update(*output);
plugin->send_configure_change();
return 1;
}
+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 PolarFSlider::handle_event()
+{
+ *output = get_value();
+ text->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)
+
+PolarReset::PolarReset(PolarEffect *plugin, PolarWindow *window, int x, int y)
+ : BC_GenericButton(x, y, _("Reset"))
{
this->plugin = plugin;
+ this->window = window;
+}
+PolarReset::~PolarReset()
+{
}
-int PolarAngle::handle_event()
+int PolarReset::handle_event()
{
- plugin->config.angle = get_value();
+ 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;
+}
+
{
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();
}
}