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 x = 10, x1 = 40, x2 = 80, x_middle= (get_w() / 2), x3 = 180;
64 int clr_x = get_w()-x - 22; // note: clrBtn_w = 22
66 BC_TitleBar *title_bar;
70 add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, 20, 10, _("Crop")));
72 add_tool(new BC_Title(x, y, _("Left")));
73 add_tool(new BC_Title((x2-x), y, _("%")));
74 crop_left_text = new CropLeftText(this, client, (x + x2), y);
75 crop_left_text->create_objects();
76 crop_left_slider = new CropLeftSlider(this, client, x3, y, 200);
77 add_subwindow(crop_left_slider);
78 clr_x = x3 + crop_left_slider->get_w() + x;
79 add_subwindow(crop_left_clr = new CropEdgesClr(this, client,
80 clr_x, y, RESET_LEFT));
82 add_tool(new BC_Title(x, y, _("Top")));
83 add_tool(new BC_Title((x2-x), y, _("%")));
84 crop_top_text = new CropTopText(this, client, (x + x2), y);
85 crop_top_text->create_objects();
86 crop_top_slider = new CropTopSlider(this, client, x3, y, 200);
87 add_subwindow(crop_top_slider);
88 add_subwindow(crop_top_clr = new CropEdgesClr(this, client,
89 clr_x, y, RESET_TOP));
91 add_tool(new BC_Title(x, y, _("Right")));
92 add_tool(new BC_Title((x2-x), y, _("%")));
93 crop_right_text = new CropRightText(this, client, (x + x2), y);
94 crop_right_text->create_objects();
95 crop_right_slider = new CropRightSlider(this, client, x3, y, 200);
96 add_subwindow(crop_right_slider);
97 add_subwindow(crop_right_clr = new CropEdgesClr(this, client,
98 clr_x, y, RESET_RIGHT));
100 add_tool(new BC_Title(x, y, _("Bottom")));
101 add_tool(new BC_Title((x2-x), y, _("%")));
102 crop_bottom_text = new CropBottomText(this, client, (x + x2), y);
103 crop_bottom_text->create_objects();
104 crop_bottom_slider = new CropBottomSlider(this, client, x3, y, 200);
105 add_subwindow(crop_bottom_slider);
106 add_subwindow(crop_bottom_clr = new CropEdgesClr(this, client,
107 clr_x, y, RESET_BOTTOM));
111 add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, 20, 10, _("Position")));
113 add_tool(new BC_Title(x, y, _("X")));
114 add_tool(new BC_Title((x2-x), y, _("%")));
115 crop_position_x_text = new CropPositionXText(this, client, (x + x2), y);
116 crop_position_x_text->create_objects();
117 crop_position_x_slider = new CropPositionXSlider(this, client, x3, y, 200);
118 add_subwindow(crop_position_x_slider);
119 add_subwindow(crop_position_x_clr = new CropEdgesClr(this, client,
120 clr_x, y, RESET_POSITION_X));
122 add_tool(new BC_Title(x, y, _("Y")));
123 add_tool(new BC_Title((x2-x), y, _("%")));
124 crop_position_y_text = new CropPositionYText(this, client, (x + x2), y);
125 crop_position_y_text->create_objects();
126 crop_position_y_slider = new CropPositionYSlider(this, client, x3, y, 200);
127 add_subwindow(crop_position_y_slider);
128 add_subwindow(crop_position_y_clr = new CropEdgesClr(this, client,
129 clr_x, y, RESET_POSITION_Y));
133 add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
135 add_tool(reset = new CropReset(client, this, x, y));
141 void CropWin::update(int clear)
145 crop_left_text->update((float)client->config.crop_l);
146 crop_left_slider->update((float)client->config.crop_l);
149 crop_top_text->update((float)client->config.crop_t);
150 crop_top_slider->update((float)client->config.crop_t);
153 crop_right_text->update((float)client->config.crop_r);
154 crop_right_slider->update((float)client->config.crop_r);
157 crop_bottom_text->update((float)client->config.crop_b);
158 crop_bottom_slider->update((float)client->config.crop_b);
160 case RESET_POSITION_X :
161 crop_position_x_text->update((float)client->config.position_x);
162 crop_position_x_slider->update((float)client->config.position_x);
164 case RESET_POSITION_Y :
165 crop_position_y_text->update((float)client->config.position_y);
166 crop_position_y_slider->update((float)client->config.position_y);
169 case RESET_DEFAULT_SETTINGS :
171 crop_left_text->update((float)client->config.crop_l);
172 crop_left_slider->update((float)client->config.crop_l);
173 crop_top_text->update((float)client->config.crop_t);
174 crop_top_slider->update((float)client->config.crop_t);
175 crop_right_text->update((float)client->config.crop_r);
176 crop_right_slider->update((float)client->config.crop_r);
177 crop_bottom_text->update((float)client->config.crop_b);
178 crop_bottom_slider->update((float)client->config.crop_b);
180 crop_position_x_text->update((float)client->config.position_x);
181 crop_position_x_slider->update((float)client->config.position_x);
182 crop_position_y_text->update((float)client->config.position_y);
183 crop_position_y_slider->update((float)client->config.position_y);
194 /* *********************************** */
195 /* **** CROP LEFT ******************** */
196 CropLeftText::CropLeftText(CropWin *win,
200 : BC_TumbleTextBox(win,
201 client->config.crop_l,
209 this->client = client;
212 CropLeftText::~CropLeftText()
216 int CropLeftText::handle_event()
218 client->config.crop_l = atof(get_text());
219 win->crop_left_slider->update(client->config.crop_l);
220 client->send_configure_change();
224 CropLeftSlider::CropLeftSlider(CropWin *win, CropMain *client,
226 : BC_FSlider(x, y, 0, w, w, 0.00, 100.00, client->config.crop_l)
229 this->client = client;
230 enable_show_value(0); // Hide caption
234 CropLeftSlider::~CropLeftSlider()
238 int CropLeftSlider::handle_event()
240 client->config.crop_l = get_value();
241 win->crop_left_text->update(client->config.crop_l);
242 win->update(RESET_ALL);
243 client->send_configure_change();
246 /* *********************************** */
248 /* *********************************** */
249 /* **** CROP TOP ******************** */
250 CropTopText::CropTopText(CropWin *win,
254 : BC_TumbleTextBox(win,
255 client->config.crop_t,
263 this->client = client;
266 CropTopText::~CropTopText()
270 int CropTopText::handle_event()
272 client->config.crop_t = atof(get_text());
273 win->crop_top_slider->update(client->config.crop_t);
274 client->send_configure_change();
278 CropTopSlider::CropTopSlider(CropWin *win, CropMain *client,
280 : BC_FSlider(x, y, 0, w, w, 0.00, 100.00, client->config.crop_t)
283 this->client = client;
284 enable_show_value(0); // Hide caption
288 CropTopSlider::~CropTopSlider()
292 int CropTopSlider::handle_event()
294 client->config.crop_t = get_value();
295 win->crop_top_text->update(client->config.crop_t);
296 win->update(RESET_ALL);
297 client->send_configure_change();
300 /* *********************************** */
302 /* *********************************** */
303 /* **** CROP RIGHT ******************* */
304 CropRightText::CropRightText(CropWin *win, CropMain *client,
307 : BC_TumbleTextBox(win,
308 client->config.crop_r,
316 this->client = client;
319 CropRightText::~CropRightText()
323 int CropRightText::handle_event()
325 client->config.crop_r = atof(get_text());
326 win->crop_right_slider->update(client->config.crop_r);
327 client->send_configure_change();
331 CropRightSlider::CropRightSlider(CropWin *win, CropMain *client,
333 : BC_FSlider(x, y, 0, w, w, 0.00, 100.00, client->config.crop_r)
336 this->client = client;
337 enable_show_value(0); // Hide caption
341 CropRightSlider::~CropRightSlider()
345 int CropRightSlider::handle_event()
347 client->config.crop_r = get_value();
348 win->crop_right_text->update(client->config.crop_r);
349 win->update(RESET_ALL);
350 client->send_configure_change();
353 /* *********************************** */
355 /* *********************************** */
356 /* **** CROP BOTTOM ****************** */
357 CropBottomText::CropBottomText(CropWin *win, CropMain *client,
360 : BC_TumbleTextBox(win,
361 client->config.crop_b,
369 this->client = client;
372 CropBottomText::~CropBottomText()
376 int CropBottomText::handle_event()
378 client->config.crop_b = atof(get_text());
379 win->crop_bottom_slider->update(client->config.crop_b);
380 client->send_configure_change();
384 CropBottomSlider::CropBottomSlider(CropWin *win, CropMain *client,
386 : BC_FSlider(x, y, 0, w, w, 0.00, 100.00, client->config.crop_b)
389 this->client = client;
390 enable_show_value(0); // Hide caption
394 CropBottomSlider::~CropBottomSlider()
398 int CropBottomSlider::handle_event()
400 client->config.crop_b = get_value();
401 win->crop_bottom_text->update(client->config.crop_b);
402 win->update(RESET_ALL);
403 client->send_configure_change();
406 /* *********************************** */
408 /* *********************************** */
409 /* **** CROP POSITION X ************** */
410 CropPositionXText::CropPositionXText(CropWin *win, CropMain *client,
413 : BC_TumbleTextBox(win,
414 client->config.position_x,
422 this->client = client;
425 CropPositionXText::~CropPositionXText()
429 int CropPositionXText::handle_event()
431 client->config.position_x = atof(get_text());
432 win->crop_position_x_slider->update(client->config.position_x);
433 client->send_configure_change();
437 CropPositionXSlider::CropPositionXSlider(CropWin *win, CropMain *client,
439 : BC_FSlider(x, y, 0, w, w, -100.00, 100.00, client->config.position_x)
442 this->client = client;
443 enable_show_value(0); // Hide caption
447 CropPositionXSlider::~CropPositionXSlider()
451 int CropPositionXSlider::handle_event()
453 client->config.position_x = get_value();
454 win->crop_position_x_text->update(client->config.position_x);
455 win->update(RESET_ALL);
456 client->send_configure_change();
459 /* *********************************** */
461 /* *********************************** */
462 /* **** CROP POSITION Y ************** */
463 CropPositionYText::CropPositionYText(CropWin *win, CropMain *client,
466 : BC_TumbleTextBox(win,
467 client->config.position_y,
475 this->client = client;
478 CropPositionYText::~CropPositionYText()
482 int CropPositionYText::handle_event()
484 client->config.position_y = atof(get_text());
485 win->crop_position_y_slider->update(client->config.position_y);
486 client->send_configure_change();
490 CropPositionYSlider::CropPositionYSlider(CropWin *win, CropMain *client,
492 : BC_FSlider(x, y, 0, w, w, -100.00, 100.00, client->config.position_y)
495 this->client = client;
496 enable_show_value(0); // Hide caption
500 CropPositionYSlider::~CropPositionYSlider()
504 int CropPositionYSlider::handle_event()
506 client->config.position_y = get_value();
507 win->crop_position_y_text->update(client->config.position_y);
508 win->update(RESET_ALL);
509 client->send_configure_change();
512 /* *********************************** */
515 CropEdgesClr::CropEdgesClr(CropWin *win, CropMain *client, int x, int y, int clear)
516 : BC_Button(x, y, client->get_theme()->get_image_set("reset_button"))
519 this->client = client;
522 CropEdgesClr::~CropEdgesClr()
525 int CropEdgesClr::handle_event()
527 client->config.reset(clear);
529 client->send_configure_change();
533 CropReset::CropReset(CropMain *client, CropWin *win, int x, int y)
534 : BC_GenericButton(x, y, _("Reset"))
536 this->client = client;
540 CropReset::~CropReset()
544 int CropReset::handle_event()
546 client->config.reset(RESET_ALL);
547 win->update(RESET_ALL);
548 client->send_configure_change();