apply contrib scale plugin rework
authorGood Guy <good1.2guy@gmail.com>
Fri, 14 Aug 2020 02:39:14 +0000 (20:39 -0600)
committerGood Guy <good1.2guy@gmail.com>
Fri, 14 Aug 2020 02:39:14 +0000 (20:39 -0600)
cinelerra-5.1/cinelerra/appearanceprefs.C
cinelerra-5.1/plugins/scale/scale.C
cinelerra-5.1/plugins/scale/scale.h
cinelerra-5.1/plugins/scale/scalewin.C

index 435f70ad1bf6df6a54397e854a0f4ca2ee2ef3fd..d6ed2bb852dee6f2fc3c80a4a9820f9bc0d8cfac 100644 (file)
@@ -95,7 +95,7 @@ void AppearancePrefs::create_objects()
        add_subwindow(plugin_icons = new ViewPluginIcons(x1, y, pwindow));
        plugin_icons->create_objects();
        y += plugin_icons->get_h() + ys10;
-       add_subwindow(new BC_Title(x, y, _("Locale:")));
+       add_subwindow(new BC_Title(x, y, _("Language:")));
        LayoutLocale *layout_locale;
        add_subwindow(layout_locale = new LayoutLocale(x1, y, pwindow));
        layout_locale->create_objects();
index cb15aff0ecb3008bd103d5804c16e6e7d8c15f99..a3afb31ec4edecc19818023edbf0b4e0f2bbe3ba 100644 (file)
@@ -36,12 +36,36 @@ REGISTER_PLUGIN(ScaleMain)
 
 ScaleConfig::ScaleConfig()
 {
-       type = FIXED_SCALE;
-       x_factor = y_factor = 1;
-       width = height = 0;
-       constrain = 0;
+       reset(RESET_DEFAULT_SETTINGS);
 }
 
+void ScaleConfig::reset(int clear)
+{
+       switch(clear) {
+               case RESET_X_FACTOR :
+                       x_factor = 1;
+                       break;
+               case RESET_Y_FACTOR :
+                       y_factor = 1;
+                       break;
+               case RESET_WIDTH :
+                       width = 1280;
+                       break;
+               case RESET_HEIGHT :
+                       height = 720;
+                       break;
+               case RESET_ALL :
+               case RESET_DEFAULT_SETTINGS :
+               default:
+                       type = FIXED_SCALE;
+                       x_factor = y_factor = 1;
+                       width = 1280; height = 720;
+                       constrain = 0;
+                       break;
+       }
+}
+
+
 void ScaleConfig::copy_from(ScaleConfig &src)
 {
        type = src.type;
@@ -102,12 +126,12 @@ void ScaleMain::set_type(int type)
                ScaleWin *swin = (ScaleWin *)thread->window;
                int fixed_scale = type == FIXED_SCALE ? 1 : 0;
                swin->use_scale->update(fixed_scale);
-               swin->x_factor->enabled = fixed_scale;
-               swin->y_factor->enabled = fixed_scale;
+               swin->x_factor_text->enabled = fixed_scale;
+               swin->y_factor_text->enabled = fixed_scale;
                int fixed_size = 1 - fixed_scale;
                swin->use_size->update(fixed_size);
-               swin->width->enabled = fixed_size;
-               swin->height->enabled = fixed_size;
+               swin->width_text->enabled = fixed_size;
+               swin->height_text->enabled = fixed_size;
                send_configure_change();
        }
 }
@@ -293,11 +317,11 @@ void ScaleMain::update_gui()
                thread->window->lock_window();
                set_type(config.type);
                ScaleWin *swin = (ScaleWin *)thread->window;
-               swin->x_factor->update(config.x_factor);
-               swin->y_factor->update(config.y_factor);
-               swin->width->update((int64_t)config.width);
-               swin->height->update((int64_t)config.height);
-               swin->constrain->update(config.constrain);
+               swin->update(RESET_ALL);
+
+               // Needed to update Enable-Disable GUI when "Preset Edit" is used.
+               swin->update_scale_size_enable();
+
                thread->window->unlock_window();
        }
 }
index 164eeb62c5be736f2365cf2fdd7c60a61209cec7..89673a4fb57bd8ac0ce7fcc3772e356e421abf2b 100644 (file)
 // the simplest plugin possible
 
 class ScaleMain;
