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, xS(285), yS(170), xS(285), yS(170), 0)
32 this->plugin = plugin;
35 UnsharpWindow::~UnsharpWindow()
39 void UnsharpWindow::create_objects()
41 int xs10 = xS(10), xs50 = xS(50), xs90 = xS(90), xs100 = xS(100);
42 int ys10 = yS(10), ys40 = yS(40), ys50 = yS(50);
43 int x = xs10, y = ys10, x1 = xs90;
44 int x2 = 0; int clrBtn_w = xs50;
45 int defaultBtn_w = xs100;
48 add_subwindow(title = new BC_Title(x, y + ys10, _("Radius:")));
49 add_subwindow(radius = new UnsharpRadius(plugin, x + x1, y));
50 x2 = xS(285) - xs10 - clrBtn_w;
51 add_subwindow(radiusClr = new UnsharpSliderClr(plugin, this, x2, y + ys10, clrBtn_w, RESET_RADIUS));
54 add_subwindow(title = new BC_Title(x, y + ys10, _("Amount:")));
55 add_subwindow(amount = new UnsharpAmount(plugin, x + x1, y));
56 add_subwindow(amountClr = new UnsharpSliderClr(plugin, this, x2, y + ys10, clrBtn_w, RESET_AMOUNT));
59 add_subwindow(title = new BC_Title(x, y + ys10, _("Threshold:")));
60 add_subwindow(threshold = new UnsharpThreshold(plugin, x + x1, y));
61 add_subwindow(thresholdClr = new UnsharpSliderClr(plugin, this, x2, y + ys10, clrBtn_w, RESET_THRESHOLD));
64 add_subwindow(reset = new UnsharpReset(plugin, this, x, y));
65 add_subwindow(default_settings = new UnsharpDefaultSettings(plugin, this,
66 (xS(285) - xs10 - defaultBtn_w), y, defaultBtn_w));
73 void UnsharpWindow::update_gui(int clear)
76 case RESET_RADIUS : radius->update(plugin->config.radius);
78 case RESET_AMOUNT : amount->update(plugin->config.amount);
80 case RESET_THRESHOLD : threshold->update(plugin->config.threshold);
83 case RESET_DEFAULT_SETTINGS :
85 radius->update(plugin->config.radius);
86 amount->update(plugin->config.amount);
87 threshold->update(plugin->config.threshold);
101 UnsharpRadius::UnsharpRadius(UnsharpMain *plugin, int x, int y)
102 : BC_FPot(x, y, plugin->config.radius, 0.1, 120)
104 this->plugin = plugin;
106 int UnsharpRadius::handle_event()
108 plugin->config.radius = get_value();
109 plugin->send_configure_change();
113 UnsharpAmount::UnsharpAmount(UnsharpMain *plugin, int x, int y)
114 : BC_FPot(x, y, plugin->config.amount, 0, 5)
116 this->plugin = plugin;
118 int UnsharpAmount::handle_event()
120 plugin->config.amount = get_value();
121 plugin->send_configure_change();
125 UnsharpThreshold::UnsharpThreshold(UnsharpMain *plugin, int x, int y)
126 : BC_IPot(x, y, plugin->config.threshold, 0, 255)
128 this->plugin = plugin;
130 int UnsharpThreshold::handle_event()
132 plugin->config.threshold = get_value();
133 plugin->send_configure_change();
137 UnsharpReset::UnsharpReset(UnsharpMain *plugin, UnsharpWindow *window, int x, int y)
138 : BC_GenericButton(x, y, _("Reset"))
140 this->plugin = plugin;
141 this->window = window;
143 UnsharpReset::~UnsharpReset()
146 int UnsharpReset::handle_event()
148 plugin->config.reset(RESET_ALL);
149 window->update_gui(RESET_ALL);
150 plugin->send_configure_change();
154 UnsharpDefaultSettings::UnsharpDefaultSettings(UnsharpMain *plugin, UnsharpWindow *window, int x, int y, int w)
155 : BC_GenericButton(x, y, w, _("Default"))
157 this->plugin = plugin;
158 this->window = window;
160 UnsharpDefaultSettings::~UnsharpDefaultSettings()
163 int UnsharpDefaultSettings::handle_event()
165 plugin->config.reset(RESET_DEFAULT_SETTINGS);
166 window->update_gui(RESET_DEFAULT_SETTINGS);
167 plugin->send_configure_change();
171 UnsharpSliderClr::UnsharpSliderClr(UnsharpMain *plugin, UnsharpWindow *window, int x, int y, int w, int clear)
172 : BC_Button(x, y, w, plugin->get_theme()->get_image_set("reset_button"))
174 this->plugin = plugin;
175 this->window = window;
178 UnsharpSliderClr::~UnsharpSliderClr()
181 int UnsharpSliderClr::handle_event()
183 // clear==1 ==> Radius slider
184 // clear==2 ==> Amount slider
185 // clear==3 ==> Threshold slider
186 plugin->config.reset(clear);
187 window->update_gui(clear);
188 plugin->send_configure_change();