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
22 #include "bcdisplayinfo.h"
26 #include "unsharpwindow.h"
29 UnsharpWindow::UnsharpWindow(UnsharpMain *plugin)
30 : PluginClientWindow(plugin, 285, 170, 285, 170, 0)
32 this->plugin = plugin;
35 UnsharpWindow::~UnsharpWindow()
39 void UnsharpWindow::create_objects()
41 int x = 10, y = 10, x1 = 90;
42 int x2 = 0; int clrBtn_w = 50;
43 int defaultBtn_w = 100;
46 add_subwindow(title = new BC_Title(x, y + 10, _("Radius:")));
47 add_subwindow(radius = new UnsharpRadius(plugin, x + x1, y));
48 x2 = 285 - 10 - clrBtn_w;
49 add_subwindow(radiusClr = new UnsharpSliderClr(plugin, this, x2, y + 10, clrBtn_w, RESET_RADIUS));
52 add_subwindow(title = new BC_Title(x, y + 10, _("Amount:")));
53 add_subwindow(amount = new UnsharpAmount(plugin, x + x1, y));
54 add_subwindow(amountClr = new UnsharpSliderClr(plugin, this, x2, y + 10, clrBtn_w, RESET_AMOUNT));
57 add_subwindow(title = new BC_Title(x, y + 10, _("Threshold:")));
58 add_subwindow(threshold = new UnsharpThreshold(plugin, x + x1, y));
59 add_subwindow(thresholdClr = new UnsharpSliderClr(plugin, this, x2, y + 10, clrBtn_w, RESET_THRESHOLD));
62 add_subwindow(reset = new UnsharpReset(plugin, this, x, y));
63 add_subwindow(default_settings = new UnsharpDefaultSettings(plugin, this,
64 (285 - 10 - defaultBtn_w), y, defaultBtn_w));
71 void UnsharpWindow::update_gui(int clear)
74 case RESET_RADIUS : radius->update(plugin->config.radius);
76 case RESET_AMOUNT : amount->update(plugin->config.amount);
78 case RESET_THRESHOLD : threshold->update(plugin->config.threshold);
81 case RESET_DEFAULT_SETTINGS :
83 radius->update(plugin->config.radius);
84 amount->update(plugin->config.amount);
85 threshold->update(plugin->config.threshold);
99 UnsharpRadius::UnsharpRadius(UnsharpMain *plugin, int x, int y)
100 : BC_FPot(x, y, plugin->config.radius, 0.1, 120)
102 this->plugin = plugin;
104 int UnsharpRadius::handle_event()
106 plugin->config.radius = get_value();
107 plugin->send_configure_change();
111 UnsharpAmount::UnsharpAmount(UnsharpMain *plugin, int x, int y)
112 : BC_FPot(x, y, plugin->config.amount, 0, 5)
114 this->plugin = plugin;
116 int UnsharpAmount::handle_event()
118 plugin->config.amount = get_value();
119 plugin->send_configure_change();
123 UnsharpThreshold::UnsharpThreshold(UnsharpMain *plugin, int x, int y)
124 : BC_IPot(x, y, plugin->config.threshold, 0, 255)
126 this->plugin = plugin;
128 int UnsharpThreshold::handle_event()
130 plugin->config.threshold = get_value();
131 plugin->send_configure_change();
135 UnsharpReset::UnsharpReset(UnsharpMain *plugin, UnsharpWindow *window, int x, int y)
136 : BC_GenericButton(x, y, _("Reset"))
138 this->plugin = plugin;
139 this->window = window;
141 UnsharpReset::~UnsharpReset()
144 int UnsharpReset::handle_event()
146 plugin->config.reset(RESET_ALL);
147 window->update_gui(RESET_ALL);
148 plugin->send_configure_change();
152 UnsharpDefaultSettings::UnsharpDefaultSettings(UnsharpMain *plugin, UnsharpWindow *window, int x, int y, int w)
153 : BC_GenericButton(x, y, w, _("Default"))
155 this->plugin = plugin;
156 this->window = window;
158 UnsharpDefaultSettings::~UnsharpDefaultSettings()
161 int UnsharpDefaultSettings::handle_event()
163 plugin->config.reset(RESET_DEFAULT_SETTINGS);
164 window->update_gui(RESET_DEFAULT_SETTINGS);
165 plugin->send_configure_change();
169 UnsharpSliderClr::UnsharpSliderClr(UnsharpMain *plugin, UnsharpWindow *window, int x, int y, int w, int clear)
170 : BC_Button(x, y, w, plugin->get_theme()->get_image_set("reset_button"))
172 this->plugin = plugin;
173 this->window = window;
176 UnsharpSliderClr::~UnsharpSliderClr()
179 int UnsharpSliderClr::handle_event()
181 // clear==1 ==> Radius slider
182 // clear==2 ==> Amount slider
183 // clear==3 ==> Threshold slider
184 plugin->config.reset(clear);
185 window->update_gui(clear);
186 plugin->send_configure_change();