-class ScaleWidth;
-class ScaleHeight;
 class ScaleConstrain;
 class ScaleThread;
 class ScaleWin;
 
+class ScaleUseScale;
+class ScaleUseSize;
+
+class ScaleXFactorText;
+class ScaleXFactorSlider;
+class ScaleYFactorText;
+class ScaleYFactorSlider;
+class ScaleWidthText;
+class ScaleWidthSlider;
+class ScaleHeightText;
+class ScaleHeightSlider;
+
+class ScaleClr;
+class ScaleReset;
+
+#define RESET_DEFAULT_SETTINGS 10
+#define RESET_ALL    0
+#define RESET_X_FACTOR 1
+#define RESET_Y_FACTOR 2
+#define RESET_WIDTH  3
+#define RESET_HEIGHT 4
+
+#define MIN_FACTOR  0.00
+#define MAX_FACTOR 10.00
+#define MAX_WIDTH 16384
+#define MAX_HEIGHT 9216
+
+
 #include "bchash.h"
 #include "guicast.h"
 #include "mwindow.inc"
@@ -47,7 +73,7 @@ class ScaleConfig
 {
 public:
        ScaleConfig();
-
+       void reset(int clear);
        void copy_from(ScaleConfig &src);
        int equivalent(ScaleConfig &src);
        void interpolate(ScaleConfig &prev,
@@ -63,53 +89,8 @@ public:
 };
 
 
-class ScaleXFactor : public BC_TumbleTextBox
-{
-public:
-       ScaleXFactor(ScaleWin *win, ScaleMain *client, int x, int y);
-       ~ScaleXFactor();
-       int handle_event();
 
-       ScaleMain *client;
-       ScaleWin *win;
-       int enabled;
-};
 
-class ScaleWidth : public BC_TumbleTextBox
-{
-public:
-       ScaleWidth(ScaleWin *win, ScaleMain *client, int x, int y);
-       ~ScaleWidth();
-       int handle_event();
-
-       ScaleMain *client;
-       ScaleWin *win;
-       int enabled;
-};
-
-class ScaleYFactor : public BC_TumbleTextBox
-{
-public:
-       ScaleYFactor(ScaleWin *win, ScaleMain *client, int x, int y);
-       ~ScaleYFactor();
-       int handle_event();
-
-       ScaleMain *client;
-       ScaleWin *win;
-       int enabled;
-};
-
-class ScaleHeight : public BC_TumbleTextBox
-{
-public:
-       ScaleHeight(ScaleWin *win, ScaleMain *client, int x, int y);
-       ~ScaleHeight();
-       int handle_event();
-
-       ScaleMain *client;
-       ScaleWin *win;
-       int enabled;
-};
 
 class ScaleUseScale : public BC_Radial
 {
@@ -136,10 +117,11 @@ public:
 class ScaleConstrain : public BC_CheckBox
 {
 public:
-       ScaleConstrain(ScaleMain *client, int x, int y);
+       ScaleConstrain(ScaleWin *win, ScaleMain *client, int x, int y);
        ~ScaleConstrain();
        int handle_event();
 
+       ScaleWin *win;
        ScaleMain *client;
 };
 
@@ -150,16 +132,34 @@ public:
        ~ScaleWin();
 
        void create_objects();
+       void update(int clear);
+
+       void update_scale_size_enable();
 
        ScaleMain *client;
-       ScaleXFactor *x_factor;
-       ScaleYFactor *y_factor;
-       ScaleWidth *width;
-       ScaleHeight *height;
+
        FrameSizePulldown *pulldown;
        ScaleUseScale *use_scale;
        ScaleUseSize *use_size;
        ScaleConstrain *constrain;
+
+       ScaleXFactorText *x_factor_text;
+       ScaleXFactorSlider *x_factor_slider;
+       ScaleClr *x_factor_clr;
+
+       ScaleYFactorText *y_factor_text;
+       ScaleYFactorSlider *y_factor_slider;
+       ScaleClr *y_factor_clr;
+
+       ScaleWidthText *width_text;
+       ScaleWidthSlider *width_slider;
+       ScaleClr *width_clr;
+
+       ScaleHeightText *height_text;
+       ScaleHeightSlider *height_slider;
+       ScaleClr *height_clr;
+
+       ScaleReset *reset;
 };
 
 
@@ -196,5 +196,123 @@ public:
        OverlayFrame *overlayer;   // To scale images
 };
 
