add BC_SCALE env var for hi def monitors, cleanup theme data
[goodguy/cinelerra.git] / cinelerra-5.1 / 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, xS(400), yS(100), xS(400), yS(100), 0)
33 {
34         this->client = client;
35 }
36
37 ScaleWin::~ScaleWin()
38 {
39         delete x_factor;
40         delete y_factor;
41         delete width;
42         delete height;
43 }
44
45 void ScaleWin::create_objects()
46 {
47         int xs10 = xS(10), xs15 = xS(15), xs20 = xS(20);
48         int ys10 = yS(10), ys25 = yS(25);
49         int x0 = xs10, y0 = ys10;
50         int y1 = y0 + ys25;
51         int y2 = y1 + ys25;
52         BC_Title *title = new BC_Title(x0, y1, _("Scale:"));
53         add_tool(title);
54         int x1 = x0 + title->get_w() + xs10;
55         add_tool(use_scale = new ScaleUseScale(this, client, x1, y1));
56         int x2 = x1 + use_scale->get_w() + xs10;
57         x_factor = new ScaleXFactor(this, client, x2, y1);
58         x_factor->create_objects();
59         int x3 = x2 + x_factor->get_w() + xs20;
60         y_factor = new ScaleYFactor(this, client, x3, y1);
61         y_factor->create_objects();
62         add_tool(constrain = new ScaleConstrain(client, x1, y2));
63
64
65         add_tool(new BC_Title(x0, y0, _("Size:")));
66         add_tool(use_size = new ScaleUseSize(this, client, x1, y0));
67         width = new ScaleWidth(this, client, x2, y0);
68         width->create_objects();
69         int x = x2 + width->get_w() + xS(3);
70         add_tool(new BC_Title(x, y0, _("x")));
71         height= new ScaleHeight(this, client, x3, y0);
72         height->create_objects();
73         int x4 = x3 + height->get_w() + xs15;
74         add_tool(pulldown = new FrameSizePulldown(client->server->mwindow->theme,
75                         width->get_textbox(), height->get_textbox(), x4, y0));
76
77         show_window();
78         flush();
79 }
80
81 ScaleXFactor::ScaleXFactor(ScaleWin *win,
82         ScaleMain *client, int x, int y)
83  : BC_TumbleTextBox(win, (float)client->config.x_factor, 0., 100., x, y, xS(100))
84 {
85 //printf("ScaleXFactor::ScaleXFactor %f\n", client->config.x_factor);
86         this->client = client;
87         this->win = win;
88         set_increment(0.1);
89         enabled = 1;
90 }
91
92 ScaleXFactor::~ScaleXFactor()
93 {
94 }
95
96 int ScaleXFactor::handle_event()
97 {
98         client->config.x_factor = atof(get_text());
99         CLAMP(client->config.x_factor, 0, 100);
100
101         if(client->config.constrain)
102         {
103                 client->config.y_factor = client->config.x_factor;
104                 win->y_factor->update(client->config.y_factor);
105         }
106
107 //printf("ScaleXFactor::handle_event 1 %f\n", client->config.x_factor);
108         if(client->config.type == FIXED_SCALE && enabled) {
109                 client->send_configure_change();
110         }
111         return 1;
112 }
113
114
115
116
117 ScaleYFactor::ScaleYFactor(ScaleWin *win, ScaleMain *client, int x, int y)
118  : BC_TumbleTextBox(win, (float)client->config.y_factor, 0., 100., x, y, xS(100))
119 {
120         this->client = client;
121         this->win = win;
122         set_increment(0.1);
123         enabled = 1;
124 }
125 ScaleYFactor::~ScaleYFactor()
126 {
127 }
128 int ScaleYFactor::handle_event()
129 {
130         client->config.y_factor = atof(get_text());
131         CLAMP(client->config.y_factor, 0, 100);
132
133         if(client->config.constrain)
134         {
135                 client->config.x_factor = client->config.y_factor;
136                 win->x_factor->update(client->config.x_factor);
137         }
138
139         if(client->config.type == FIXED_SCALE && enabled)
140         {
141                 client->send_configure_change();
142         }
143         return 1;
144 }
145
146
147
148 ScaleWidth::ScaleWidth(ScaleWin *win,
149         ScaleMain *client, int x, int y)
150  : BC_TumbleTextBox(win, client->config.width, 0, 100000, x, y, xS(90))
151 {
152 //printf("ScaleWidth::ScaleWidth %f\n", client->config.x_factor);
153         this->client = client;
154         this->win = win;
155         set_increment(10);
156         enabled = 1;
157 }
158
159 ScaleWidth::~ScaleWidth()
160 {
161 }
162
163 int ScaleWidth::handle_event()
164 {
165         client->config.width = atoi(get_text());
166         if(client->config.type == FIXED_SIZE && enabled)
167         {
168                 client->send_configure_change();
169         }
170 //printf("ScaleWidth::handle_event 1 %f\n", client->config.x_factor);
171         return 1;
172 }
173
174
175
176
177 ScaleHeight::ScaleHeight(ScaleWin *win, ScaleMain *client, int x, int y)
178  : BC_TumbleTextBox(win, client->config.height, 0, 100000, x, y, xS(90))
179 {
180         this->client = client;
181         this->win = win;
182         set_increment(10);
183         enabled = 1;
184 }
185 ScaleHeight::~ScaleHeight()
186 {
187 }
188
189 int ScaleHeight::handle_event()
190 {
191         client->config.height = atoi(get_text());
192         if(client->config.type == FIXED_SIZE && enabled)
193         {
194                 client->send_configure_change();
195         }
196         return 1;
197 }
198
199 ScaleUseScale::ScaleUseScale(ScaleWin *win, ScaleMain *client, int x, int y)
200  : BC_Radial(x, y, client->config.type == FIXED_SCALE, "")
201 {
202         this->win = win;
203         this->client = client;
204         set_tooltip(_("Use fixed scale"));
205 }
206 ScaleUseScale::~ScaleUseScale()
207 {
208 }
209 int ScaleUseScale::handle_event()
210 {
211         client->set_type(FIXED_SCALE);
212         return 1;
213 }
214
215 ScaleUseSize::ScaleUseSize(ScaleWin *win, ScaleMain *client, int x, int y)
216  : BC_Radial(x, y, client->config.type == FIXED_SIZE, "")
217 {
218         this->win = win;
219         this->client = client;
220         set_tooltip(_("Use fixed size"));
221 }
222 ScaleUseSize::~ScaleUseSize()
223 {
224 }
225 int ScaleUseSize::handle_event()
226 {
227         client->set_type(FIXED_SIZE);
228         return 1;
229 }
230
231
232
233 ScaleConstrain::ScaleConstrain(ScaleMain *client, int x, int y)
234  : BC_CheckBox(x, y, client->config.constrain, _("Constrain ratio"))
235 {
236         this->client = client;
237 }
238 ScaleConstrain::~ScaleConstrain()
239 {
240 }
241 int ScaleConstrain::handle_event()
242 {
243         client->config.constrain = get_value();
244         client->send_configure_change();
245         return 1;
246 }
247