X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fyuvshift%2Fyuvshift.C;h=0f0b85b663d845e785fceeae382e7ce6a199e061;hb=3d5faf45a6c261bb3e9973b42cf682415a1fde2e;hp=bab83bb432f1da07bf7551bb0a55af083e70153a;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/yuvshift/yuvshift.C b/cinelerra-5.1/plugins/yuvshift/yuvshift.C index bab83bb4..0f0b85b6 100644 --- a/cinelerra-5.1/plugins/yuvshift/yuvshift.C +++ b/cinelerra-5.1/plugins/yuvshift/yuvshift.C @@ -19,76 +19,7 @@ * */ -#include "bcdisplayinfo.h" -#include "clip.h" -#include "bchash.h" -#include "filexml.h" -#include "guicast.h" -#include "language.h" -#include "bccolors.h" -#include "pluginvclient.h" -#include "vframe.h" - -#include -#include - - -class YUVShiftEffect; - - -class YUVShiftConfig -{ -public: - YUVShiftConfig(); - - void copy_from(YUVShiftConfig &src); - int equivalent(YUVShiftConfig &src); - void interpolate(YUVShiftConfig &prev, - YUVShiftConfig &next, - long prev_frame, - long next_frame, - long current_frame); - - int y_dx, y_dy, u_dx, u_dy, v_dx, v_dy; -}; - -class YUVShiftLevel : public BC_ISlider -{ -public: - YUVShiftLevel(YUVShiftEffect *plugin, int *output, int x, int y); - int handle_event(); - YUVShiftEffect *plugin; - int *output; -}; - -class YUVShiftWindow : public PluginClientWindow -{ -public: - YUVShiftWindow(YUVShiftEffect *plugin); - void create_objects(); - YUVShiftLevel *y_dx, *y_dy, *u_dx, *u_dy, *v_dx, *v_dy; - YUVShiftEffect *plugin; -}; - - - -class YUVShiftEffect : public PluginVClient -{ - VFrame *temp_frame; -public: - YUVShiftEffect(PluginServer *server); - ~YUVShiftEffect(); - - - PLUGIN_CLASS_MEMBERS(YUVShiftConfig) - int process_realtime(VFrame *input, VFrame *output); - int is_realtime(); - void save_data(KeyFrame *keyframe); - void read_data(KeyFrame *keyframe); - void update_gui(); -}; - - +#include "yuvshift.h" @@ -99,12 +30,33 @@ REGISTER_PLUGIN(YUVShiftEffect) - YUVShiftConfig::YUVShiftConfig() { - y_dx = y_dy = 0; - u_dx = u_dy = 0; - v_dx = v_dy = 0; + reset(RESET_ALL); +} + +void YUVShiftConfig::reset(int clear) +{ + switch(clear) { + case RESET_Y_DX : y_dx = 0; + break; + case RESET_Y_DY : y_dy = 0; + break; + case RESET_U_DX : u_dx = 0; + break; + case RESET_U_DY : u_dy = 0; + break; + case RESET_V_DX : v_dx = 0; + break; + case RESET_V_DY : v_dy = 0; + break; + case RESET_ALL : + default: + y_dx = y_dy = 0; + u_dx = u_dy = 0; + v_dx = v_dy = 0; + break; + } } void YUVShiftConfig::copy_from(YUVShiftConfig &src) @@ -159,8 +111,48 @@ int YUVShiftLevel::handle_event() } +YUVShiftReset::YUVShiftReset(YUVShiftEffect *plugin, YUVShiftWindow *window, int x, int y) + : BC_GenericButton(x, y, _("Reset")) +{ + this->plugin = plugin; + this->window = window; +} +YUVShiftReset::~YUVShiftReset() +{ +} +int YUVShiftReset::handle_event() +{ + plugin->config.reset(RESET_ALL); + window->update_gui(RESET_ALL); + plugin->send_configure_change(); + return 1; +} + + +YUVShiftSliderClr::YUVShiftSliderClr(YUVShiftEffect *plugin, YUVShiftWindow *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; +} +YUVShiftSliderClr::~YUVShiftSliderClr() +{ +} +int YUVShiftSliderClr::handle_event() +{ + // clear==1 ==> y_dx slider --- clear==2 ==> y_dy slider + // clear==3 ==> u_dx slider --- clear==4 ==> u_dy slider + // clear==5 ==> v_dx slider --- clear==6 ==> v_dy slider + plugin->config.reset(clear); + window->update_gui(clear); + plugin->send_configure_change(); + return 1; +} + + YUVShiftWindow::YUVShiftWindow(YUVShiftEffect *plugin) - : PluginClientWindow(plugin, 300, 200, 300, 200, 0) + : PluginClientWindow(plugin, 320, 230, 320, 230, 0) { this->plugin = plugin; } @@ -168,30 +160,73 @@ YUVShiftWindow::YUVShiftWindow(YUVShiftEffect *plugin) void YUVShiftWindow::create_objects() { int x = 10, y = 10, x1 = 50; + int x2 = 0; int clrBtn_w = 50; + add_subwindow(new BC_Title(x, y, _("Y_dx:"))); add_subwindow(y_dx = new YUVShiftLevel(plugin, &plugin->config.y_dx, x1, y)); + x2 = x1 + y_dx->get_w() + 10; + add_subwindow(y_dxClr = new YUVShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_Y_DX)); + y += 30; add_subwindow(new BC_Title(x, y, _("Y_dy:"))); add_subwindow(y_dy = new YUVShiftLevel(plugin, &plugin->config.y_dy, x1, y)); + add_subwindow(y_dyClr = new YUVShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_Y_DY)); + y += 30; add_subwindow(new BC_Title(x, y, _("U_dx:"))); add_subwindow(u_dx = new YUVShiftLevel(plugin, &plugin->config.u_dx, x1, y)); + add_subwindow(u_dxClr = new YUVShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_U_DX)); + y += 30; add_subwindow(new BC_Title(x, y, _("U_dy:"))); add_subwindow(u_dy = new YUVShiftLevel(plugin, &plugin->config.u_dy, x1, y)); + add_subwindow(u_dyClr = new YUVShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_U_DY)); + y += 30; add_subwindow(new BC_Title(x, y, _("V_dx:"))); add_subwindow(v_dx = new YUVShiftLevel(plugin, &plugin->config.v_dx, x1, y)); + add_subwindow(v_dxClr = new YUVShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_V_DX)); + y += 30; add_subwindow(new BC_Title(x, y, _("V_dy:"))); add_subwindow(v_dy = new YUVShiftLevel(plugin, &plugin->config.v_dy, x1, y)); + add_subwindow(v_dyClr = new YUVShiftSliderClr(plugin, this, x2, y, clrBtn_w, RESET_V_DY)); + + y += 40; + add_subwindow(reset = new YUVShiftReset(plugin, this, x, y)); show_window(); flush(); } - +// for Reset button +void YUVShiftWindow::update_gui(int clear) +{ + switch(clear) { + case RESET_Y_DX : y_dx->update(plugin->config.y_dx); + break; + case RESET_Y_DY : y_dy->update(plugin->config.y_dy); + break; + case RESET_U_DX : u_dx->update(plugin->config.u_dx); + break; + case RESET_U_DY : u_dy->update(plugin->config.u_dy); + break; + case RESET_V_DX : v_dx->update(plugin->config.v_dx); + break; + case RESET_V_DY : v_dy->update(plugin->config.v_dy); + break; + case RESET_ALL : + default: + y_dx->update(plugin->config.y_dx); + y_dy->update(plugin->config.y_dy); + u_dx->update(plugin->config.u_dx); + u_dy->update(plugin->config.u_dy); + v_dx->update(plugin->config.v_dx); + v_dy->update(plugin->config.v_dy); + break; + } +}