4 * Copyright (C) 2010 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
22 #include "bcdisplayinfo.h"
24 #include "blurwindow.h"
32 BlurWindow::BlurWindow(BlurMain *client)
33 : PluginClientWindow(client,
40 this->client = client;
43 BlurWindow::~BlurWindow()
45 //printf("BlurWindow::~BlurWindow 1\n");
48 void BlurWindow::create_objects()
50 int xs10 = xS(10), xs20 = xS(20), xs200 = xS(200);
51 int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(40);
52 int x2 = xS(80), x3 = xS(180);
53 int x = xs10, y = ys10;
54 int clr_x = get_w()-x - xS(22); // note: clrBtn_w = 22
56 BC_TitleBar *title_bar;
59 add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Radius")));
61 add_subwindow(new BC_Title(x, y, _("Radius:")));
62 radius_text = new BlurRadiusText(client, this, (x + x2), y);
63 radius_text->create_objects();
64 add_subwindow(radius_slider = new BlurRadiusSlider(client, this, x3, y, xs200));
65 clr_x = x3 + radius_slider->get_w() + x;
66 add_subwindow(radius_Clr = new BlurRadiusClr(client, this, clr_x, y));
67 // December 2021: Disable and Hide 'Alpha determines radius' checkbox for bug(?)
69 add_subwindow(a_key = new BlurAKey(client, x, y));
72 add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Direction")));
74 add_subwindow(horizontal = new BlurHorizontal(client, this, x, y));
76 add_subwindow(vertical = new BlurVertical(client, this, x, y));
79 add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Color channel")));
82 int toggle_w = (get_w()-2*x) / 4;
83 add_subwindow(r = new BlurR(client, x1, y));
85 add_subwindow(g = new BlurG(client, x1, y));
87 add_subwindow(b = new BlurB(client, x1, y));
89 add_subwindow(a = new BlurA(client, x1, y));
93 add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
95 add_subwindow(reset = new BlurReset(client, this, x, y));
99 // December 2021: Disable and Hide 'Alpha determines radius' checkbox for bug(?)
101 a_key->hide_window();
107 void BlurWindow::update(int clear)
111 radius_slider->update(client->config.radius);
112 radius_text->update((int64_t)client->config.radius);
116 horizontal->update(client->config.horizontal);
117 vertical->update(client->config.vertical);
118 radius_slider->update(client->config.radius);
119 radius_text->update((int64_t)client->config.radius);
120 a_key->update(client->config.a_key);
121 a->update(client->config.a);
122 r->update(client->config.r);
123 g->update(client->config.g);
124 b->update(client->config.b);
130 BlurRadiusSlider::BlurRadiusSlider(BlurMain *client, BlurWindow *gui, int x, int y, int w)
131 : BC_ISlider(x, y, 0, w, w, 0, MAXRADIUS, client->config.radius, 0, 0, 0)
133 this->client = client;
135 enable_show_value(0); // Hide caption
137 BlurRadiusSlider::~BlurRadiusSlider()
140 int BlurRadiusSlider::handle_event()
142 client->config.radius = get_value();
143 gui->radius_text->update((int64_t)client->config.radius);
144 client->send_configure_change();
151 BlurRadiusText::BlurRadiusText(BlurMain *client, BlurWindow *gui, int x, int y)
152 : BC_TumbleTextBox(gui, client->config.radius,
153 0, MAXRADIUS, x, y, xS(60), 0)
155 this->client = client;
159 BlurRadiusText::~BlurRadiusText()
162 int BlurRadiusText::handle_event()
164 client->config.radius = atoi(get_text());
165 if(client->config.radius > MAXRADIUS) client->config.radius = MAXRADIUS;
166 else if(client->config.radius < 0) client->config.radius = 0;
167 gui->radius_text->update((int64_t)client->config.radius);
168 gui->radius_slider->update(client->config.radius);
169 client->send_configure_change();
176 BlurVertical::BlurVertical(BlurMain *client, BlurWindow *window, int x, int y)
179 client->config.vertical,
182 this->client = client;
183 this->window = window;
185 BlurVertical::~BlurVertical()
188 int BlurVertical::handle_event()
190 client->config.vertical = get_value();
191 client->send_configure_change();
195 BlurHorizontal::BlurHorizontal(BlurMain *client, BlurWindow *window, int x, int y)
198 client->config.horizontal,
201 this->client = client;
202 this->window = window;
204 BlurHorizontal::~BlurHorizontal()
207 int BlurHorizontal::handle_event()
209 client->config.horizontal = get_value();
210 client->send_configure_change();
217 BlurA::BlurA(BlurMain *client, int x, int y)
218 : BC_CheckBox(x, y, client->config.a, _("Alpha"))
220 this->client = client;
222 int BlurA::handle_event()
224 client->config.a = get_value();
225 client->send_configure_change();
232 BlurAKey::BlurAKey(BlurMain *client, int x, int y)
233 : BC_CheckBox(x, y, client->config.a_key, _("Alpha determines radius"))
235 this->client = client;
237 int BlurAKey::handle_event()
239 client->config.a_key = get_value();
240 client->send_configure_change();
244 BlurR::BlurR(BlurMain *client, int x, int y)
245 : BC_CheckBox(x, y, client->config.r, _("Red"))
247 this->client = client;
249 int BlurR::handle_event()
251 client->config.r = get_value();
252 client->send_configure_change();
256 BlurG::BlurG(BlurMain *client, int x, int y)
257 : BC_CheckBox(x, y, client->config.g, _("Green"))
259 this->client = client;
261 int BlurG::handle_event()
263 client->config.g = get_value();
264 client->send_configure_change();
268 BlurB::BlurB(BlurMain *client, int x, int y)
269 : BC_CheckBox(x, y, client->config.b, _("Blue"))
271 this->client = client;
273 int BlurB::handle_event()
275 client->config.b = get_value();
276 client->send_configure_change();
280 BlurReset::BlurReset(BlurMain *client, BlurWindow *window, int x, int y)
281 : BC_GenericButton(x, y, _("Reset"))
283 this->client = client;
284 this->window = window;
286 BlurReset::~BlurReset()
289 int BlurReset::handle_event()
291 client->config.reset(RESET_ALL);
292 window->update(RESET_ALL);
293 client->send_configure_change();
297 BlurRadiusClr::BlurRadiusClr(BlurMain *client, BlurWindow *gui, int x, int y)
298 : BC_Button(x, y, client->get_theme()->get_image_set("reset_button"))
300 this->client = client;
303 BlurRadiusClr::~BlurRadiusClr()
306 int BlurRadiusClr::handle_event()
308 client->config.reset(RESET_RADIUS);
309 gui->update(RESET_RADIUS);
310 client->send_configure_change();