*
*/
-#include <math.h>
-#include <stdint.h>
-#include <string.h>
-
-#include "bcdisplayinfo.h"
-#include "bcsignals.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 ZoomBlurMain;
-class ZoomBlurEngine;
-
-
-
-
-
-class ZoomBlurConfig
-{
-public:
- ZoomBlurConfig();
-
- int equivalent(ZoomBlurConfig &that);
- void copy_from(ZoomBlurConfig &that);
- void interpolate(ZoomBlurConfig &prev,
- ZoomBlurConfig &next,
- long prev_frame,
- long next_frame,
- long current_frame);
-
- int x;
- int y;
- int radius;
- int steps;
- int r;
- int g;
- int b;
- int a;
-};
-
-
-
-class ZoomBlurSize : public BC_ISlider
-{
-public:
- ZoomBlurSize(ZoomBlurMain *plugin,
- int x,
- int y,
- int *output,
- int min,
- int max);
- int handle_event();
- ZoomBlurMain *plugin;
- int *output;
-};
-
-class ZoomBlurToggle : public BC_CheckBox
-{
-public:
- ZoomBlurToggle(ZoomBlurMain *plugin,
- int x,
- int y,
- int *output,
- char *string);
- int handle_event();
- ZoomBlurMain *plugin;
- int *output;
-};
-
-class ZoomBlurWindow : public PluginClientWindow
-{
-public:
- ZoomBlurWindow(ZoomBlurMain *plugin);
- ~ZoomBlurWindow();
-
- void create_objects();
-
- ZoomBlurSize *x, *y, *radius, *steps;
- ZoomBlurToggle *r, *g, *b, *a;
- ZoomBlurMain *plugin;
-};
-
-
-
-
-
-// Output coords for a layer of blurring
-// Used for OpenGL only
-class ZoomBlurLayer
-{
-public:
- ZoomBlurLayer() {};
- float x1, y1, x2, y2;
-};
-
-class ZoomBlurMain : public PluginVClient
-{
-public:
- ZoomBlurMain(PluginServer *server);
- ~ZoomBlurMain();
-
- 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(ZoomBlurConfig)
-
- void delete_tables();
- VFrame *input, *output, *temp;
- ZoomBlurEngine *engine;
- int **scale_y_table;
- int **scale_x_table;
- ZoomBlurLayer *layer_table;
- int table_entries;
- int need_reconfigure;
-// The accumulation buffer is needed because 8 bits isn't precise enough
- unsigned char *accum;
-};
-
-class ZoomBlurPackage : public LoadPackage
-{
-public:
- ZoomBlurPackage();
- int y1, y2;
-};
-
-class ZoomBlurUnit : public LoadClient
-{
-public:
- ZoomBlurUnit(ZoomBlurEngine *server, ZoomBlurMain *plugin);
- void process_package(LoadPackage *package);
- ZoomBlurEngine *server;
- ZoomBlurMain *plugin;
-};
-
-class ZoomBlurEngine : public LoadServer
-{
-public:
- ZoomBlurEngine(ZoomBlurMain *plugin,
- int total_clients,
- int total_packages);
- void init_packages();
- LoadClient* new_client();
- LoadPackage* new_package();
- ZoomBlurMain *plugin;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+#include "zoomblur.h"
ZoomBlurConfig::ZoomBlurConfig()
{
- x = 50;
- y = 50;
- radius = 10;
- steps = 10;
- r = 1;
- g = 1;
- b = 1;
- a = 1;
+ reset(RESET_DEFAULT_SETTINGS);
+}
+
+void ZoomBlurConfig::reset(int clear)
+{
+ switch(clear) {
+ case RESET_ALL :
+ x = xS(50);
+ y = yS(50);
+ radius = 0;
+ steps = 1;
+ r = 1;
+ g = 1;
+ b = 1;
+ a = 1;
+ break;
+ case RESET_XSLIDER : x = xS(50);
+ break;
+ case RESET_YSLIDER : y = yS(50);
+ break;
+ case RESET_RADIUS : radius = 0;
+ break;
+ case RESET_STEPS : steps = 1;
+ break;
+ case RESET_DEFAULT_SETTINGS :
+ default:
+ x = xS(50);
+ y = yS(50);
+ radius = 10;
+ steps = 10;
+ r = 1;
+ g = 1;
+ b = 1;
+ a = 1;
+ break;
+ }
}
int ZoomBlurConfig::equivalent(ZoomBlurConfig &that)
ZoomBlurWindow::ZoomBlurWindow(ZoomBlurMain *plugin)
: PluginClientWindow(plugin,
- 230,
- 340,
- 230,
- 340,
+ xS(280),
+ yS(370),
+ xS(280),
+ yS(370),
0)
{
this->plugin = plugin;
void ZoomBlurWindow::create_objects()
{
- int x = 10, y = 10;
+ int xs10 = xS(10), xs50 = xS(50), xs100 = xS(100);
+ int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(40);
+ int x = xs10, y = ys10;
+ int x1 = 0; int clrBtn_w = xs50;
+ int defaultBtn_w = xs100;
add_subwindow(new BC_Title(x, y, _("X:")));
- y += 20;
+ y += ys20;
add_subwindow(this->x = new ZoomBlurSize(plugin, x, y, &plugin->config.x, 0, 100));
- y += 30;
+ x1 = x + this->x->get_w() + xs10;
+ add_subwindow(xClr = new ZoomBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_XSLIDER));
+
+ y += ys30;
add_subwindow(new BC_Title(x, y, _("Y:")));
- y += 20;
+ y += ys20;
add_subwindow(this->y = new ZoomBlurSize(plugin, x, y, &plugin->config.y, 0, 100));
- y += 30;
+ add_subwindow(yClr = new ZoomBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_YSLIDER));
+
+ y += ys30;
add_subwindow(new BC_Title(x, y, _("Radius:")));
- y += 20;
+ y += ys20;
add_subwindow(radius = new ZoomBlurSize(plugin, x, y, &plugin->config.radius, -100, 100));
- y += 30;
+ add_subwindow(radiusClr = new ZoomBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_RADIUS));
+
+ y += ys30;
add_subwindow(new BC_Title(x, y, _("Steps:")));
- y += 20;
+ y += ys20;
add_subwindow(steps = new ZoomBlurSize(plugin, x, y, &plugin->config.steps, 1, 100));
- y += 30;
+ add_subwindow(stepsClr = new ZoomBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_STEPS));
+
+ y += ys30;
add_subwindow(r = new ZoomBlurToggle(plugin, x, y, &plugin->config.r, _("Red")));
- y += 30;
+ y += ys30;
add_subwindow(g = new ZoomBlurToggle(plugin, x, y, &plugin->config.g, _("Green")));
- y += 30;
+ y += ys30;
add_subwindow(b = new ZoomBlurToggle(plugin, x, y, &plugin->config.b, _("Blue")));
- y += 30;
+ y += ys30;
add_subwindow(a = new ZoomBlurToggle(plugin, x, y, &plugin->config.a, _("Alpha")));
- y += 30;
+ y += ys40;
+ add_subwindow(reset = new ZoomBlurReset(plugin, this, x, y));
+ add_subwindow(default_settings = new ZoomBlurDefaultSettings(plugin, this,
+ (xS(280) - xS(10) - defaultBtn_w), y, defaultBtn_w));
show_window();
flush();
}
-
+// for Reset button
+void ZoomBlurWindow::update_gui(int clear)
+{
+ switch(clear) {
+ case RESET_XSLIDER : this->x->update(plugin->config.x);
+ break;
+ case RESET_YSLIDER : this->y->update(plugin->config.y);
+ break;
+ case RESET_RADIUS : radius->update(plugin->config.radius);
+ break;
+ case RESET_STEPS : steps->update(plugin->config.steps);
+ break;
+ case RESET_ALL :
+ case RESET_DEFAULT_SETTINGS :
+ default:
+ this->x->update(plugin->config.x);
+ this->y->update(plugin->config.x);
+ radius->update(plugin->config.radius);
+ steps->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;
+ }
+}
int *output,
int min,
int max)
- : BC_ISlider(x, y, 0, 200, 200, min, max, *output)
+ : BC_ISlider(x, y, 0, xS(200), yS(200), min, max, *output)
{
this->plugin = plugin;
this->output = output;
}
+ZoomBlurReset::ZoomBlurReset(ZoomBlurMain *plugin, ZoomBlurWindow *window, int x, int y)
+ : BC_GenericButton(x, y, _("Reset"))
+{
+ this->plugin = plugin;
+ this->window = window;
+}
+ZoomBlurReset::~ZoomBlurReset()
+{
+}
+int ZoomBlurReset::handle_event()
+{
+ plugin->config.reset(RESET_ALL);
+ window->update_gui(RESET_ALL);
+ plugin->send_configure_change();
+ return 1;
+}
+ZoomBlurDefaultSettings::ZoomBlurDefaultSettings(ZoomBlurMain *plugin, ZoomBlurWindow *window, int x, int y, int w)
+ : BC_GenericButton(x, y, w, _("Default"))
+{
+ this->plugin = plugin;
+ this->window = window;
+}
+ZoomBlurDefaultSettings::~ZoomBlurDefaultSettings()
+{
+}
+int ZoomBlurDefaultSettings::handle_event()
+{
+ plugin->config.reset(RESET_DEFAULT_SETTINGS);
+ window->update_gui(RESET_DEFAULT_SETTINGS);
+ plugin->send_configure_change();
+ return 1;
+}
+ZoomBlurSliderClr::ZoomBlurSliderClr(ZoomBlurMain *plugin, ZoomBlurWindow *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;
+}
+ZoomBlurSliderClr::~ZoomBlurSliderClr()
+{
+}
+int ZoomBlurSliderClr::handle_event()
+{
+ // clear==1 ==> X slider
+ // clear==2 ==> Y slider
+ // clear==3 ==> Radius slider
+ // clear==4 ==> Steps slider
+ plugin->config.reset(clear);
+ window->update_gui(clear);
+ plugin->send_configure_change();
+ return 1;
+}