r864: Merge 2.1:
[cinelerra_cv/ct.git] / plugins / scale / scalewin.C
blob19676b1c333feb964a58a19f1f2578e62ce1fe64
1 #include "bcdisplayinfo.h"
2 #include "clip.h"
3 #include "language.h"
4 #include "scale.h"
10 PLUGIN_THREAD_OBJECT(ScaleMain, ScaleThread, ScaleWin)
19 ScaleWin::ScaleWin(ScaleMain *client, int x, int y)
20  : BC_Window(client->gui_string, 
21         x,
22         y,
23         150, 
24         150, 
25         150, 
26         150, 
27         0, 
28         0,
29         1)
30
31         this->client = client; 
34 ScaleWin::~ScaleWin()
38 int ScaleWin::create_objects()
40         int x = 10, y = 10;
42         add_tool(new BC_Title(x, y, _("X Scale:")));
43         y += 20;
44         width = new ScaleWidth(this, client, x, y);
45         width->create_objects();
46         y += 30;
47         add_tool(new BC_Title(x, y, _("Y Scale:")));
48         y += 20;
49         height = new ScaleHeight(this, client, x, y);
50         height->create_objects();
51         y += 35;
52         add_tool(constrain = new ScaleConstrain(client, x, y));
53         show_window();
54         flush();
55         return 0;
58 int ScaleWin::close_event()
60         set_done(1);
61         return 1;
64 ScaleWidth::ScaleWidth(ScaleWin *win, 
65         ScaleMain *client, 
66         int x, 
67         int y)
68  : BC_TumbleTextBox(win,
69         (float)client->config.w,
70         (float)0,
71         (float)100,
72         x, 
73         y, 
74         100)
76 //printf("ScaleWidth::ScaleWidth %f\n", client->config.w);
77         this->client = client;
78         this->win = win;
79         set_increment(0.1);
82 ScaleWidth::~ScaleWidth()
86 int ScaleWidth::handle_event()
88         client->config.w = atof(get_text());
89         CLAMP(client->config.w, 0, 100);
91         if(client->config.constrain)
92         {
93                 client->config.h = client->config.w;
94                 win->height->update(client->config.h);
95         }
97 //printf("ScaleWidth::handle_event 1 %f\n", client->config.w);
98         client->send_configure_change();
99         return 1;
105 ScaleHeight::ScaleHeight(ScaleWin *win, ScaleMain *client, int x, int y)
106  : BC_TumbleTextBox(win,
107         (float)client->config.h,
108         (float)0,
109         (float)100,
110         x, 
111         y, 
112         100)
114         this->client = client;
115         this->win = win;
116         set_increment(0.1);
118 ScaleHeight::~ScaleHeight()
121 int ScaleHeight::handle_event()
123         client->config.h = atof(get_text());
124         CLAMP(client->config.h, 0, 100);
126         if(client->config.constrain)
127         {
128                 client->config.w = client->config.h;
129                 win->width->update(client->config.w);
130         }
132         client->send_configure_change();
133         return 1;
141 ScaleConstrain::ScaleConstrain(ScaleMain *client, int x, int y)
142  : BC_CheckBox(x, y, client->config.constrain, _("Constrain ratio"))
144         this->client = client;
146 ScaleConstrain::~ScaleConstrain()
149 int ScaleConstrain::handle_event()
151         client->config.constrain = get_value();
152         client->send_configure_change();