*
*/
-#include <math.h>
-#include <stdint.h>
-#include <string.h>
+#include "radialblur.h"
-#include "affine.h"
-#include "bcdisplayinfo.h"
-#include "clip.h"
-#include "bchash.h"
-#include "filexml.h"
-#include "keyframe.h"
-#include "language.h"
-#include "loadbalance.h"
-#include "pluginvclient.h"
-#include "vframe.h"
-class RadialBlurMain;
-class RadialBlurEngine;
-
-
-
-
-
-class RadialBlurConfig
-{
-public:
- RadialBlurConfig();
-
- int equivalent(RadialBlurConfig &that);
- void copy_from(RadialBlurConfig &that);
- void interpolate(RadialBlurConfig &prev,
- RadialBlurConfig &next,
- long prev_frame,
- long next_frame,
- long current_frame);
-
- int x;
- int y;
- int steps;
- int angle;
- int r;
- int g;
- int b;
- int a;
-};
-
-
-
-class RadialBlurSize : public BC_ISlider
-{
-public:
- RadialBlurSize(RadialBlurMain *plugin,
- int x,
- int y,
- int *output,
- int min,
- int max);
- int handle_event();
- RadialBlurMain *plugin;
- int *output;
-};
-
-class RadialBlurToggle : public BC_CheckBox
-{
-public:
- RadialBlurToggle(RadialBlurMain *plugin,
- int x,
- int y,
- int *output,
- char *string);
- int handle_event();
- RadialBlurMain *plugin;
- int *output;
-};
-
-class RadialBlurWindow : public PluginClientWindow
-{
-public:
- RadialBlurWindow(RadialBlurMain *plugin);
- ~RadialBlurWindow();
-
- void create_objects();
-
-
- RadialBlurSize *x, *y, *steps, *angle;
- RadialBlurToggle *r, *g, *b, *a;
- RadialBlurMain *plugin;
-};
-
-
-
-
-
-
-class RadialBlurMain : public PluginVClient
-{
-public:
- RadialBlurMain(PluginServer *server);
- ~RadialBlurMain();
-
- int process_buffer(VFrame *frame,
- int64_t start_position,
- double frame_rate);
- int is_realtime();
- void save_data(KeyFrame *keyframe);
- void read_data(KeyFrame *keyframe);
- void update_gui();
- int handle_opengl();
-
- PLUGIN_CLASS_MEMBERS(RadialBlurConfig)
+REGISTER_PLUGIN(RadialBlurMain)
- VFrame *input, *output, *temp;
- RadialBlurEngine *engine;
-// Rotate engine only used for OpenGL
- AffineEngine *rotate;
-};
-class RadialBlurPackage : public LoadPackage
-{
-public:
- RadialBlurPackage();
- int y1, y2;
-};
-class RadialBlurUnit : public LoadClient
-{
-public:
- RadialBlurUnit(RadialBlurEngine *server, RadialBlurMain *plugin);
- void process_package(LoadPackage *package);
- RadialBlurEngine *server;
- RadialBlurMain *plugin;
-};
-
-class RadialBlurEngine : public LoadServer
+RadialBlurConfig::RadialBlurConfig()
{
-public:
- RadialBlurEngine(RadialBlurMain *plugin,
- int total_clients,
- int total_packages);
- void init_packages();
- LoadClient* new_client();
- LoadPackage* new_package();
- RadialBlurMain *plugin;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-REGISTER_PLUGIN(RadialBlurMain)
-
+ reset(RESET_DEFAULT_SETTINGS);
+}
-RadialBlurConfig::RadialBlurConfig()
+void RadialBlurConfig::reset(int clear)
{
- x = 50;
- y = 50;
- steps = 10;
- angle = 33;
- r = 1;
- g = 1;
- b = 1;
- a = 1;
+ switch(clear) {
+ case RESET_ALL :
+ x = 50;
+ y = 50;
+ angle = 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_ANGLE : angle = 0;
+ break;
+ case RESET_STEPS : steps = 1;
+ break;
+ case RESET_DEFAULT_SETTINGS :
+ default:
+ x = 50;
+ y = 50;
+ angle = 33;
+ steps = 10;
+ r = 1;
+ g = 1;
+ b = 1;
+ a = 1;
+ break;
+ }
}
int RadialBlurConfig::equivalent(RadialBlurConfig &that)
RadialBlurWindow::RadialBlurWindow(RadialBlurMain *plugin)
: PluginClientWindow(plugin,
- 230,
- 340,
- 230,
- 340,
+ xS(420),
+ yS(230),
+ xS(420),
+ yS(230),
0)
{
this->plugin = plugin;
void RadialBlurWindow::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 RadialBlurSize(plugin, x, y, &plugin->config.x, 0, 100));
- y += 30;
+ x_text = new RadialBlurIText(this, plugin,
+ 0, &plugin->config.x, (x + x2), y, XY_MIN, XY_MAX);
+ x_text->create_objects();
+ x_slider = new RadialBlurISlider(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 RadialBlurClr(plugin, this, clr_x, y, RESET_XSLIDER));
+ y += ys30;
+
add_subwindow(new BC_Title(x, y, _("Y:")));
- y += 20;
- add_subwindow(this->y = new RadialBlurSize(plugin, x, y, &plugin->config.y, 0, 100));
- y += 30;
+ y_text = new RadialBlurIText(this, plugin,
+ 0, &plugin->config.y, (x + x2), y, XY_MIN, XY_MAX);
+ y_text->create_objects();
+ y_slider = new RadialBlurISlider(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 RadialBlurClr(plugin, this, clr_x, y, RESET_YSLIDER));
+ y += ys30;
+
add_subwindow(new BC_Title(x, y, _("Angle:")));
- y += 20;
- add_subwindow(angle = new RadialBlurSize(plugin, x, y, &plugin->config.angle, 0, 360));
- y += 30;
+ angle_text = new RadialBlurIText(this, plugin,
+ 0, &plugin->config.angle, (x + x2), y, ANGLE_MIN, ANGLE_MAX);
+ angle_text->create_objects();
+ angle_slider = new RadialBlurISlider(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 RadialBlurClr(plugin, this, clr_x, y, RESET_ANGLE));
+ y += ys30;
+
add_subwindow(new BC_Title(x, y, _("Steps:")));
- y += 20;
- add_subwindow(steps = new RadialBlurSize(plugin, x, y, &plugin->config.steps, 1, 100));
- y += 30;
- add_subwindow(r = new RadialBlurToggle(plugin, x, y, &plugin->config.r, _("Red")));
- y += 30;
- add_subwindow(g = new RadialBlurToggle(plugin, x, y, &plugin->config.g, _("Green")));
- y += 30;
- add_subwindow(b = new RadialBlurToggle(plugin, x, y, &plugin->config.b, _("Blue")));
- y += 30;
- add_subwindow(a = new RadialBlurToggle(plugin, x, y, &plugin->config.a, _("Alpha")));
- y += 30;
+ steps_text = new RadialBlurIText(this, plugin,
+ 0, &plugin->config.steps, (x + x2), y, STEPS_MIN, STEPS_MAX);
+ steps_text->create_objects();
+ steps_slider = new RadialBlurISlider(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 RadialBlurClr(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 RadialBlurToggle(plugin, x1, y, &plugin->config.r, _("Red")));
+ x1 += toggle_w;
+ add_subwindow(g = new RadialBlurToggle(plugin, x1, y, &plugin->config.g, _("Green")));
+ x1 += toggle_w;
+ add_subwindow(b = new RadialBlurToggle(plugin, x1, y, &plugin->config.b, _("Blue")));
+ x1 += toggle_w;
+ add_subwindow(a = new RadialBlurToggle(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 RadialBlurReset(plugin, this, x, y));
+ add_subwindow(default_settings = new RadialBlurDefaultSettings(plugin, this,
+ (get_w() - xs10 - defaultBtn_w), y, defaultBtn_w));
show_window();
flush();
}
-
+// for Reset button
+void RadialBlurWindow::update_gui(int clear)
+{
+ 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_ANGLE :
+ angle_text->update((int64_t)plugin->config.angle);
+ angle_slider->update(plugin->config.angle);
+ 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);
+ angle_text->update((int64_t)plugin->config.angle);
+ angle_slider->update(plugin->config.angle);
+ 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;
+ }
+}
}
+RadialBlurIText::RadialBlurIText(RadialBlurWindow *gui, RadialBlurMain *plugin,
+ RadialBlurISlider *slider, int *output, int x, int y, int min, int max)
+ : BC_TumbleTextBox(gui, *output,
+ min, max, x, y, xS(60), 0)
+{
+ this->gui = gui;
+ this->plugin = plugin;
+ this->output = output;
+ this->slider = slider;
+ this->min = min;
+ this->max = max;
+ set_increment(1);
+}
+RadialBlurIText::~RadialBlurIText()
+{
+}
+int RadialBlurIText::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;
+}
-
-RadialBlurSize::RadialBlurSize(RadialBlurMain *plugin,
- int x,
- int y,
- int *output,
- int min,
- int max)
- : BC_ISlider(x, y, 0, 200, 200, min, max, *output)
+RadialBlurISlider::RadialBlurISlider(RadialBlurMain *plugin,
+ RadialBlurIText *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
+}
+
+RadialBlurISlider::~RadialBlurISlider()
+{
}
-int RadialBlurSize::handle_event()
+
+int RadialBlurISlider::handle_event()
{
*output = get_value();
+ text->update((int64_t)*output);
plugin->send_configure_change();
return 1;
}
+RadialBlurReset::RadialBlurReset(RadialBlurMain *plugin, RadialBlurWindow *gui, int x, int y)
+ : BC_GenericButton(x, y, _("Reset"))
+{
+ this->plugin = plugin;
+ this->gui = gui;
+}
+RadialBlurReset::~RadialBlurReset()
+{
+}
+int RadialBlurReset::handle_event()
+{
+ plugin->config.reset(RESET_ALL);
+ gui->update_gui(RESET_ALL);
+ plugin->send_configure_change();
+ return 1;
+}
+RadialBlurDefaultSettings::RadialBlurDefaultSettings(RadialBlurMain *plugin, RadialBlurWindow *gui, int x, int y, int w)
+ : BC_GenericButton(x, y, w, _("Default"))
+{
+ this->plugin = plugin;
+ this->gui = gui;
+}
+RadialBlurDefaultSettings::~RadialBlurDefaultSettings()
+{
+}
+int RadialBlurDefaultSettings::handle_event()
+{
+ plugin->config.reset(RESET_DEFAULT_SETTINGS);
+ gui->update_gui(RESET_DEFAULT_SETTINGS);
+ plugin->send_configure_change();
+ return 1;
+}
+RadialBlurClr::RadialBlurClr(RadialBlurMain *plugin, RadialBlurWindow *gui, int x, int y, int clear)
+ : BC_Button(x, y, plugin->get_theme()->get_image_set("reset_button"))
+{
+ this->plugin = plugin;
+ this->gui = gui;
+ this->clear = clear;
+}
+RadialBlurClr::~RadialBlurClr()
+{
+}
+int RadialBlurClr::handle_event()
+{
+ // clear==1 ==> X slider
+ // clear==2 ==> Y slider
+ // clear==3 ==> Angle slider
+ // clear==4 ==> Steps slider
+ plugin->config.reset(clear);
+ gui->update_gui(clear);
+ plugin->send_configure_change();
+ return 1;
+}
{
load_configuration();
thread->window->lock_window();
- ((RadialBlurWindow*)thread->window)->x->update(config.x);
- ((RadialBlurWindow*)thread->window)->y->update(config.y);
- ((RadialBlurWindow*)thread->window)->angle->update(config.angle);
- ((RadialBlurWindow*)thread->window)->steps->update(config.steps);
+ ((RadialBlurWindow*)thread->window)->x_text->update((int64_t)config.x);
+ ((RadialBlurWindow*)thread->window)->x_slider->update(config.x);
+ ((RadialBlurWindow*)thread->window)->y_text->update((int64_t)config.y);
+ ((RadialBlurWindow*)thread->window)->y_slider->update(config.y);
+ ((RadialBlurWindow*)thread->window)->angle_text->update((int64_t)config.angle);
+ ((RadialBlurWindow*)thread->window)->angle_slider->update(config.angle);
+ ((RadialBlurWindow*)thread->window)->steps_text->update((int64_t)config.steps);
+ ((RadialBlurWindow*)thread->window)->steps_slider->update(config.steps);
+
((RadialBlurWindow*)thread->window)->r->update(config.r);
((RadialBlurWindow*)thread->window)->g->update(config.g);
((RadialBlurWindow*)thread->window)->b->update(config.b);