4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
23 * 2019. Derivative by Translate plugin. This plugin works also with Proxy.
24 * It uses Percent values instead of Pixel value coordinates.
27 #include "bcdisplayinfo.h"
45 CropWin::CropWin(CropMain *client)
46 : PluginClientWindow(client,
53 this->client = client;
60 void CropWin::create_objects()
62 int xs10 = xS(10), xs20 = xS(20), xs200 = xS(200);
63 int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(40);
64 int x2 = xS(80), x3 = xS(180);
65 int x = xs10, y = ys10;
66 int clr_x = get_w()-x - xS(22); // note: clrBtn_w = 22
68 BC_TitleBar *title_bar;
72 add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Crop")));
74 add_tool(new BC_Title(x, y, _("Left")));
75 add_tool(new BC_Title((x2-x), y, _("%")));
76 crop_left_text = new CropLeftText(this, client, (x + x2), y);
77 crop_left_text->create_objects();
78 crop_left_slider = new CropLeftSlider(this, client, x3, y, xs200);
79 add_subwindow(crop_left_slider);
80 clr_x = x3 + crop_left_slider->get_w() + x;
81 add_subwindow(crop_left_clr = new CropEdgesClr(this, client,
82 clr_x, y, RESET_LEFT));
84 add_tool(new BC_Title(x, y, _("Top")));
85 add_tool(new BC_Title((x2-x), y, _("%")));
86 crop_top_text = new CropTopText(this, client, (x + x2), y);
87 crop_top_text->create_objects();
88 crop_top_slider = new CropTopSlider(this, client, x3, y, xs200);
89 add_subwindow(crop_top_slider);
90 add_subwindow(crop_top_clr = new CropEdgesClr(this, client,
91 clr_x, y, RESET_TOP));
93 add_tool(new BC_Title(x, y, _("Right")));
94 add_tool(new BC_Title((x2-x), y, _("%")));
95 crop_right_text = new CropRightText(this, client, (x + x2), y);
96 crop_right_text->create_objects();
97 crop_right_slider = new CropRightSlider(this, client, x3, y, xs200);
98 add_subwindow(crop_right_slider);
99 add_subwindow(crop_right_clr = new CropEdgesClr(this, client,
100 clr_x, y, RESET_RIGHT));
102 add_tool(new BC_Title(x, y, _("Bottom")));
103 add_tool(new BC_Title((x2-x), y, _("%")));
104 crop_bottom_text = new CropBottomText(this, client, (x + x2), y);
105 crop_bottom_text->create_objects();
106 crop_bottom_slider = new CropBottomSlider(this, client, x3, y, xs200);
107 add_subwindow(crop_bottom_slider);
108 add_subwindow(crop_bottom_clr = new CropEdgesClr(this, client,
109 clr_x, y, RESET_BOTTOM));
113 add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Position")));
115 add_tool(new BC_Title(x, y, _("X")));
116 add_tool(new BC_Title((x2-x), y, _("%")));
117 crop_position_x_text = new CropPositionXText(this, client, (x + x2), y);
118 crop_position_x_text->create_objects();
119 crop_position_x_slider = new CropPositionXSlider(this, client, x3, y, xs200);
120 add_subwindow(crop_position_x_slider);
121 add_subwindow(crop_position_x_clr = new CropEdgesClr(this, client,
122 clr_x, y, RESET_POSITION_X));
124 add_tool(new BC_Title(x, y, _("Y")));
125 add_tool(new BC_Title((x2-x), y, _("%")));
126 crop_position_y_text = new CropPositionYText(this, client, (x + x2), y);
127 crop_position_y_text->create_objects();
128 crop_position_y_slider = new CropPositionYSlider(this, client, x3, y, xs200);
129 add_subwindow(crop_position_y_slider);
130 add_subwindow(crop_position_y_clr = new CropEdgesClr(this, client,
131 clr_x, y, RESET_POSITION_Y));
135 add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
137 add_tool(reset = new CropReset(client, this, x, y));
143 void CropWin::update(int clear)
147 crop_left_text->update((float)client->config.crop_l);
148 crop_left_slider->update((float)client->config.crop_l);
151 crop_top_text->update((float)client->config.crop_t);
152 crop_top_slider->update((float)client->config.crop_t);
155 crop_right_text->update((float)client->config.crop_r);
156 crop_right_slider->update((float)client->config.crop_r);
159 crop_bottom_text->update((float)client->config.crop_b);
160 crop_bottom_slider->update((float)client->config.crop_b);
162 case RESET_POSITION_X :
163 crop_position_x_text->update((float)client->config.position_x);
164 crop_position_x_slider->update((float)client->config.position_x);
166 case RESET_POSITION_Y :
167 crop_position_y_text->update((float)client->config.position_y);
168 crop_position_y_slider->update((float)client->config.position_y);
171 case RESET_DEFAULT_SETTINGS :
173 crop_left_text->update((float)client->config.crop_l);
174 crop_left_slider->update((float)client->config.crop_l);
175 crop_top_text->update((float)client->config.crop_t);
176 crop_top_slider->update((float)client->config.crop_t);
177 crop_right_text->update((float)client->config.crop_r);
178 crop_right_slider->update((float)client->config.crop_r);
179 crop_bottom_text->update((float)client->config.crop_b);
180 crop_bottom_slider->update((float)client->config.crop_b);
182 crop_position_x_text->update((float)client->config.position_x);
183 crop_position_x_slider->update((float)client->config.position_x);
184 crop_position_y_text->update((float)client->config.position_y);
185 crop_position_y_slider->update((float)client->config.position_y);
196 /* *********************************** */
197 /* **** CROP LEFT ******************** */
198 CropLeftText::CropLeftText(CropWin *win,
202 : BC_TumbleTextBox(win, client->config.crop_l,
203 (float)0.00, (float)100.00, x, y, xS(60), 2)
206 this->client = client;
209 CropLeftText::~CropLeftText()
213 int CropLeftText::handle_event()
215 client->config.crop_l = atof(get_text());
216 win->crop_left_slider->update(client->config.crop_l);
217 client->send_configure_change();
221 CropLeftSlider::CropLeftSlider(CropWin *win, CropMain *client,
223 : BC_FSlider(x, y, 0, w, w, 0.00, 100.00, client->config.crop_l)
226 this->client = client;
227 enable_show_value(0); // Hide caption
231 CropLeftSlider::~CropLeftSlider()
235 int CropLeftSlider::handle_event()
237 client->config.crop_l = get_value();
238 win->crop_left_text->update(client->config.crop_l);
239 win->update(RESET_ALL);
240 client->send_configure_change();
243 /* *********************************** */
245 /* *********************************** */
246 /* **** CROP TOP ******************** */
247 CropTopText::CropTopText(CropWin *win,
251 : BC_TumbleTextBox(win, client->config.crop_t,
252 (float)0.00, (float)100.00, x, y, xS(60), 2)
255 this->client = client;
258 CropTopText::~CropTopText()
262 int CropTopText::handle_event()
264 client->config.crop_t = atof(get_text());
265 win->crop_top_slider->update(client->config.crop_t);
266 client->send_configure_change();
270 CropTopSlider::CropTopSlider(CropWin *win, CropMain *client,
272 : BC_FSlider(x, y, 0, w, w, 0.00, 100.00, client->config.crop_t)
275 this->client = client;
276 enable_show_value(0); // Hide caption
280 CropTopSlider::~CropTopSlider()
284 int CropTopSlider::handle_event()
286 client->config.crop_t = get_value();
287 win->crop_top_text->update(client->config.crop_t);
288 win->update(RESET_ALL);
289 client->send_configure_change();
292 /* *********************************** */
294 /* *********************************** */
295 /* **** CROP RIGHT ******************* */
296 CropRightText::CropRightText(CropWin *win, CropMain *client,
299 : BC_TumbleTextBox(win, client->config.crop_r,
300 (float)0.00, (float)100.00, x, y, xS(60), 2)
303 this->client = client;
306 CropRightText::~CropRightText()
310 int CropRightText::handle_event()
312 client->config.crop_r = atof(get_text());
313 win->crop_right_slider->update(client->config.crop_r);
314 client->send_configure_change();
318 CropRightSlider::CropRightSlider(CropWin *win, CropMain *client,
320 : BC_FSlider(x, y, 0, w, w, 0.00, 100.00, client->config.crop_r)
323 this->client = client;
324 enable_show_value(0); // Hide caption
328 CropRightSlider::~CropRightSlider()
332 int CropRightSlider::handle_event()
334 client->config.crop_r = get_value();
335 win->crop_right_text->update(client->config.crop_r);
336 win->update(RESET_ALL);
337 client->send_configure_change();
340 /* *********************************** */
342 /* *********************************** */
343 /* **** CROP BOTTOM ****************** */
344 CropBottomText::CropBottomText(CropWin *win, CropMain *client,
347 : BC_TumbleTextBox(win, client->config.crop_b,
348 (float)0.00, (float)100.00, x, y, xS(60), 2)
351 this->client = client;
354 CropBottomText::~CropBottomText()
358 int CropBottomText::handle_event()
360 client->config.crop_b = atof(get_text());
361 win->crop_bottom_slider->update(client->config.crop_b);
362 client->send_configure_change();
366 CropBottomSlider::CropBottomSlider(CropWin *win, CropMain *client,
368 : BC_FSlider(x, y, 0, w, w, 0.00, 100.00, client->config.crop_b)
371 this->client = client;
372 enable_show_value(0); // Hide caption
376 CropBottomSlider::~CropBottomSlider()
380 int CropBottomSlider::handle_event()
382 client->config.crop_b = get_value();
383 win->crop_bottom_text->update(client->config.crop_b);
384 win->update(RESET_ALL);
385 client->send_configure_change();
388 /* *********************************** */
390 /* *********************************** */
391 /* **** CROP POSITION X ************** */
392 CropPositionXText::CropPositionXText(CropWin *win, CropMain *client,
395 : BC_TumbleTextBox(win, client->config.position_x,
396 (float)-100.00, (float)100.00, x, y, xS(60), 2)
399 this->client = client;
402 CropPositionXText::~CropPositionXText()
406 int CropPositionXText::handle_event()
408 client->config.position_x = atof(get_text());
409 win->crop_position_x_slider->update(client->config.position_x);
410 client->send_configure_change();
414 CropPositionXSlider::CropPositionXSlider(CropWin *win, CropMain *client,
416 : BC_FSlider(x, y, 0, w, w, -100.00, 100.00, client->config.position_x)
419 this->client = client;
420 enable_show_value(0); // Hide caption
424 CropPositionXSlider::~CropPositionXSlider()
428 int CropPositionXSlider::handle_event()
430 client->config.position_x = get_value();
431 win->crop_position_x_text->update(client->config.position_x);
432 win->update(RESET_ALL);
433 client->send_configure_change();
436 /* *********************************** */
438 /* *********************************** */
439 /* **** CROP POSITION Y ************** */
440 CropPositionYText::CropPositionYText(CropWin *win, CropMain *client,
443 : BC_TumbleTextBox(win, client->config.position_y,
444 (float)-100.00, (float)100.00, x, y, xS(60), 2)
447 this->client = client;
450 CropPositionYText::~CropPositionYText()
454 int CropPositionYText::handle_event()
456 client->config.position_y = atof(get_text());
457 win->crop_position_y_slider->update(client->config.position_y);
458 client->send_configure_change();
462 CropPositionYSlider::CropPositionYSlider(CropWin *win, CropMain *client,
464 : BC_FSlider(x, y, 0, w, w, -100.00, 100.00, client->config.position_y)
467 this->client = client;
468 enable_show_value(0); // Hide caption
472 CropPositionYSlider::~CropPositionYSlider()
476 int CropPositionYSlider::handle_event()
478 client->config.position_y = get_value();
479 win->crop_position_y_text->update(client->config.position_y);
480 win->update(RESET_ALL);
481 client->send_configure_change();
484 /* *********************************** */
487 CropEdgesClr::CropEdgesClr(CropWin *win, CropMain *client, int x, int y, int clear)
488 : BC_Button(x, y, client->get_theme()->get_image_set("reset_button"))
491 this->client = client;
494 CropEdgesClr::~CropEdgesClr()
497 int CropEdgesClr::handle_event()
499 client->config.reset(clear);
501 client->send_configure_change();
505 CropReset::CropReset(CropMain *client, CropWin *win, int x, int y)
506 : BC_GenericButton(x, y, _("Reset"))
508 this->client = client;
512 CropReset::~CropReset()
516 int CropReset::handle_event()
518 client->config.reset(RESET_ALL);
519 win->update(RESET_ALL);
520 client->send_configure_change();