+class ScaleXFactorText : public BC_TumbleTextBox
+{
+public:
+       ScaleXFactorText(ScaleWin *win, ScaleMain *client,
+               int x,
+               int y);
+       ~ScaleXFactorText();
+       int handle_event();
+       ScaleWin *win;
+       ScaleMain *client;
+       int enabled;
+};
+
+class ScaleXFactorSlider : public BC_FSlider
+{
+public:
+       ScaleXFactorSlider(ScaleWin *win, ScaleMain *client,
+               int x, int y, int w);
+       ~ScaleXFactorSlider();
+       int handle_event();
+       ScaleWin *win;
+       ScaleMain *client;
+};
+
+class ScaleYFactorText : public BC_TumbleTextBox
+{
+public:
+       ScaleYFactorText(ScaleWin *win, ScaleMain *client,
+               int x,
+               int y);
+       ~ScaleYFactorText();
+       int handle_event();
+       ScaleWin *win;
+       ScaleMain *client;
+       int enabled;
+};
+
+class ScaleYFactorSlider : public BC_FSlider
+{
+public:
+       ScaleYFactorSlider(ScaleWin *win, ScaleMain *client,
+               int x, int y, int w);
+       ~ScaleYFactorSlider();
+       int handle_event();
+       ScaleWin *win;
+       ScaleMain *client;
+};
+
+class ScaleWidthText : public BC_TumbleTextBox
+{
+public:
+       ScaleWidthText(ScaleWin *win, ScaleMain *client,
+               int x,
+               int y);
+       ~ScaleWidthText();
+       int handle_event();
+       ScaleWin *win;
+       ScaleMain *client;
+       int enabled;
+};
+
+class ScaleWidthSlider : public BC_ISlider
+{
+public:
+       ScaleWidthSlider(ScaleWin *win, ScaleMain *client,
+               int x, int y, int w);
+       ~ScaleWidthSlider();
+       int handle_event();
+       ScaleWin *win;
+       ScaleMain *client;
+};
+
+class ScaleHeightText : public BC_TumbleTextBox
+{
+public:
+       ScaleHeightText(ScaleWin *win, ScaleMain *client,
+               int x,
+               int y);
+       ~ScaleHeightText();
+       int handle_event();
+       ScaleWin *win;
+       ScaleMain *client;
+       int enabled;
+};
+
+class ScaleHeightSlider : public BC_ISlider
+{
+public:
+       ScaleHeightSlider(ScaleWin *win, ScaleMain *client,
+               int x, int y, int w);
+       ~ScaleHeightSlider();
+       int handle_event();
+       ScaleWin *win;
+       ScaleMain *client;
+};
+
+
+class ScaleClr : public BC_Button
+{
+public:
+       ScaleClr(ScaleWin *win, ScaleMain *client,
+               int x, int y, int clear);
+       ~ScaleClr();
+       int handle_event();
+       ScaleWin *win;
+       ScaleMain *client;
+       int clear;
+};
+
+class ScaleReset : public BC_GenericButton
+{
+public:
+       ScaleReset(ScaleWin *win, ScaleMain *client, int x, int y);
+       ~ScaleReset();
+       int handle_event();
+       ScaleWin *win;
+       ScaleMain *client;
+};
 
 #endif
index 479aee67373fcf01224da6e9ddca1445622e50cd..1398be4f2cc09a6c0f16872b975da3db21307617 100644 (file)
@@ -22,6 +22,7 @@
 #include "bcdisplayinfo.h"
 #include "clip.h"
 #include "language.h"
+#include "theme.h"
 #include "mwindow.h"
 #include "pluginserver.h"
 #include "scale.h"
 
 
 ScaleWin::ScaleWin(ScaleMain *client)
