update internationalization data
[goodguy/history.git] / cinelerra-5.0 / plugins / scale / scalewin.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #include "bcdisplayinfo.h"
23 #include "clip.h"
24 #include "language.h"
25 #include "mwindow.h"
26 #include "pluginserver.h"
27 #include "scale.h"
28
29
30
31 ScaleWin::ScaleWin(ScaleMain *client)
32  : PluginClientWindow(client,
33         400, 100, 400, 100, 0)
34
35         this->client = client; 
36 }
37
38 ScaleWin::~ScaleWin()
39 {
40         delete x_factor;
41         delete y_factor;
42         delete width;
43         delete height;
44 }
45
46 void ScaleWin::create_objects()
47 {
48         int x0 = 10, y0 = 10;
49         int y1 = y0 + 25;
50         int y2 = y1 + 25;
51         BC_Title *title = new BC_Title(x0, y1, _("Scale:"));
52         add_tool(title);
53         int x1 = x0 + title->get_w() + 10;
54         add_tool(use_scale = new ScaleUseScale(this, client, x1, y1));
55         int x2 = x1 + use_scale->get_w() + 10;
56         x_factor = new ScaleXFactor(this, client, x2, y1);
57         x_factor->create_objects();
58         int x3 = x2 + x_factor->get_w() + 20;
59         y_factor = new ScaleYFactor(this, client, x3, y1);
60         y_factor->create_objects();
61         add_tool(constrain = new ScaleConstrain(client, x1, y2));
62
63
64         add_tool(new BC_Title(x0, y0, _("Size:")));
65         add_tool(use_size = new ScaleUseSize(this, client, x1, y0));
66         width = new ScaleWidth(this, client, x2, y0);
67         width->create_objects();
68         int x = x2 + width->get_w() + 3;
69         add_tool(new BC_Title(x, y0, _("x")));
70         height= new ScaleHeight(this, client, x3, y0);
71         height->create_objects();
72         int x4 = x3 + height->get_w() + 15;
73         add_tool(pulldown = new FrameSizePulldown(client->server->mwindow->theme,
74                         width->get_textbox(), height->get_textbox(), x4, y0));
75
76         show_window();
77         flush();
78 }
79
80 ScaleXFactor::ScaleXFactor(ScaleWin *win, 
81         ScaleMain *client, int x, int y)
82  : BC_TumbleTextBox(win, (float)client->config.x_factor, 0., 100., x, y, 100)
83 {
84 //printf("ScaleXFactor::ScaleXFactor %f\n", client->config.x_factor);
85         this->client = client;
86         this->win = win;
87         set_increment(0.1);
88         enabled = 1;
89 }
90
91 ScaleXFactor::~ScaleXFactor()
92 {
93 }
94
95 int ScaleXFactor::handle_event()
96 {
97         client->config.x_factor = atof(get_text());
98         CLAMP(client->config.x_factor, 0, 100);
99
100         if(client->config.constrain)
101         {
102                 client->config.y_factor = client->config.x_factor;
103                 win->y_factor->update(client->config.y_factor);
104         }
105
106 //printf("ScaleXFactor::handle_event 1 %f\n", client->config.x_factor);
107         if(client->config.type == FIXED_SCALE && enabled) {
108                 client->send_configure_change();
109         }
110         return 1;
111 }
112
113
114
115
116 ScaleYFactor::ScaleYFactor(ScaleWin *win, ScaleMain *client, int x, int y)
117  : BC_TumbleTextBox(win, (float)client->config.y_factor, 0., 100., x, y, 100)
118 {
119         this->client = client;
120         this->win = win;
121         set_increment(0.1);
122         enabled = 1;
123 }
124 ScaleYFactor::~ScaleYFactor()
125 {
126 }
127 int ScaleYFactor::handle_event()
128 {
129         client->config.y_factor = atof(get_text());
130         CLAMP(client->config.y_factor, 0, 100);
131
132         if(client->config.constrain)
133         {
134                 client->config.x_factor = client->config.y_factor;
135                 win->x_factor->update(client->config.x_factor);
136         }
137
138         if(client->config.type == FIXED_SCALE && enabled)
139         {
140                 client->send_configure_change();
141         }
142         return 1;
143 }
144
145
146
147 ScaleWidth::ScaleWidth(ScaleWin *win, 
148         ScaleMain *client, int x, int y)
149  : BC_TumbleTextBox(win, client->config.width, 0, 100000, x, y, 90)
150 {
151 //printf("ScaleWidth::ScaleWidth %f\n", client->config.x_factor);
152         this->client = client;
153         this->win = win;
154         set_increment(10);
155         enabled = 1;
156 }
157
158 ScaleWidth::~ScaleWidth()
159 {
160 }
161
162 int ScaleWidth::handle_event()
163 {
164         client->config.width = atoi(get_text());
165         if(client->config.type == FIXED_SIZE && enabled)
166         {
167                 client->send_configure_change();
168         }
169 //printf("ScaleWidth::handle_event 1 %f\n", client->config.x_factor);
170         return 1;
171 }
172
173
174
175
176 ScaleHeight::ScaleHeight(ScaleWin *win, ScaleMain *client, int x, int y)
177  : BC_TumbleTextBox(win, client->config.height, 0, 100000, x, y, 90)
178 {
179         this->client = client;
180         this->win = win;
181         set_increment(10);
182         enabled = 1;
183 }
184 ScaleHeight::~ScaleHeight()
185 {
186 }
187
188 int ScaleHeight::handle_event()
189 {
190         client->config.height = atoi(get_text());
191         if(client->config.type == FIXED_SIZE && enabled)
192         {
193                 client->send_configure_change();
194         }
195         return 1;
196 }
197
198 ScaleUseScale::ScaleUseScale(ScaleWin *win, ScaleMain *client, int x, int y)
199  : BC_Radial(x, y, client->config.type == FIXED_SCALE, "")
200 {
201         this->win = win;
202         this->client = client;
203         set_tooltip(_("Use fixed scale"));
204 }
205 ScaleUseScale::~ScaleUseScale()
206 {
207 }
208 int ScaleUseScale::handle_event()
209 {
210         client->set_type(FIXED_SCALE);
211         return 1;
212 }
213
214 ScaleUseSize::ScaleUseSize(ScaleWin *win, ScaleMain *client, int x, int y)
215  : BC_Radial(x, y, client->config.type == FIXED_SIZE, "")
216 {
217         this->win = win;
218         this->client = client;
219         set_tooltip(_("Use fixed size"));
220 }
221 ScaleUseSize::~ScaleUseSize()
222 {
223 }
224 int ScaleUseSize::handle_event()
225 {
226         client->set_type(FIXED_SIZE);
227         return 1;
228 }
229
230
231
232 ScaleConstrain::ScaleConstrain(ScaleMain *client, int x, int y)
233  : BC_CheckBox(x, y, client->config.constrain, _("Constrain ratio"))
234 {
235         this->client = client;
236 }
237 ScaleConstrain::~ScaleConstrain()
238 {
239 }
240 int ScaleConstrain::handle_event()
241 {
242         client->config.constrain = get_value();
243         client->send_configure_change();
244         return 1;
245 }
246