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 * 2023. Derivative by Flip plugin.
26 #include "bcdisplayinfo.h"
27 #include "mirrorwindow.h"
37 MirrorWindow::MirrorWindow(MirrorMain *client)
38 : PluginClientWindow(client, xS(420), yS(270), xS(420), yS(270), 0)
40 this->client = client;
43 MirrorWindow::~MirrorWindow()
45 delete mirror_horizontal;
46 delete mirror_swaphorizontal;
47 delete mirror_vertical;
48 delete mirror_swapvertical;
49 delete reflection_center_enable;
50 delete reflection_center_x_text;
51 delete reflection_center_x_slider;
52 delete reflection_center_y_text;
53 delete reflection_center_y_slider;
54 delete reflection_center_x_clr;
55 delete reflection_center_y_clr;
59 void MirrorWindow::create_objects()
61 int xs10 = xS(10), xs20 = xS(20), xs200 = xS(200);
62 int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(40);
63 int x2 = xS(60), x3 = xS(180);
64 int x = xs10, y = ys10;
65 int clr_x = get_w()-x - xS(22); // note: clrBtn_w = 22
67 BC_TitleBar *title_bar;
72 add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Direction")));
74 add_tool(mirror_horizontal = new MirrorToggle(client,
75 &(client->config.mirror_horizontal),
79 add_tool(mirror_swaphorizontal = new MirrorSwapSide(client,
80 &(client->config.mirror_swaphorizontal),
81 _("Swap LEFT-RIGHT side"),
85 add_tool(mirror_vertical = new MirrorToggle(client,
86 &(client->config.mirror_vertical),
90 add_tool(mirror_swapvertical = new MirrorSwapSide(client,
91 &(client->config.mirror_swapvertical),
92 _("Swap TOP-BOTTOM side"),
96 add_tool(reflection_center_enable = new MirrorReflectionCenter(this, client, x, y));
99 // Reflection Center section
100 add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Reflection Center")));
102 add_tool(new BC_Title(x, y, _("X")));
103 add_tool(new BC_Title((x2-x), y, _("%")));
104 reflection_center_x_text = new MirrorReflectionCenterXText(this, client, (x + x2), y);
105 reflection_center_x_text->create_objects();
106 reflection_center_x_slider = new MirrorReflectionCenterXSlider(this, client, x3, y, xs200);
107 add_subwindow(reflection_center_x_slider);
108 add_subwindow(reflection_center_x_clr = new MirrorReflectionCenterClr(this, client,
109 clr_x, y, RESET_REFLECTION_CENTER_X));
111 add_tool(new BC_Title(x, y, _("Y")));
112 add_tool(new BC_Title((x2-x), y, _("%")));
113 reflection_center_y_text = new MirrorReflectionCenterYText(this, client, (x + x2), y);
114 reflection_center_y_text->create_objects();
115 reflection_center_y_slider = new MirrorReflectionCenterYSlider(this, client, x3, y, xs200);
116 add_subwindow(reflection_center_y_slider);
117 add_subwindow(reflection_center_y_clr = new MirrorReflectionCenterClr(this, client,
118 clr_x, y, RESET_REFLECTION_CENTER_Y));
122 add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
124 add_tool(reset = new MirrorReset(client, this, x, y));
128 // Needed to update Enable-Disable GUI when "Show controls" is pressed.
129 update_reflection_center_enable();
133 void MirrorWindow::update_reflection_center_enable()
135 if(client->config.reflection_center_enable)
137 reflection_center_x_text->enable();
138 reflection_center_x_slider->enable();
139 reflection_center_x_clr->enable();
140 reflection_center_y_text->enable();
141 reflection_center_y_slider->enable();
142 reflection_center_y_clr->enable();
143 mirror_swaphorizontal->disable();
144 mirror_swaphorizontal->hide_window();
145 mirror_swapvertical->disable();
146 mirror_swapvertical->hide_window();
150 reflection_center_x_text->disable();
151 reflection_center_x_slider->disable();
152 reflection_center_x_clr->disable();
153 reflection_center_y_text->disable();
154 reflection_center_y_slider->disable();
155 reflection_center_y_clr->disable();
156 mirror_swaphorizontal->enable();
157 mirror_swaphorizontal->show_window();
158 mirror_swapvertical->enable();
159 mirror_swapvertical->show_window();
163 void MirrorWindow::update(int clear)
166 case RESET_REFLECTION_CENTER_X :
167 reflection_center_x_text->update((float)client->config.reflection_center_x);
168 reflection_center_x_slider->update((float)client->config.reflection_center_x);
169 mirror_horizontal->update(client->config.mirror_horizontal);
170 mirror_swaphorizontal->update(client->config.mirror_swaphorizontal);
172 case RESET_REFLECTION_CENTER_Y :
173 reflection_center_y_text->update((float)client->config.reflection_center_y);
174 reflection_center_y_slider->update((float)client->config.reflection_center_y);
175 mirror_vertical->update(client->config.mirror_vertical);
176 mirror_swapvertical->update(client->config.mirror_swapvertical);
179 case RESET_DEFAULT_SETTINGS :
181 mirror_horizontal->update(client->config.mirror_horizontal);
182 mirror_swaphorizontal->update(client->config.mirror_swaphorizontal);
183 mirror_vertical->update(client->config.mirror_vertical);
184 mirror_swapvertical->update(client->config.mirror_swapvertical);
185 reflection_center_enable->update(client->config.reflection_center_enable);
186 reflection_center_x_text->update((float)client->config.reflection_center_x);
187 reflection_center_x_slider->update((float)client->config.reflection_center_x);
188 reflection_center_y_text->update((float)client->config.reflection_center_y);
189 reflection_center_y_slider->update((float)client->config.reflection_center_y);
194 MirrorToggle::MirrorToggle(MirrorMain *client, int *output, char *string, int x, int y)
195 : BC_CheckBox(x, y, *output, string)
197 this->client = client;
198 this->output = output;
200 MirrorToggle::~MirrorToggle()
203 int MirrorToggle::handle_event()
205 *output = get_value();
206 client->send_configure_change();
210 MirrorSwapSide::MirrorSwapSide(MirrorMain *client, int *output, char *string, int x, int y)
211 : BC_CheckBox(x, y, *output, string)
213 this->client = client;
214 this->output = output;
216 MirrorSwapSide::~MirrorSwapSide()
219 int MirrorSwapSide::handle_event()
221 *output = get_value();
222 client->send_configure_change();
226 MirrorReflectionCenter::MirrorReflectionCenter(MirrorWindow *window, MirrorMain *client, int x, int y)
227 : BC_CheckBox(x, y, client->config.reflection_center_enable, _("Enable Reflection Center"))
229 this->window = window;
230 this->client = client;
232 MirrorReflectionCenter::~MirrorReflectionCenter()
235 int MirrorReflectionCenter::handle_event()
237 client->config.reflection_center_enable = get_value();
239 if(client->config.reflection_center_enable)
241 window->reflection_center_x_text->enable();
242 window->reflection_center_x_slider->enable();
243 window->reflection_center_x_clr->enable();
244 window->reflection_center_y_text->enable();
245 window->reflection_center_y_slider->enable();
246 window->reflection_center_y_clr->enable();
248 window->mirror_swaphorizontal->disable();
249 window->mirror_swaphorizontal->hide_window();
250 window->mirror_swapvertical->disable();
251 window->mirror_swapvertical->hide_window();
253 window->reflection_center_x_text->update(client->config.reflection_center_x);
254 window->reflection_center_x_slider->update(client->config.reflection_center_x);
255 window->reflection_center_y_text->update(client->config.reflection_center_y);
256 window->reflection_center_y_slider->update(client->config.reflection_center_y);
257 window->mirror_swaphorizontal->update(client->config.mirror_swaphorizontal);
258 window->mirror_swapvertical->update(client->config.mirror_swapvertical);
262 window->reflection_center_x_text->disable();
263 window->reflection_center_x_slider->disable();
264 window->reflection_center_x_clr->disable();
265 window->reflection_center_y_text->disable();
266 window->reflection_center_y_slider->disable();
267 window->reflection_center_y_clr->disable();
269 window->mirror_swaphorizontal->enable();
270 window->mirror_swaphorizontal->show_window();
271 window->mirror_swapvertical->enable();
272 window->mirror_swapvertical->show_window();
274 window->reflection_center_x_text->update(client->config.reflection_center_x);
275 window->reflection_center_x_slider->update(client->config.reflection_center_x);
276 window->reflection_center_y_text->update(client->config.reflection_center_y);
277 window->reflection_center_y_slider->update(client->config.reflection_center_y);
278 window->mirror_swaphorizontal->update(client->config.mirror_swaphorizontal);
279 window->mirror_swapvertical->update(client->config.mirror_swapvertical);
281 client->send_configure_change();
285 /* ********************************************** */
286 /* **** MIRROR REFLECTION CENTER X ************** */
287 MirrorReflectionCenterXText::MirrorReflectionCenterXText(MirrorWindow *window, MirrorMain *client,
290 : BC_TumbleTextBox(window, client->config.reflection_center_x,
291 (float)0.00, (float)100.00, x, y, xS(60), 2)
293 this->window = window;
294 this->client = client;
297 MirrorReflectionCenterXText::~MirrorReflectionCenterXText()
301 int MirrorReflectionCenterXText::handle_event()
303 client->config.reflection_center_x = atof(get_text());
304 if(client->config.reflection_center_x > 100.00) client->config.reflection_center_x = 100.00;
305 else if(client->config.reflection_center_x < 0.00) client->config.reflection_center_x = 0.00;
306 window->reflection_center_x_text->update(client->config.reflection_center_x);
307 window->reflection_center_x_slider->update(client->config.reflection_center_x);
308 client->send_configure_change();
312 MirrorReflectionCenterXSlider::MirrorReflectionCenterXSlider(MirrorWindow *window, MirrorMain *client,
314 : BC_FSlider(x, y, 0, w, w, 0.00, 100.00, client->config.reflection_center_x)
316 this->window = window;
317 this->client = client;
318 enable_show_value(0); // Hide caption
322 MirrorReflectionCenterXSlider::~MirrorReflectionCenterXSlider()
326 int MirrorReflectionCenterXSlider::handle_event()
328 client->config.reflection_center_x = get_value();
329 window->reflection_center_x_text->update(client->config.reflection_center_x);
330 window->update(RESET_ALL);
331 client->send_configure_change();
334 /* ********************************************** */
336 /* ********************************************** */
337 /* **** MIRROR REFLECTION CENTER Y ************** */
338 MirrorReflectionCenterYText::MirrorReflectionCenterYText(MirrorWindow *window, MirrorMain *client,
341 : BC_TumbleTextBox(window, client->config.reflection_center_y,
342 (float)0.00, (float)100.00, x, y, xS(60), 2)
344 this->window = window;
345 this->client = client;
348 MirrorReflectionCenterYText::~MirrorReflectionCenterYText()
352 int MirrorReflectionCenterYText::handle_event()
354 client->config.reflection_center_y = atof(get_text());
355 if(client->config.reflection_center_y > 100.00) client->config.reflection_center_y = 100.00;
356 else if(client->config.reflection_center_y < 0.00) client->config.reflection_center_y = 0.00;
357 window->reflection_center_y_text->update(client->config.reflection_center_y);
358 window->reflection_center_y_slider->update(client->config.reflection_center_y);
359 client->send_configure_change();
363 MirrorReflectionCenterYSlider::MirrorReflectionCenterYSlider(MirrorWindow *window, MirrorMain *client,
365 : BC_FSlider(x, y, 0, w, w, 0.00, 100.00, client->config.reflection_center_y)
367 this->window = window;
368 this->client = client;
369 enable_show_value(0); // Hide caption
373 MirrorReflectionCenterYSlider::~MirrorReflectionCenterYSlider()
377 int MirrorReflectionCenterYSlider::handle_event()
379 client->config.reflection_center_y = get_value();
380 window->reflection_center_y_text->update(client->config.reflection_center_y);
381 window->update(RESET_ALL);
382 client->send_configure_change();
385 /* ********************************************** */
388 MirrorReflectionCenterClr::MirrorReflectionCenterClr(MirrorWindow *window, MirrorMain *client, int x, int y, int clear)
389 : BC_Button(x, y, client->get_theme()->get_image_set("reset_button"))
391 this->window = window;
392 this->client = client;
395 MirrorReflectionCenterClr::~MirrorReflectionCenterClr()
398 int MirrorReflectionCenterClr::handle_event()
400 client->config.reset(clear);
401 window->update(clear);
402 client->send_configure_change();
406 MirrorReset::MirrorReset(MirrorMain *client, MirrorWindow *window, int x, int y)
407 : BC_GenericButton(x, y, _("Reset"))
409 this->client = client;
410 this->window = window;
413 MirrorReset::~MirrorReset()
417 int MirrorReset::handle_event()
419 client->config.reset(RESET_ALL);
420 window->update_reflection_center_enable();
421 window->update(RESET_ALL);
422 client->send_configure_change();