- : PluginClientWindow(client, xS(400), yS(100), xS(400), yS(100), 0)
+ : PluginClientWindow(client, xS(420), yS(260), xS(420), yS(260), 0)
 {
        this->client = client;
 }
 
 ScaleWin::~ScaleWin()
 {
-       delete x_factor;
-       delete y_factor;
-       delete width;
-       delete height;
+       delete x_factor_text;
+       delete x_factor_slider;
+       delete x_factor_clr;
+       delete y_factor_text;
+       delete y_factor_slider;
+       delete y_factor_clr;
+       delete width_text;
+       delete width_slider;
+       delete width_clr;
+       delete height_text;
+       delete height_slider;
+       delete height_clr;
 }
 
 void ScaleWin::create_objects()
 {
-       int xs10 = xS(10), xs15 = xS(15), xs20 = xS(20);
-       int ys10 = yS(10), ys25 = yS(25);
-       int x0 = xs10, y0 = ys10;
-       int y1 = y0 + ys25;
-       int y2 = y1 + ys25;
-       BC_Title *title = new BC_Title(x0, y1, _("Scale:"));
-       add_tool(title);
-       int x1 = x0 + title->get_w() + xs10;
-       add_tool(use_scale = new ScaleUseScale(this, client, x1, y1));
-       int x2 = x1 + use_scale->get_w() + xs10;
-       x_factor = new ScaleXFactor(this, client, x2, y1);
-       x_factor->create_objects();
-       int x3 = x2 + x_factor->get_w() + xs20;
-       y_factor = new ScaleYFactor(this, client, x3, y1);
-       y_factor->create_objects();
-       add_tool(constrain = new ScaleConstrain(client, x1, y2));
-
-
-       add_tool(new BC_Title(x0, y0, _("Size:")));
-       add_tool(use_size = new ScaleUseSize(this, client, x1, y0));
-       width = new ScaleWidth(this, client, x2, y0);
-       width->create_objects();
-       int x = x2 + width->get_w() + xS(3);
-       add_tool(new BC_Title(x, y0, _("x")));
-       height= new ScaleHeight(this, client, x3, y0);
-       height->create_objects();
-       int x4 = x3 + height->get_w() + xs15;
+       int xs10 = xS(10), xs20 = xS(20), xs200 = xS(200);
+       int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(40);
+       int x2 = xS(60), x3 = xS(180);
+       int x = xs10, y = ys10;
+       int clr_x = get_w()-x - xS(22); // note: clrBtn_w = 22
+
+       BC_TitleBar *title_bar;
+       BC_Bar *bar;
+
+
+// Scale section
+       add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Scale")));
+       y += ys20;
+       add_tool(use_scale = new ScaleUseScale(this, client, x, y));
+       int xa= x*2 + use_scale->get_w();
+       add_tool(new BC_Title(xa, y, _("X:")));
+       x_factor_text = new ScaleXFactorText(this, client, (x + x2), y);
+       x_factor_text->create_objects();
+       x_factor_slider = new ScaleXFactorSlider(this, client, x3, y, xs200);
+       add_subwindow(x_factor_slider);
+       clr_x = x3 + x_factor_slider->get_w() + x;
+       add_subwindow(x_factor_clr = new ScaleClr(this, client, clr_x, y, RESET_X_FACTOR));
+       y += ys30;
+       add_tool(new BC_Title(xa, y, _("Y:")));
+       y_factor_text = new ScaleYFactorText(this, client, (x + x2), y);
+       y_factor_text->create_objects();
+       y_factor_slider = new ScaleYFactorSlider(this, client, x3, y, xs200);
+       add_subwindow(y_factor_slider);
+       add_subwindow(y_factor_clr = new ScaleClr(this, client, clr_x, y, RESET_Y_FACTOR));
+       y += ys30;
+       add_tool(constrain = new ScaleConstrain(this, client, (x + x2), y));
+       y += ys40;
+
+// Size section
+       add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Size")));
+       y += ys20;
+       add_tool(use_size = new ScaleUseSize(this, client, x, y));
+       add_tool(new BC_Title(xa, y, _("W:")));
+       width_text = new ScaleWidthText(this, client, (x + x2), y);
+       width_text->create_objects();
+       width_slider = new ScaleWidthSlider(this, client, x3, y, xs200);
+       add_subwindow(width_slider);
+       add_subwindow(width_clr = new ScaleClr(this, client, clr_x, y, RESET_WIDTH));
+       int ya = y;
+       y += ys30;
+       add_tool(new BC_Title(xa, y, _("H:")));
+       height_text = new ScaleHeightText(this, client, (x + x2), y);
+       height_text->create_objects();
+       height_slider = new ScaleHeightSlider(this, client, x3, y, xs200);
+       add_subwindow(height_slider);
+       add_subwindow(height_clr = new ScaleClr(this, client, clr_x, y, RESET_HEIGHT));
+
+       int x4 = x + x2 + height_text->get_w();
        add_tool(pulldown = new FrameSizePulldown(client->server->mwindow->theme,
-                       width->get_textbox(), height->get_textbox(), x4, y0));
+                       width_text->get_textbox(), height_text->get_textbox(), x4, ya));
+       y += ys40;
+
+// Reset section
+       add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
+       y += ys10;
+       add_tool(reset = new ScaleReset(this, client, x, y));
 
        show_window();
        flush();
