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"
34 BrightnessWindow::BrightnessWindow(BrightnessMain *client)
35 : PluginClientWindow(client, 370, 155, 370, 155, 0)
37 this->client = client;
40 BrightnessWindow::~BrightnessWindow()
44 void BrightnessWindow::create_objects()
46 int x = 10, y = 10, x1 = x + 90;
47 int x2 = 0; int clrBtn_w = 50;
49 add_tool(new BC_Title(x, y, _("Brightness/Contrast")));
51 add_tool(new BC_Title(x, y,_("Brightness:")));
52 add_tool(brightness = new BrightnessSlider(client,
53 &(client->config.brightness),
57 x2 = x1 + brightness->get_w() + 10;
58 add_subwindow(brightnessClr = new BrightnessSliderClr(client, this, x2, y, clrBtn_w, 1));
60 add_tool(new BC_Title(x, y, _("Contrast:")));
61 add_tool(contrast = new BrightnessSlider(client,
62 &(client->config.contrast),
67 add_subwindow(contrastClr = new BrightnessSliderClr(client, this, x2, y, clrBtn_w, 0));
69 add_tool(luma = new BrightnessLuma(client,
74 add_subwindow(reset = new BrightnessReset(client, this, x, y));
81 void BrightnessWindow::update_gui(int clear)
84 case RESET_CONTRAST : contrast->update(client->config.contrast);
86 case RESET_BRIGHTNESS: brightness->update(client->config.brightness);
90 brightness->update(client->config.brightness);
91 contrast->update(client->config.contrast);
92 luma->update(client->config.luma);
97 BrightnessSlider::BrightnessSlider(BrightnessMain *client,
111 this->client = client;
112 this->output = output;
113 this->is_brightness = is_brightness;
115 BrightnessSlider::~BrightnessSlider()
118 int BrightnessSlider::handle_event()
120 *output = get_value();
121 client->send_configure_change();
125 char* BrightnessSlider::get_caption()
130 fraction = *output / 100;
134 fraction = (*output < 0) ?
135 (*output + 100) / 100 :
138 sprintf(string, "%0.4f", fraction);
143 BrightnessLuma::BrightnessLuma(BrightnessMain *client,
149 _("Boost luminance only"))
151 this->client = client;
153 BrightnessLuma::~BrightnessLuma()
156 int BrightnessLuma::handle_event()
158 client->config.luma = get_value();
159 client->send_configure_change();
164 BrightnessReset::BrightnessReset(BrightnessMain *client, BrightnessWindow *window, int x, int y)
165 : BC_GenericButton(x, y, _("Reset"))
167 this->client = client;
168 this->window = window;
170 BrightnessReset::~BrightnessReset()
173 int BrightnessReset::handle_event()
175 client->config.reset(RESET_ALL); // clear=0 ==> reset all
176 window->update_gui(RESET_ALL);
177 client->send_configure_change();
181 BrightnessSliderClr::BrightnessSliderClr(BrightnessMain *client, BrightnessWindow *window, int x, int y, int w, int is_brightness)
182 : BC_GenericButton(x, y, w, _("⌂"))
184 this->client = client;
185 this->window = window;
186 this->is_brightness = is_brightness;
188 BrightnessSliderClr::~BrightnessSliderClr()
191 int BrightnessSliderClr::handle_event()
193 // is_brightness==0 means Contrast slider ==> "clear=1"
194 // is_brightness==1 means Brightness slider ==> "clear=2"
195 client->config.reset(is_brightness + 1);
196 window->update_gui(is_brightness + 1);
197 client->send_configure_change();