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"
24 #include "sharpenwindow.h"
35 SharpenWindow::SharpenWindow(SharpenMain *client)
36 : PluginClientWindow(client, xS(420), yS(190), xS(420), yS(190), 0)
38 this->client = client;
41 SharpenWindow::~SharpenWindow()
45 void SharpenWindow::create_objects()
47 int xs10 = xS(10), xs100 = xS(100), xs200 = xS(200);
48 int ys10 = yS(10), ys30 = yS(30), ys40 = yS(40);
49 int x = xs10, y = ys10;
50 int x2 = xS(80), x3 = xS(180);
51 int clr_x = get_w()-x - xS(22); // note: clrBtn_w = 22
52 int defaultBtn_w = xs100;
57 add_tool(new BC_Title(x, y, _("Sharpness:")));
58 sharpen_text = new SharpenText(client, this, (x + x2), y);
59 sharpen_text->create_objects();
60 add_tool(sharpen_slider = new SharpenSlider(client, this, x3, y, xs200));
61 clr_x = x3 + sharpen_slider->get_w() + x;
62 add_subwindow(sharpen_Clr = new SharpenClr(client, this, clr_x, y));
65 add_tool(sharpen_interlace = new SharpenInterlace(client, x, y));
67 add_tool(sharpen_horizontal = new SharpenHorizontal(client, x, y));
69 add_tool(sharpen_luminance = new SharpenLuminance(client, x, y));
73 add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
75 add_tool(reset = new SharpenReset(client, this, x, y));
76 add_subwindow(default_settings = new SharpenDefaultSettings(client, this,
77 (get_w() - xs10 - defaultBtn_w), y, defaultBtn_w));
83 void SharpenWindow::update_gui(int clear)
87 sharpen_text->update((int64_t)client->config.sharpness);
88 sharpen_slider->update(client->config.sharpness);
91 case RESET_DEFAULT_SETTINGS :
93 sharpen_text->update((int64_t)client->config.sharpness);
94 sharpen_slider->update(client->config.sharpness);
95 sharpen_interlace->update(client->config.interlace);
96 sharpen_horizontal->update(client->config.horizontal);
97 sharpen_luminance->update(client->config.luminance);
102 SharpenText::SharpenText(SharpenMain *client, SharpenWindow *gui, int x, int y)
103 : BC_TumbleTextBox(gui, client->config.sharpness,
104 0, MAXSHARPNESS, x, y, xS(60), 0)
106 this->client = client;
111 SharpenText::~SharpenText()
115 int SharpenText::handle_event()
117 client->config.sharpness = atoi(get_text());
118 if(client->config.sharpness > MAXSHARPNESS)
119 client->config.sharpness = MAXSHARPNESS;
121 if(client->config.sharpness < 0) client->config.sharpness = 0;
123 gui->sharpen_slider->update((int64_t)client->config.sharpness);
124 client->send_configure_change();
128 SharpenSlider::SharpenSlider(SharpenMain *client, SharpenWindow *gui, int x, int y, int w)
129 : BC_ISlider(x, y, 0, w, w, 0, MAXSHARPNESS, client->config.sharpness, 0, 0, 0)
131 this->client = client;
133 enable_show_value(0); // Hide caption
135 SharpenSlider::~SharpenSlider()
138 int SharpenSlider::handle_event()
140 client->config.sharpness = get_value();
141 gui->sharpen_text->update(client->config.sharpness);
142 client->send_configure_change();
147 SharpenInterlace::SharpenInterlace(SharpenMain *client, int x, int y)
148 : BC_CheckBox(x, y, client->config.interlace, _("Interlace"))
150 this->client = client;
152 SharpenInterlace::~SharpenInterlace()
155 int SharpenInterlace::handle_event()
157 client->config.interlace = get_value();
158 client->send_configure_change();
163 SharpenHorizontal::SharpenHorizontal(SharpenMain *client, int x, int y)
164 : BC_CheckBox(x, y, client->config.horizontal, _("Horizontal only"))
166 this->client = client;
168 SharpenHorizontal::~SharpenHorizontal()
171 int SharpenHorizontal::handle_event()
173 client->config.horizontal = get_value();
174 client->send_configure_change();
179 SharpenLuminance::SharpenLuminance(SharpenMain *client, int x, int y)
180 : BC_CheckBox(x, y, client->config.luminance, _("Luminance only"))
182 this->client = client;
184 SharpenLuminance::~SharpenLuminance()
187 int SharpenLuminance::handle_event()
189 client->config.luminance = get_value();
190 client->send_configure_change();
195 SharpenReset::SharpenReset(SharpenMain *client, SharpenWindow *gui, int x, int y)
196 : BC_GenericButton(x, y, _("Reset"))
198 this->client = client;
201 SharpenReset::~SharpenReset()
204 int SharpenReset::handle_event()
206 client->config.reset(RESET_ALL);
207 gui->update_gui(RESET_ALL);
208 client->send_configure_change();
213 SharpenDefaultSettings::SharpenDefaultSettings(SharpenMain *client, SharpenWindow *gui, int x, int y, int w)
214 : BC_GenericButton(x, y, w, _("Default"))
216 this->client = client;
219 SharpenDefaultSettings::~SharpenDefaultSettings()
222 int SharpenDefaultSettings::handle_event()
224 client->config.reset(RESET_DEFAULT_SETTINGS);
225 gui->update_gui(RESET_DEFAULT_SETTINGS);
226 client->send_configure_change();
231 SharpenClr::SharpenClr(SharpenMain *client, SharpenWindow *gui, int x, int y)
232 : BC_Button(x, y, client->get_theme()->get_image_set("reset_button"))
234 this->client = client;
237 SharpenClr::~SharpenClr()
240 int SharpenClr::handle_event()
242 client->config.reset(RESET_SHARPEN);
243 gui->update_gui(RESET_SHARPEN);
244 client->send_configure_change();