r864: Merge 2.1:
[cinelerra_cv/ct.git] / plugins / brightness / brightnesswindow.C
blob3a5610394b65fc9f06e89f35a80b8bcc5894fba4
1 #include "bcdisplayinfo.h"
2 #include "brightnesswindow.h"
3 #include "language.h"
6 PLUGIN_THREAD_OBJECT(BrightnessMain, BrightnessThread, BrightnessWindow)
12 BrightnessWindow::BrightnessWindow(BrightnessMain *client, int x, int y)
13  : BC_Window(client->gui_string, x,
14         y,
15         330, 
16         160, 
17         330, 
18         160, 
19         0, 
20         0)
21
22         this->client = client; 
25 BrightnessWindow::~BrightnessWindow()
29 int BrightnessWindow::create_objects()
31         int x = 10, y = 10;
32         add_tool(new BC_Title(x, y, _("Brightness/Contrast")));
33         y += 25;
34         add_tool(new BC_Title(x, y,_("Brightness:")));
35         add_tool(brightness = new BrightnessSlider(client, 
36                 &(client->config.brightness), 
37                 x + 80, 
38                 y,
39                 1));
40         y += 25;
41         add_tool(new BC_Title(x, y, _("Contrast:")));
42         add_tool(contrast = new BrightnessSlider(client, 
43                 &(client->config.contrast), 
44                 x + 80, 
45                 y,
46                 0));
47         y += 30;
48         add_tool(luma = new BrightnessLuma(client, 
49                 x, 
50                 y));
51         show_window();
52         flush();
53         return 0;
56 int BrightnessWindow::close_event()
58 // Set result to 1 to indicate a client side close
59         set_done(1);
60         return 1;
63 BrightnessSlider::BrightnessSlider(BrightnessMain *client, 
64         float *output, 
65         int x, 
66         int y,
67         int is_brightness)
68  : BC_FSlider(x, 
69         y, 
70         0, 
71         200, 
72         200,
73         -100, 
74         100, 
75         (int)*output)
77         this->client = client;
78         this->output = output;
79         this->is_brightness = is_brightness;
81 BrightnessSlider::~BrightnessSlider()
84 int BrightnessSlider::handle_event()
86         *output = get_value();
87         client->send_configure_change();
88         return 1;
91 char* BrightnessSlider::get_caption()
93         float fraction;
94         if(is_brightness)
95         {
96                 fraction = *output / 100;
97         }
98         else
99         {
100                 fraction = (*output < 0) ? 
101                         (*output + 100) / 100 : 
102                         (*output + 25) / 25;
103         }
104         sprintf(string, "%0.4f", fraction);
105         return string;
109 BrightnessLuma::BrightnessLuma(BrightnessMain *client, 
110         int x, 
111         int y)
112  : BC_CheckBox(x, 
113         y, 
114         client->config.luma,
115         _("Boost luminance only"))
117         this->client = client;
119 BrightnessLuma::~BrightnessLuma()
122 int BrightnessLuma::handle_event()
124         client->config.luma = get_value();
125         client->send_configure_change();
126         return 1;