#include "bcdisplayinfo.h"
#include "brightnesswindow.h"
#include "language.h"
+#include "theme.h"
BrightnessWindow::BrightnessWindow(BrightnessMain *client)
- : PluginClientWindow(client,
- 330,
- 160,
- 330,
- 160,
- 0)
+ : PluginClientWindow(client, xS(370), yS(155), xS(370), yS(155), 0)
{
this->client = client;
}
void BrightnessWindow::create_objects()
{
- int x = 10, y = 10;
+ int xs10 = xS(10);
+ int ys10 = yS(10), ys25 = yS(25), ys30 = yS(30), ys35 = yS(35);
+ int x = xs10, y = ys10, x1 = x + xS(90);
+ int x2 = 0; int clrBtn_w = xS(50);
+
add_tool(new BC_Title(x, y, _("Brightness/Contrast")));
- y += 25;
+ y += ys25;
add_tool(new BC_Title(x, y,_("Brightness:")));
add_tool(brightness = new BrightnessSlider(client,
&(client->config.brightness),
- x + 80,
+ x1,
y,
1));
- y += 25;
+ x2 = x1 + brightness->get_w() + xs10;
+ add_subwindow(brightnessClr = new BrightnessSliderClr(client, this, x2, y, clrBtn_w, 1));
+ y += ys25;
add_tool(new BC_Title(x, y, _("Contrast:")));
add_tool(contrast = new BrightnessSlider(client,
&(client->config.contrast),
- x + 80,
+ x1,
y,
0));
- y += 30;
+
+ add_subwindow(contrastClr = new BrightnessSliderClr(client, this, x2, y, clrBtn_w, 0));
+ y += ys30;
add_tool(luma = new BrightnessLuma(client,
x,
y));
+
+ y += ys35;
+ add_subwindow(reset = new BrightnessReset(client, this, x, y));
+
show_window();
flush();
}
+// for Reset button
+void BrightnessWindow::update_gui(int clear)
+{
+ switch(clear) {
+ case RESET_CONTRAST : contrast->update(client->config.contrast);
+ break;
+ case RESET_BRIGHTNESS: brightness->update(client->config.brightness);
+ break;
+ case RESET_ALL :
+ default:
+ brightness->update(client->config.brightness);
+ contrast->update(client->config.contrast);
+ luma->update(client->config.luma);
+ break;
+ }
+}
BrightnessSlider::BrightnessSlider(BrightnessMain *client,
float *output,
: BC_FSlider(x,
y,
0,
- 200,
- 200,
+ xS(200),
+ yS(200),
-100,
100,
(int)*output)
client->send_configure_change();
return 1;
}
+
+
+BrightnessReset::BrightnessReset(BrightnessMain *client, BrightnessWindow *window, int x, int y)
+ : BC_GenericButton(x, y, _("Reset"))
+{
+ this->client = client;
+ this->window = window;
+}
+BrightnessReset::~BrightnessReset()
+{
+}
+int BrightnessReset::handle_event()
+{
+ client->config.reset(RESET_ALL); // clear=0 ==> reset all
+ window->update_gui(RESET_ALL);
+ client->send_configure_change();
+ return 1;
+}
+
+BrightnessSliderClr::BrightnessSliderClr(BrightnessMain *client, BrightnessWindow *window, int x, int y, int w, int is_brightness)
+ : BC_Button(x, y, w, client->get_theme()->get_image_set("reset_button"))
+{
+ this->client = client;
+ this->window = window;
+ this->is_brightness = is_brightness;
+}
+BrightnessSliderClr::~BrightnessSliderClr()
+{
+}
+int BrightnessSliderClr::handle_event()
+{
+ // is_brightness==0 means Contrast slider ==> "clear=1"
+ // is_brightness==1 means Brightness slider ==> "clear=2"
+ client->config.reset(is_brightness + 1);
+ window->update_gui(is_brightness + 1);
+ client->send_configure_change();
+ return 1;
+}
+