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, 370, 155, 370, 155, 0)
38 this->client = client;
41 BrightnessWindow::~BrightnessWindow()
45 void BrightnessWindow::create_objects()
47 int x = 10, y = 10, x1 = x + 90;
48 int x2 = 0; int clrBtn_w = 50;
50 add_tool(new BC_Title(x, y, _("Brightness/Contrast")));
52 add_tool(new BC_Title(x, y,_("Brightness:")));
53 add_tool(brightness = new BrightnessSlider(client,
54 &(client->config.brightness),
58 x2 = x1 + brightness->get_w() + 10;
59 add_subwindow(brightnessClr = new BrightnessSliderClr(client, this, x2, y, clrBtn_w, 1));
61 add_tool(new BC_Title(x, y, _("Contrast:")));
62 add_tool(contrast = new BrightnessSlider(client,
63 &(client->config.contrast),
68 add_subwindow(contrastClr = new BrightnessSliderClr(client, this, x2, y, clrBtn_w, 0));
70 add_tool(luma = new BrightnessLuma(client,
75 add_subwindow(reset = new BrightnessReset(client, this, x, y));
82 void BrightnessWindow::update_gui(int clear)
85 case RESET_CONTRAST : contrast->update(client->config.contrast);
87 case RESET_BRIGHTNESS: brightness->update(client->config.brightness);
91 brightness->update(client->config.brightness);
92 contrast->update(client->config.contrast);
93 luma->update(client->config.luma);
98 BrightnessSlider::BrightnessSlider(BrightnessMain *client,
112 this->client = client;
113 this->output = output;
114 this->is_brightness = is_brightness;
116 BrightnessSlider::~BrightnessSlider()
119 int BrightnessSlider::handle_event()
121 *output = get_value();
122 client->send_configure_change();
126 char* BrightnessSlider::get_caption()
131 fraction = *output / 100;
135 fraction = (*output < 0) ?
136 (*output + 100) / 100 :
139 sprintf(string, "%0.4f", fraction);
144 BrightnessLuma::BrightnessLuma(BrightnessMain *client,
150 _("Boost luminance only"))
152 this->client = client;
154 BrightnessLuma::~BrightnessLuma()
157 int BrightnessLuma::handle_event()
159 client->config.luma = get_value();
160 client->send_configure_change();
165 BrightnessReset::BrightnessReset(BrightnessMain *client, BrightnessWindow *window, int x, int y)
166 : BC_GenericButton(x, y, _("Reset"))
168 this->client = client;
169 this->window = window;
171 BrightnessReset::~BrightnessReset()
174 int BrightnessReset::handle_event()
176 client->config.reset(RESET_ALL); // clear=0 ==> reset all
177 window->update_gui(RESET_ALL);
178 client->send_configure_change();
182 BrightnessSliderClr::BrightnessSliderClr(BrightnessMain *client, BrightnessWindow *window, int x, int y, int w, int is_brightness)
183 : BC_Button(x, y, w, client->get_theme()->get_image_set("reset_button"))
185 this->client = client;
186 this->window = window;
187 this->is_brightness = is_brightness;
189 BrightnessSliderClr::~BrightnessSliderClr()
192 int BrightnessSliderClr::handle_event()
194 // is_brightness==0 means Contrast slider ==> "clear=1"
195 // is_brightness==1 means Brightness slider ==> "clear=2"
196 client->config.reset(is_brightness + 1);
197 window->update_gui(is_brightness + 1);
198 client->send_configure_change();