+
+       // Needed to update Enable-Disable GUI when "Show controls" is pressed.
+       update_scale_size_enable();
+}
+
+
+void ScaleWin::update_scale_size_enable()
+{
+       if(use_scale->get_value()==1) 
+       {
+               width_text->disable();
+               width_slider->disable();
+               width_clr->disable();
+               height_text->disable();
+               height_slider->disable();
+               height_clr->disable();
+               pulldown->hide_window();
+
+               x_factor_text->enable();
+               x_factor_slider->enable();
+               x_factor_clr->enable();
+               if(client->config.constrain)
+               {
+                       y_factor_text->disable();
+                       y_factor_slider->disable();
+                       y_factor_clr->disable();
+               }
+               else
+               {
+                       y_factor_text->enable();
+                       y_factor_slider->enable();
+                       y_factor_clr->enable();
+               }
+               constrain->enable();
+       }
+
+       if(use_size->get_value()==1)
+       {
+               x_factor_text->disable();
+               x_factor_slider->disable();
+               x_factor_clr->disable();
+               y_factor_text->disable();
+               y_factor_slider->disable();
+               y_factor_clr->disable();
+               constrain->disable();
+
+               width_text->enable();
+               width_slider->enable();
+               width_clr->enable();
+               height_text->enable();
+               height_slider->enable();
+               height_clr->enable();
+               pulldown->show_window();
+       }
+}
+
+
+void ScaleWin::update(int clear)
+{
+       switch(clear) {
+               case RESET_X_FACTOR :
+                       x_factor_text->update((float)client->config.x_factor);
+                       x_factor_slider->update((float)client->config.x_factor);
+                       break;
+               case RESET_Y_FACTOR :
+                       y_factor_text->update((float)client->config.y_factor);
+                       y_factor_slider->update((float)client->config.y_factor);
+                       break;
+               case RESET_WIDTH :
+                       width_text->update((int64_t)client->config.width);
+                       width_slider->update((int64_t)client->config.width);
+                       break;
+               case RESET_HEIGHT :
+                       height_text->update((int64_t)client->config.height);
+                       height_slider->update((int64_t)client->config.height);
+                       break;
+               case RESET_ALL :
+               case RESET_DEFAULT_SETTINGS :
+               default:
+                       x_factor_text->update((float)client->config.x_factor);
+                       x_factor_slider->update((float)client->config.x_factor);
+                       y_factor_text->update((float)client->config.y_factor);
+                       y_factor_slider->update((float)client->config.y_factor);
+                       constrain->update(client->config.constrain);
+
+                       width_text->update((int64_t)client->config.width);
+                       width_slider->update((int64_t)client->config.width);
+                       height_text->update((int64_t)client->config.height);
+                       height_slider->update((int64_t)client->config.height);
+
+                       use_scale->update((int)!client->config.type);
+                       use_size->update((int)client->config.type);
+                       break;
+       }
+}
+
+
+
+
+
+ScaleUseScale::ScaleUseScale(ScaleWin *win, ScaleMain *client, int x, int y)
+ : BC_Radial(x, y, client->config.type == FIXED_SCALE, "")
+{
+        this->win = win;
+        this->client = client;
+       set_tooltip(_("Use fixed scale"));
+}
+ScaleUseScale::~ScaleUseScale()
+{
+}
+int ScaleUseScale::handle_event()
+{
+       client->set_type(FIXED_SCALE);
+       win->update_scale_size_enable();
+       return 1;
+}
+
+ScaleUseSize::ScaleUseSize(ScaleWin *win, ScaleMain *client, int x, int y)
+ : BC_Radial(x, y, client->config.type == FIXED_SIZE, "")
+{
+        this->win = win;
+        this->client = client;
+       set_tooltip(_("Use fixed size"));
+}
+ScaleUseSize::~ScaleUseSize()
+{
 }
