X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fzoomblur%2Fzoomblur.C;h=0d40b7ca2857bf86cd801a34905db5f30b9c27e7;hp=8336708732aa833ee1fd45756879e19236a2580c;hb=c857b2fb7965d27d86d5785fb9f1b8957a871a1a;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/plugins/zoomblur/zoomblur.C b/cinelerra-5.1/plugins/zoomblur/zoomblur.C index 83367087..0d40b7ca 100644 --- a/cinelerra-5.1/plugins/zoomblur/zoomblur.C +++ b/cinelerra-5.1/plugins/zoomblur/zoomblur.C @@ -19,180 +19,8 @@ * */ -#include -#include -#include - -#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" @@ -202,14 +30,42 @@ REGISTER_PLUGIN(ZoomBlurMain) 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 = 50; + y = 50; + radius = 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_RADIUS : radius = 0; + break; + case RESET_STEPS : steps = 1; + break; + case RESET_DEFAULT_SETTINGS : + default: + x = 50; + y = 50; + radius = 10; + steps = 10; + r = 1; + g = 1; + b = 1; + a = 1; + break; + } } int ZoomBlurConfig::equivalent(ZoomBlurConfig &that) @@ -268,10 +124,10 @@ void ZoomBlurConfig::interpolate(ZoomBlurConfig &prev, ZoomBlurWindow::ZoomBlurWindow(ZoomBlurMain *plugin) : PluginClientWindow(plugin, - 230, - 340, - 230, - 340, + 280, + 370, + 280, + 370, 0) { this->plugin = plugin; @@ -284,22 +140,33 @@ ZoomBlurWindow::~ZoomBlurWindow() void ZoomBlurWindow::create_objects() { int x = 10, y = 10; + int x1 = 0; int clrBtn_w = 50; + int defaultBtn_w = 100; add_subwindow(new BC_Title(x, y, _("X:"))); y += 20; add_subwindow(this->x = new ZoomBlurSize(plugin, x, y, &plugin->config.x, 0, 100)); + x1 = x + this->x->get_w() + 10; + add_subwindow(xClr = new ZoomBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_XSLIDER)); + y += 30; add_subwindow(new BC_Title(x, y, _("Y:"))); y += 20; add_subwindow(this->y = new ZoomBlurSize(plugin, x, y, &plugin->config.y, 0, 100)); + add_subwindow(yClr = new ZoomBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_YSLIDER)); + y += 30; add_subwindow(new BC_Title(x, y, _("Radius:"))); y += 20; add_subwindow(radius = new ZoomBlurSize(plugin, x, y, &plugin->config.radius, -100, 100)); + add_subwindow(radiusClr = new ZoomBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_RADIUS)); + y += 30; add_subwindow(new BC_Title(x, y, _("Steps:"))); y += 20; add_subwindow(steps = new ZoomBlurSize(plugin, x, y, &plugin->config.steps, 1, 100)); + add_subwindow(stepsClr = new ZoomBlurSliderClr(plugin, this, x1, y, clrBtn_w, RESET_STEPS)); + y += 30; add_subwindow(r = new ZoomBlurToggle(plugin, x, y, &plugin->config.r, _("Red"))); y += 30; @@ -308,13 +175,41 @@ void ZoomBlurWindow::create_objects() add_subwindow(b = new ZoomBlurToggle(plugin, x, y, &plugin->config.b, _("Blue"))); y += 30; add_subwindow(a = new ZoomBlurToggle(plugin, x, y, &plugin->config.a, _("Alpha"))); - y += 30; + y += 40; + add_subwindow(reset = new ZoomBlurReset(plugin, this, x, y)); + add_subwindow(default_settings = new ZoomBlurDefaultSettings(plugin, this, + (280 - 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; + } +} @@ -368,10 +263,63 @@ int ZoomBlurSize::handle_event() } +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; +}