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"
23 #include "brightnesswindow.h"
35 BrightnessWindow::BrightnessWindow(BrightnessMain *client)
36 : PluginClientWindow(client, xS(370), yS(155), xS(370), yS(155), 0)
38 this->client = client;
41 BrightnessWindow::~BrightnessWindow()
45 void BrightnessWindow::create_objects()
48 int ys10 = yS(10), ys25 = yS(25), ys30 = yS(30), ys35 = yS(35);
49 int x = xs10, y = ys10, x1 = x + xS(90);
50 int x2 = 0; int clrBtn_w = xS(50);
52 add_tool(new BC_Title(x, y, _("Brightness/Contrast")));
54 add_tool(new BC_Title(x, y,_("Brightness:")));
55 add_tool(brightness = new BrightnessSlider(client,
56 &(client->config.brightness),
60 x2 = x1 + brightness->get_w() + xs10;
61 add_subwindow(brightnessClr = new BrightnessSliderClr(client, this, x2, y, clrBtn_w, 1));
63 add_tool(new BC_Title(x, y, _("Contrast:")));
64 add_tool(contrast = new BrightnessSlider(client,
65 &(client->config.contrast),
70 add_subwindow(contrastClr = new BrightnessSliderClr(client, this, x2, y, clrBtn_w, 0));
72 add_tool(luma = new BrightnessLuma(client,
77 add_subwindow(reset = new BrightnessReset(client, this, x, y));
84 void BrightnessWindow::update_gui(int clear)
87 case RESET_CONTRAST : contrast->update(client->config.contrast);
89 case RESET_BRIGHTNESS: brightness->update(client->config.brightness);
93 brightness->update(client->config.brightness);
94 contrast->update(client->config.contrast);
95 luma->update(client->config.luma);
100 BrightnessSlider::BrightnessSlider(BrightnessMain *client,
114 this->client = client;
115 this->output = output;
116 this->is_brightness = is_brightness;
118 BrightnessSlider::~BrightnessSlider()
121 int BrightnessSlider::handle_event()
123 *output = get_value();
124 client->send_configure_change();
128 char* BrightnessSlider::get_caption()
133 fraction = *output / 100;
137 fraction = (*output < 0) ?
138 (*output + 100) / 100 :
141 sprintf(string, "%0.4f", fraction);
146 BrightnessLuma::BrightnessLuma(BrightnessMain *client,
152 _("Boost luminance only"))
154 this->client = client;
156 BrightnessLuma::~BrightnessLuma()
159 int BrightnessLuma::handle_event()
161 client->config.luma = get_value();
162 client->send_configure_change();
167 BrightnessReset::BrightnessReset(BrightnessMain *client, BrightnessWindow *window, int x, int y)
168 : BC_GenericButton(x, y, _("Reset"))
170 this->client = client;
171 this->window = window;
173 BrightnessReset::~BrightnessReset()
176 int BrightnessReset::handle_event()
178 client->config.reset(RESET_ALL); // clear=0 ==> reset all
179 window->update_gui(RESET_ALL);
180 client->send_configure_change();
184 BrightnessSliderClr::BrightnessSliderClr(BrightnessMain *client, BrightnessWindow *window, int x, int y, int w, int is_brightness)
185 : BC_Button(x, y, w, client->get_theme()->get_image_set("reset_button"))
187 this->client = client;
188 this->window = window;
189 this->is_brightness = is_brightness;
191 BrightnessSliderClr::~BrightnessSliderClr()
194 int BrightnessSliderClr::handle_event()
196 // is_brightness==0 means Contrast slider ==> "clear=1"
197 // is_brightness==1 means Brightness slider ==> "clear=2"
198 client->config.reset(is_brightness + 1);
199 window->update_gui(is_brightness + 1);
200 client->send_configure_change();