+int ScaleUseSize::handle_event()
+{
+       client->set_type(FIXED_SIZE);
+       win->update_scale_size_enable();
+       return 1;
+}
+
+
 
-ScaleXFactor::ScaleXFactor(ScaleWin *win,
-       ScaleMain *client, int x, int y)
- : BC_TumbleTextBox(win, (float)client->config.x_factor, 0., 100., x, y, xS(100))
+ScaleConstrain::ScaleConstrain(ScaleWin *win, ScaleMain *client, int x, int y)
+ : BC_CheckBox(x, y, client->config.constrain, _("Constrain ratio"))
+{
+        this->win = win;
+       this->client = client;
+}
+ScaleConstrain::~ScaleConstrain()
+{
+}
+int ScaleConstrain::handle_event()
+{
+       client->config.constrain = get_value();
+
+       if(client->config.constrain)
+       {
+               win->y_factor_text->disable();
+               win->y_factor_slider->disable();
+               win->y_factor_clr->disable();
+
+               client->config.y_factor = client->config.x_factor;
+               win->y_factor_text->update(client->config.y_factor);
+               win->y_factor_slider->update(client->config.y_factor);
+       }
+       else
+       {
+               win->y_factor_text->enable();
+               win->y_factor_slider->enable();
+               win->y_factor_clr->enable();
+       }
+       client->send_configure_change();
+       return 1;
+}
+
+
+
+/* *********************************** */
+/* **** SCALE X FACTOR  ************** */
+ScaleXFactorText::ScaleXFactorText(ScaleWin *win, ScaleMain *client,
+       int x, int y)
+ : BC_TumbleTextBox(win, (float)client->config.x_factor,
+       MIN_FACTOR, MAX_FACTOR, x, y, xS(60), 2)
 {
-//printf("ScaleXFactor::ScaleXFactor %f\n", client->config.x_factor);
        this->client = client;
        this->win = win;
        set_increment(0.1);
        enabled = 1;
 }
 
-ScaleXFactor::~ScaleXFactor()
+ScaleXFactorText::~ScaleXFactorText()
 {
 }
 
-int ScaleXFactor::handle_event()
+int ScaleXFactorText::handle_event()
 {
        client->config.x_factor = atof(get_text());
-       CLAMP(client->config.x_factor, 0, 100);
+       CLAMP(client->config.x_factor, MIN_FACTOR, MAX_FACTOR);
 
        if(client->config.constrain)
        {
                client->config.y_factor = client->config.x_factor;
-               win->y_factor->update(client->config.y_factor);
-       }
-
-//printf("ScaleXFactor::handle_event 1 %f\n", client->config.x_factor);
-       if(client->config.type == FIXED_SCALE && enabled) {
-               client->send_configure_change();
+               win->y_factor_text->update(client->config.y_factor);
+               win->y_factor_slider->update(client->config.y_factor);
        }
+       win->x_factor_slider->update(client->config.x_factor);
+       client->send_configure_change();
        return 1;
 }
 
+ScaleXFactorSlider::ScaleXFactorSlider(ScaleWin *win, ScaleMain *client,
+       int x, int y, int w)
+ : BC_FSlider(x, y, 0, w, w, MIN_FACTOR, MAX_FACTOR, (float)client->config.x_factor)
+{
+       this->win = win;
+       this->client = client;
+       enable_show_value(0); // Hide caption
+       set_precision(0.01);
+}
 
+ScaleXFactorSlider::~ScaleXFactorSlider()
+{
+}
+
+int ScaleXFactorSlider::handle_event()
+{
+       client->config.x_factor = get_value();
+       if(client->config.constrain)
+       {
+               client->config.y_factor = client->config.x_factor;
+               win->y_factor_text->update(client->config.y_factor);
+               win->y_factor_slider->update(client->config.y_factor);
+       }
+       win->x_factor_text->update(client->config.x_factor);
+       client->send_configure_change();
+       return 1;
+}
+/* *********************************** */
 
 
-ScaleYFactor::ScaleYFactor(ScaleWin *win, ScaleMain *client, int x, int y)
- : BC_TumbleTextBox(win, (float)client->config.y_factor, 0., 100., x, y, xS(100))
+/* *********************************** */
+/* **** SCALE Y FACTOR  ************** */
+ScaleYFactorText::ScaleYFactorText(ScaleWin *win, ScaleMain *client,
+       int x, int y)
+ : BC_TumbleTextBox(win, (float)client->config.y_factor,
+       MIN_FACTOR, MAX_FACTOR, x, y, xS(60), 2)
 {
        this->client = client;
        this->win = win;
        set_increment(0.1);
        enabled = 1;
 }
