affine + perspective plugin rework, info popup tweaks
[goodguy/history.git] / cinelerra-5.1 / plugins / brightness / brightnesswindow.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "bcdisplayinfo.h"
23 #include "brightnesswindow.h"
24 #include "language.h"
25
26
27
28
29
30
31
32
33
34 BrightnessWindow::BrightnessWindow(BrightnessMain *client)
35  : PluginClientWindow(client,
36         330,
37         160,
38         330,
39         160,
40         0)
41 {
42         this->client = client;
43 }
44
45 BrightnessWindow::~BrightnessWindow()
46 {
47 }
48
49 void BrightnessWindow::create_objects()
50 {
51         int x = 10, y = 10;
52         add_tool(new BC_Title(x, y, _("Brightness/Contrast")));
53         y += 25;
54         add_tool(new BC_Title(x, y,_("Brightness:")));
55         add_tool(brightness = new BrightnessSlider(client,
56                 &(client->config.brightness),
57                 x + 80,
58                 y,
59                 1));
60         y += 25;
61         add_tool(new BC_Title(x, y, _("Contrast:")));
62         add_tool(contrast = new BrightnessSlider(client,
63                 &(client->config.contrast),
64                 x + 80,
65                 y,
66                 0));
67         y += 30;
68         add_tool(luma = new BrightnessLuma(client,
69                 x,
70                 y));
71         show_window();
72         flush();
73 }
74
75
76 BrightnessSlider::BrightnessSlider(BrightnessMain *client,
77         float *output,
78         int x,
79         int y,
80         int is_brightness)
81  : BC_FSlider(x,
82         y,
83         0,
84         200,
85         200,
86         -100,
87         100,
88         (int)*output)
89 {
90         this->client = client;
91         this->output = output;
92         this->is_brightness = is_brightness;
93 }
94 BrightnessSlider::~BrightnessSlider()
95 {
96 }
97 int BrightnessSlider::handle_event()
98 {
99         *output = get_value();
100         client->send_configure_change();
101         return 1;
102 }
103
104 char* BrightnessSlider::get_caption()
105 {
106         float fraction;
107         if(is_brightness)
108         {
109                 fraction = *output / 100;
110         }
111         else
112         {
113                 fraction = (*output < 0) ?
114                         (*output + 100) / 100 :
115                         (*output + 25) / 25;
116         }
117         sprintf(string, "%0.4f", fraction);
118         return string;
119 }
120
121
122 BrightnessLuma::BrightnessLuma(BrightnessMain *client,
123         int x,
124         int y)
125  : BC_CheckBox(x,
126         y,
127         client->config.luma,
128         _("Boost luminance only"))
129 {
130         this->client = client;
131 }
132 BrightnessLuma::~BrightnessLuma()
133 {
134 }
135 int BrightnessLuma::handle_event()
136 {
137         client->config.luma = get_value();
138         client->send_configure_change();
139         return 1;
140 }