r705: More gettextizations (mostly plugins) by Jean-Luc Coulon.
[cinelerra_cv.git] / plugins / colorbalance / colorbalancewindow.C
blobe5ac7a7f88813fa0b64facf1bef0fa42e48a4ddf
1 #include "bcdisplayinfo.h"
2 #include "colorbalancewindow.h"
3 #include "language.h"
9 PLUGIN_THREAD_OBJECT(ColorBalanceMain, ColorBalanceThread, ColorBalanceWindow)
16 ColorBalanceWindow::ColorBalanceWindow(ColorBalanceMain *client, int x, int y)
17  : BC_Window(client->gui_string, x,
18         y,
19         330, 
20         250, 
21         330, 
22         250, 
23         0, 
24         0)
25
26         this->client = client; 
29 ColorBalanceWindow::~ColorBalanceWindow()
33 int ColorBalanceWindow::create_objects()
35         int x = 10, y = 10;
36         add_tool(new BC_Title(x, y, _("Color Balance")));
37         y += 25;
38         add_tool(new BC_Title(x, y, _("Cyan")));
39         add_tool(cyan = new ColorBalanceSlider(client, &(client->config.cyan), x + 70, y));
40         add_tool(new BC_Title(x + 270, y, _("Red")));
41         y += 25;
42         add_tool(new BC_Title(x, y, _("Magenta")));
43         add_tool(magenta = new ColorBalanceSlider(client, &(client->config.magenta), x + 70, y));
44         add_tool(new BC_Title(x + 270, y, _("Green")));
45         y += 25;
46         add_tool(new BC_Title(x, y, _("Yellow")));
47         add_tool(yellow = new ColorBalanceSlider(client, &(client->config.yellow), x + 70, y));
48         add_tool(new BC_Title(x + 270, y, _("Blue")));
49         y += 25;
50         add_tool(preserve = new ColorBalancePreserve(client, x + 70, y));
51         y += preserve->get_h() + 10;
52         add_tool(lock_params = new ColorBalanceLock(client, x + 70, y));
53         y += lock_params->get_h() + 10;
54         add_tool(new ColorBalanceWhite(client, this, x, y));
55         y += lock_params->get_h() + 10;
56         add_tool(new ColorBalanceReset(client, this, x, y));
58         show_window();
59         flush();
60         return 0;
63 void ColorBalanceWindow::update()
65         cyan->update((int64_t)client->config.cyan);
66         magenta->update((int64_t)client->config.magenta);
67         yellow->update((int64_t)client->config.yellow);
70 WINDOW_CLOSE_EVENT(ColorBalanceWindow)
72 ColorBalanceSlider::ColorBalanceSlider(ColorBalanceMain *client, 
73         float *output, int x, int y)
74  : BC_ISlider(x, 
75         y, 
76         0, 
77         200, 
78         200,
79         -100, 
80         100, 
81         (int)*output)
83         this->client = client;
84         this->output = output;
85     old_value = *output;
88 ColorBalanceSlider::~ColorBalanceSlider()
92 int ColorBalanceSlider::handle_event()
94         float difference = get_value() - *output;
95         *output = get_value();
96     client->synchronize_params(this, difference);
97         client->send_configure_change();
98         return 1;
101 ColorBalancePreserve::ColorBalancePreserve(ColorBalanceMain *client, int x, int y)
102  : BC_CheckBox(x, 
103         y, 
104         client->config.preserve, 
105         _("Preserve luminosity"))
107         this->client = client;
109 ColorBalancePreserve::~ColorBalancePreserve()
113 int ColorBalancePreserve::handle_event()
115         client->config.preserve = get_value();
116         client->send_configure_change();
117         return 1;
120 ColorBalanceLock::ColorBalanceLock(ColorBalanceMain *client, int x, int y)
121  : BC_CheckBox(x, 
122         y, 
123         client->config.lock_params, 
124         _("Lock parameters"))
126         this->client = client;
128 ColorBalanceLock::~ColorBalanceLock()
132 int ColorBalanceLock::handle_event()
134         client->config.lock_params = get_value();
135         client->send_configure_change();
136         return 1;
140 ColorBalanceWhite::ColorBalanceWhite(ColorBalanceMain *plugin, 
141         ColorBalanceWindow *gui,
142         int x, 
143         int y)
144  : BC_GenericButton(x, y, _("White balance"))
146         this->plugin = plugin;
147         this->gui = gui;
150 int ColorBalanceWhite::handle_event()
152 // Get colorpicker value
153         float red = plugin->get_red();
154         float green = plugin->get_green();
155         float blue = plugin->get_blue();
156 // // Get maximum value
157 //      float max = MAX(red, green);
158 //      max  = MAX(max, blue);
159 // // Get factors required to normalize other values to maximum
160 //      float r_factor = max / red;
161 //      float g_factor = max / green;
162 //      float b_factor = max / blue;
163 // Get minimum value.  Can't use maximum because the sliders run out of room.
164         float min = MIN(red, green);
165         min = MIN(min, blue);
166 // Get factors required to normalize other values to minimum
167         float r_factor = min / red;
168         float g_factor = min / green;
169         float b_factor = min / blue;
170 // Convert factors to slider values
171         plugin->config.cyan = plugin->calculate_slider(r_factor);
172         plugin->config.magenta = plugin->calculate_slider(g_factor);
173         plugin->config.yellow = plugin->calculate_slider(b_factor);
174         gui->update();
176         plugin->send_configure_change();
177         return 1;
181 ColorBalanceReset::ColorBalanceReset(ColorBalanceMain *plugin, 
182         ColorBalanceWindow *gui, 
183         int x, 
184         int y)
185  : BC_GenericButton(x, y, _("Reset"))
187         this->plugin = plugin;
188         this->gui = gui;
191 int ColorBalanceReset::handle_event()
193         plugin->config.cyan = 0;
194         plugin->config.magenta = 0;
195         plugin->config.yellow = 0;
196         gui->update();
197         plugin->send_configure_change();
198         return 1;