-ScaleYFactor::~ScaleYFactor()
+
+ScaleYFactorText::~ScaleYFactorText()
 {
 }
-int ScaleYFactor::handle_event()
+
+int ScaleYFactorText::handle_event()
 {
        client->config.y_factor = atof(get_text());
-       CLAMP(client->config.y_factor, 0, 100);
+       CLAMP(client->config.y_factor, MIN_FACTOR, MAX_FACTOR);
 
        if(client->config.constrain)
        {
                client->config.x_factor = client->config.y_factor;
-               win->x_factor->update(client->config.x_factor);
+               win->x_factor_text->update(client->config.x_factor);
+               win->x_factor_slider->update(client->config.x_factor);
        }
+       win->y_factor_slider->update(client->config.y_factor);
+       client->send_configure_change();
+       return 1;
+}
 
-       if(client->config.type == FIXED_SCALE && enabled)
+ScaleYFactorSlider::ScaleYFactorSlider(ScaleWin *win, ScaleMain *client,
+       int x, int y, int w)
+ : BC_FSlider(x, y, 0, w, w, MIN_FACTOR, MAX_FACTOR, (float)client->config.y_factor)
+{
+       this->win = win;
+       this->client = client;
+       enable_show_value(0); // Hide caption
+       set_precision(0.01);
+}
+
+ScaleYFactorSlider::~ScaleYFactorSlider()
+{
+}
+
+int ScaleYFactorSlider::handle_event()
+{
+       client->config.y_factor = get_value();
+       if(client->config.constrain)
        {
-               client->send_configure_change();
+               client->config.x_factor = client->config.y_factor;
+               win->x_factor_text->update(client->config.x_factor);
+               win->x_factor_slider->update(client->config.x_factor);
        }
+       win->y_factor_text->update(client->config.y_factor);
+       client->send_configure_change();
        return 1;
 }
+/* *********************************** */
 
 
-
-ScaleWidth::ScaleWidth(ScaleWin *win,
-       ScaleMain *client, int x, int y)
- : BC_TumbleTextBox(win, client->config.width, 0, 100000, x, y, xS(90))
+/* *********************************** */
+/* **** SCALE WIDTH     ************** */
+ScaleWidthText::ScaleWidthText(ScaleWin *win, ScaleMain *client,
+       int x, int y)
+ : BC_TumbleTextBox(win, client->config.width,
+       0, MAX_WIDTH, x, y, xS(60))
 {
-//printf("ScaleWidth::ScaleWidth %f\n", client->config.x_factor);
        this->client = client;
        this->win = win;
        set_increment(10);
        enabled = 1;
 }
 
-ScaleWidth::~ScaleWidth()
+ScaleWidthText::~ScaleWidthText()
 {
 }
 
-int ScaleWidth::handle_event()
+int ScaleWidthText::handle_event()
 {
        client->config.width = atoi(get_text());
-       if(client->config.type == FIXED_SIZE && enabled)
-       {
-               client->send_configure_change();
-       }
-//printf("ScaleWidth::handle_event 1 %f\n", client->config.x_factor);
+       win->width_slider->update(client->config.width);
+       client->send_configure_change();
        return 1;
 }
 
+ScaleWidthSlider::ScaleWidthSlider(ScaleWin *win, ScaleMain *client,
+       int x, int y, int w)
+ : BC_ISlider(x, y, 0, w, w, 0, MAX_WIDTH, client->config.width)
+{
+       this->client = client;
+       this->win = win;
+       enable_show_value(0); // Hide caption
+}
+
+ScaleWidthSlider::~ScaleWidthSlider()
+{
+}
 
