X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Frgbshift%2Frgbshift.C;h=95d120580a682f02a0b2a5f026e695c36eae95c1;hb=refs%2Fheads%2Fmaster;hp=d558687b106ad68c2b30e0929fc1d0252ba47f10;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/rgbshift/rgbshift.C b/cinelerra-5.1/plugins/rgbshift/rgbshift.C index d558687b..ebdd96a5 100644 --- a/cinelerra-5.1/plugins/rgbshift/rgbshift.C +++ b/cinelerra-5.1/plugins/rgbshift/rgbshift.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 RGBShiftEffect; - - -class RGBShiftConfig -{ -public: - RGBShiftConfig(); - - void copy_from(RGBShiftConfig &src); - int equivalent(RGBShiftConfig &src); - void interpolate(RGBShiftConfig &prev, - RGBShiftConfig &next, - long prev_frame, - long next_frame, - long current_frame); - - int r_dx, r_dy, g_dx, g_dy, b_dx, b_dy; -}; - -class RGBShiftLevel : public BC_ISlider -{ -public: - RGBShiftLevel(RGBShiftEffect *plugin, int *output, int x, int y); - int handle_event(); - RGBShiftEffect *plugin; - int *output; -}; - -class RGBShiftWindow : public PluginClientWindow -{ -public: - RGBShiftWindow(RGBShiftEffect *plugin); - void create_objects(); - RGBShiftLevel *r_dx, *r_dy, *g_dx, *g_dy, *b_dx, *b_dy; - RGBShiftEffect *plugin; -}; - - - -class RGBShiftEffect : public PluginVClient -{ - VFrame *temp_frame; -public: - RGBShiftEffect(PluginServer *server); - ~RGBShiftEffect(); - - - PLUGIN_CLASS_MEMBERS(RGBShiftConfig) - int process_realtime(VFrame *input, VFrame *output); - int is_realtime(); - void save_data(KeyFrame *keyframe); - void read_data(KeyFrame *keyframe); - void update_gui(); -}; - - +#include "rgbshift.h" @@ -99,12 +30,33 @@ REGISTER_PLUGIN(RGBShiftEffect) - RGBShiftConfig::RGBShiftConfig() { - r_dx = r_dy = 0; - g_dx = g_dy = 0; - b_dx = b_dy = 0; + reset(RESET_ALL); +} + +void RGBShiftConfig::reset(int clear) +{ + switch(clear) { + case RESET_R_DX : r_dx = 0; + break; + case RESET_R_DY : r_dy = 0; + break; + case RESET_G_DX : g_dx = 0; + break; + case RESET_G_DY : g_dy = 0; + break; + case RESET_B_DX : b_dx = 0; + break; + case RESET_B_DY : b_dy = 0; + break; + case RESET_ALL : + default: + r_dx = r_dy = 0; + g_dx = g_dy = 0; + b_dx = b_dy = 0; + break; + } } void RGBShiftConfig::copy_from(RGBShiftConfig &src) @@ -142,56 +94,232 @@ void RGBShiftConfig::interpolate(RGBShiftConfig &prev, -#define MAXVALUE 100 -RGBShiftLevel::RGBShiftLevel(RGBShiftEffect *plugin, int *output, int x, int y) - : BC_ISlider(x, y, 0, 200, 200, -MAXVALUE, MAXVALUE, *output) +RGBShiftIText::RGBShiftIText(RGBShiftWindow *window, RGBShiftEffect *plugin, + RGBShiftISlider *slider, int *output, int x, int y, int min, int max) + : BC_TumbleTextBox(window, *output, + min, max, x, y, xS(60), 0) +{ + this->window = window; + this->plugin = plugin; + this->output = output; + this->slider = slider; + this->min = min; + this->max = max; + set_increment(1); +} + +RGBShiftIText::~RGBShiftIText() +{ +} + +int RGBShiftIText::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; +} + +RGBShiftISlider::RGBShiftISlider(RGBShiftEffect *plugin, RGBShiftIText *text, int *output, int x, int y) + : BC_ISlider(x, y, 0, xS(200), xS(200), -MAXVALUE, MAXVALUE, *output) { this->plugin = plugin; this->output = output; + this->text = text; + enable_show_value(0); // Hide caption } -int RGBShiftLevel::handle_event() +int RGBShiftISlider::handle_event() { *output = get_value(); + text->update((int64_t)*output); + plugin->send_configure_change(); + return 1; +} + + +RGBShiftReset::RGBShiftReset(RGBShiftEffect *plugin, RGBShiftWindow *window, int x, int y) + : BC_GenericButton(x, y, _("Reset")) +{ + this->plugin = plugin; + this->window = window; +} +RGBShiftReset::~RGBShiftReset() +{ +} +int RGBShiftReset::handle_event() +{ + plugin->config.reset(RESET_ALL); + window->update_gui(RESET_ALL); + plugin->send_configure_change(); + return 1; +} + + +RGBShiftClr::RGBShiftClr(RGBShiftEffect *plugin, RGBShiftWindow *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; +} +RGBShiftClr::~RGBShiftClr() +{ +} +int RGBShiftClr::handle_event() +{ + // clear==1 ==> r_dx slider --- clear==2 ==> r_dy slider + // clear==3 ==> g_dx slider --- clear==4 ==> g_dy slider + // clear==5 ==> b_dx slider --- clear==6 ==> b_dy slider + plugin->config.reset(clear); + window->update_gui(clear); plugin->send_configure_change(); return 1; } RGBShiftWindow::RGBShiftWindow(RGBShiftEffect *plugin) - : PluginClientWindow(plugin, 300, 200, 300, 200, 0) + : PluginClientWindow(plugin, xS(420), yS(250), xS(420), yS(250), 0) { this->plugin = plugin; } void RGBShiftWindow::create_objects() { - int x = 10, y = 10, x1 = 50; + int xs10 = xS(10); + 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, _("R_dx:"))); - add_subwindow(r_dx = new RGBShiftLevel(plugin, &plugin->config.r_dx, x1, y)); - y += 30; + r_dx_text = new RGBShiftIText(this, plugin, + 0, &plugin->config.r_dx, (x + x2), y, -MAXVALUE, MAXVALUE); + r_dx_text->create_objects(); + r_dx_slider = new RGBShiftISlider(plugin, + r_dx_text, &plugin->config.r_dx, x3, y); + add_subwindow(r_dx_slider); + r_dx_text->slider = r_dx_slider; + clr_x = x3 + r_dx_slider->get_w() + x; + add_subwindow(r_dx_Clr = new RGBShiftClr(plugin, this, clr_x, y, RESET_R_DX)); + y += ys30; + add_subwindow(new BC_Title(x, y, _("R_dy:"))); - add_subwindow(r_dy = new RGBShiftLevel(plugin, &plugin->config.r_dy, x1, y)); - y += 30; + r_dy_text = new RGBShiftIText(this, plugin, + 0, &plugin->config.r_dy, (x + x2), y, -MAXVALUE, MAXVALUE); + r_dy_text->create_objects(); + r_dy_slider = new RGBShiftISlider(plugin, + r_dy_text, &plugin->config.r_dy, x3, y); + add_subwindow(r_dy_slider); + r_dy_text->slider = r_dy_slider; + add_subwindow(r_dy_Clr = new RGBShiftClr(plugin, this, clr_x, y, RESET_R_DY)); + y += ys30; + add_subwindow(new BC_Title(x, y, _("G_dx:"))); - add_subwindow(g_dx = new RGBShiftLevel(plugin, &plugin->config.g_dx, x1, y)); - y += 30; + g_dx_text = new RGBShiftIText(this, plugin, + 0, &plugin->config.g_dx, (x + x2), y, -MAXVALUE, MAXVALUE); + g_dx_text->create_objects(); + g_dx_slider = new RGBShiftISlider(plugin, + g_dx_text, &plugin->config.g_dx, x3, y); + add_subwindow(g_dx_slider); + g_dx_text->slider = g_dx_slider; + add_subwindow(g_dx_Clr = new RGBShiftClr(plugin, this, clr_x, y, RESET_G_DX)); + y += ys30; + add_subwindow(new BC_Title(x, y, _("G_dy:"))); - add_subwindow(g_dy = new RGBShiftLevel(plugin, &plugin->config.g_dy, x1, y)); - y += 30; + g_dy_text = new RGBShiftIText(this, plugin, + 0, &plugin->config.g_dy, (x + x2), y, -MAXVALUE, MAXVALUE); + g_dy_text->create_objects(); + g_dy_slider = new RGBShiftISlider(plugin, + g_dy_text, &plugin->config.g_dy, x3, y); + add_subwindow(g_dy_slider); + g_dy_text->slider = g_dy_slider; + add_subwindow(g_dy_Clr = new RGBShiftClr(plugin, this, clr_x, y, RESET_G_DY)); + y += ys30; + add_subwindow(new BC_Title(x, y, _("B_dx:"))); - add_subwindow(b_dx = new RGBShiftLevel(plugin, &plugin->config.b_dx, x1, y)); - y += 30; + b_dx_text = new RGBShiftIText(this, plugin, + 0, &plugin->config.b_dx, (x + x2), y, -MAXVALUE, MAXVALUE); + b_dx_text->create_objects(); + b_dx_slider = new RGBShiftISlider(plugin, + b_dx_text, &plugin->config.b_dx, x3, y); + add_subwindow(b_dx_slider); + b_dx_text->slider = b_dx_slider; + add_subwindow(b_dx_Clr = new RGBShiftClr(plugin, this, clr_x, y, RESET_B_DX)); + y += ys30; + add_subwindow(new BC_Title(x, y, _("B_dy:"))); - add_subwindow(b_dy = new RGBShiftLevel(plugin, &plugin->config.b_dy, x1, y)); + b_dy_text = new RGBShiftIText(this, plugin, + 0, &plugin->config.b_dy, (x + x2), y, -MAXVALUE, MAXVALUE); + b_dy_text->create_objects(); + b_dy_slider = new RGBShiftISlider(plugin, + b_dy_text, &plugin->config.b_dy, x3, y); + add_subwindow(b_dy_slider); + b_dy_text->slider = b_dy_slider; + add_subwindow(b_dy_Clr = new RGBShiftClr(plugin, this, clr_x, y, RESET_B_DY)); + y += ys40; + +// Reset section + add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x)); + y += ys10; + add_subwindow(reset = new RGBShiftReset(plugin, this, x, y)); show_window(); flush(); } - +// for Reset button +void RGBShiftWindow::update_gui(int clear) +{ + switch(clear) { + case RESET_R_DX : + r_dx_text->update((int64_t)plugin->config.r_dx); + r_dx_slider->update(plugin->config.r_dx); + break; + case RESET_R_DY : + r_dy_text->update((int64_t)plugin->config.r_dy); + r_dy_slider->update(plugin->config.r_dy); + break; + case RESET_G_DX : + g_dx_text->update((int64_t)plugin->config.g_dx); + g_dx_slider->update(plugin->config.g_dx); + break; + case RESET_G_DY : + g_dy_text->update((int64_t)plugin->config.g_dy); + g_dy_slider->update(plugin->config.g_dy); + break; + case RESET_B_DX : + b_dx_text->update((int64_t)plugin->config.b_dx); + b_dx_slider->update(plugin->config.b_dx); + break; + case RESET_B_DY : + b_dy_text->update((int64_t)plugin->config.b_dy); + b_dy_slider->update(plugin->config.b_dy); + break; + case RESET_ALL : + default: + r_dx_text->update((int64_t)plugin->config.r_dx); + r_dx_slider->update(plugin->config.r_dx); + r_dy_text->update((int64_t)plugin->config.r_dy); + r_dy_slider->update(plugin->config.r_dy); + g_dx_text->update((int64_t)plugin->config.g_dx); + g_dx_slider->update(plugin->config.g_dx); + g_dy_text->update((int64_t)plugin->config.g_dy); + g_dy_slider->update(plugin->config.g_dy); + b_dx_text->update((int64_t)plugin->config.b_dx); + b_dx_slider->update(plugin->config.b_dx); + b_dy_text->update((int64_t)plugin->config.b_dy); + b_dy_slider->update(plugin->config.b_dy); + break; + } +} @@ -222,12 +350,18 @@ void RGBShiftEffect::update_gui() RGBShiftWindow *yuv_wdw = (RGBShiftWindow*)thread->window; yuv_wdw->lock_window("RGBShiftEffect::update_gui"); load_configuration(); - yuv_wdw->r_dx->update(config.r_dx); - yuv_wdw->r_dy->update(config.r_dy); - yuv_wdw->g_dx->update(config.g_dx); - yuv_wdw->g_dy->update(config.g_dy); - yuv_wdw->b_dx->update(config.b_dx); - yuv_wdw->b_dy->update(config.b_dy); + yuv_wdw->r_dx_text->update((int64_t)config.r_dx); + yuv_wdw->r_dx_slider->update(config.r_dx); + yuv_wdw->r_dy_text->update((int64_t)config.r_dy); + yuv_wdw->r_dy_slider->update(config.r_dy); + yuv_wdw->g_dx_text->update((int64_t)config.g_dx); + yuv_wdw->g_dx_slider->update(config.g_dx); + yuv_wdw->g_dy_text->update((int64_t)config.g_dy); + yuv_wdw->g_dy_slider->update(config.g_dy); + yuv_wdw->b_dx_text->update((int64_t)config.b_dx); + yuv_wdw->b_dx_slider->update(config.b_dx); + yuv_wdw->b_dy_text->update((int64_t)config.b_dy); + yuv_wdw->b_dy_slider->update(config.b_dy); yuv_wdw->unlock_window(); } }