+int ScaleWidthSlider::handle_event()
+{
+       client->config.width = get_value();
+       win->width_text->update((int64_t)client->config.width);
+       client->send_configure_change();
+       return 1;
+}
+/* *********************************** */
 
 
-ScaleHeight::ScaleHeight(ScaleWin *win, ScaleMain *client, int x, int y)
- : BC_TumbleTextBox(win, client->config.height, 0, 100000, x, y, xS(90))
+/* *********************************** */
+/* **** SCALE HEIGHT    ************** */
+ScaleHeightText::ScaleHeightText(ScaleWin *win, ScaleMain *client,
+       int x, int y)
+ : BC_TumbleTextBox(win, client->config.height,
+       0, MAX_HEIGHT, x, y, xS(60))
 {
        this->client = client;
        this->win = win;
        set_increment(10);
        enabled = 1;
 }
-ScaleHeight::~ScaleHeight()
+
+ScaleHeightText::~ScaleHeightText()
 {
 }
 
-int ScaleHeight::handle_event()
+int ScaleHeightText::handle_event()
 {
        client->config.height = atoi(get_text());
-       if(client->config.type == FIXED_SIZE && enabled)
-       {
-               client->send_configure_change();
-       }
+       win->height_slider->update(client->config.height);
+       client->send_configure_change();
        return 1;
 }
 
-ScaleUseScale::ScaleUseScale(ScaleWin *win, ScaleMain *client, int x, int y)
- : BC_Radial(x, y, client->config.type == FIXED_SCALE, "")
+ScaleHeightSlider::ScaleHeightSlider(ScaleWin *win, ScaleMain *client,
+       int x, int y, int w)
+ : BC_ISlider(x, y, 0, w, w, 0, MAX_HEIGHT, client->config.height)
 {
-        this->win = win;
-        this->client = client;
-       set_tooltip(_("Use fixed scale"));
+       this->client = client;
+       this->win = win;
+       enable_show_value(0); // Hide caption
 }
-ScaleUseScale::~ScaleUseScale()
+
+ScaleHeightSlider::~ScaleHeightSlider()
 {
 }
-int ScaleUseScale::handle_event()
+
+int ScaleHeightSlider::handle_event()
 {
-       client->set_type(FIXED_SCALE);
+       client->config.height = get_value();
+       win->height_text->update((int64_t)client->config.height);
+       client->send_configure_change();
        return 1;
 }
+/* *********************************** */
 
-ScaleUseSize::ScaleUseSize(ScaleWin *win, ScaleMain *client, int x, int y)
- : BC_Radial(x, y, client->config.type == FIXED_SIZE, "")
+
+ScaleClr::ScaleClr(ScaleWin *win, ScaleMain *client, int x, int y, int clear)
+ : BC_Button(x, y, client->get_theme()->get_image_set("reset_button"))
 {
-        this->win = win;
-        this->client = client;
-       set_tooltip(_("Use fixed size"));
+       this->win = win;
+       this->client = client;
+       this->clear = clear;
 }
-ScaleUseSize::~ScaleUseSize()
+ScaleClr::~ScaleClr()
 {
 }
-int ScaleUseSize::handle_event()
+int ScaleClr::handle_event()
 {
-       client->set_type(FIXED_SIZE);
+       client->config.reset(clear);
+       win->update(clear);
+       if( client->config.constrain && win->use_scale->get_value() )
+       {
+               client->config.reset(RESET_X_FACTOR);
+               win->update(RESET_X_FACTOR);
+
+               client->config.reset(RESET_Y_FACTOR);
+               win->update(RESET_Y_FACTOR);
+       }
+       client->send_configure_change();
        return 1;
 }
 
-
-
-ScaleConstrain::ScaleConstrain(ScaleMain *client, int x, int y)
- : BC_CheckBox(x, y, client->config.constrain, _("Constrain ratio"))
+ScaleReset::ScaleReset(ScaleWin *win, ScaleMain *client, int x, int y)
+ : BC_GenericButton(x, y, _("Reset"))
 {
+       this->win = win;
        this->client = client;
 }
-ScaleConstrain::~ScaleConstrain()
+
+ScaleReset::~ScaleReset()
 {
 }
-int ScaleConstrain::handle_event()
+
+int ScaleReset::handle_event()
 {
-       client->config.constrain = get_value();
+       client->config.reset(RESET_ALL);
+       win->update(RESET_ALL);
+       win->update_scale_size_enable();
        client->send_configure_change();
        return 1;
 }
-