44ba304eff827fd552bbf6e4eea8e556e8257acb
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / blur / blurwindow.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2010 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 "blur.h"
24 #include "blurwindow.h"
25 #include "language.h"
26
27
28
29
30
31
32 BlurWindow::BlurWindow(BlurMain *client)
33  : PluginClientWindow(client,
34         xS(210),
35         yS(360),
36         xS(210),
37         yS(360),
38         0)
39 {
40         this->client = client;
41 }
42
43 BlurWindow::~BlurWindow()
44 {
45 //printf("BlurWindow::~BlurWindow 1\n");
46 }
47
48 void BlurWindow::create_objects()
49 {
50         int xs10 = xS(10);
51         int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys35 = yS(35), ys40 = yS(40);
52         int x = xs10, y = ys10;
53         BC_Title *title;
54
55         add_subwindow(new BC_Title(x, y, _("Blur")));
56         y += ys20;
57         add_subwindow(horizontal = new BlurHorizontal(client, this, x, y));
58         y += ys30;
59         add_subwindow(vertical = new BlurVertical(client, this, x, y));
60         y += ys35;
61         add_subwindow(title = new BC_Title(x, y, _("Radius:")));
62         y += title->get_h() + ys10;
63         add_subwindow(radius = new BlurRadius(client, this, x, y));
64         add_subwindow(radius_text = new BlurRadiusText(client, this, x + radius->get_w() + xs10, y, 100));
65         y += radius->get_h() + ys10;
66         add_subwindow(a_key = new BlurAKey(client, x, y));
67         y += ys30;
68         add_subwindow(a = new BlurA(client, x, y));
69         y += ys30;
70         add_subwindow(r = new BlurR(client, x, y));
71         y += ys30;
72         add_subwindow(g = new BlurG(client, x, y));
73         y += ys30;
74         add_subwindow(b = new BlurB(client, x, y));
75         y += ys40;
76         add_subwindow(reset = new BlurReset(client, this, x, y));
77
78         show_window();
79         flush();
80 }
81
82 // for Reset button
83 void BlurWindow::update()
84 {
85         horizontal->update(client->config.horizontal);
86         vertical->update(client->config.vertical);
87         radius->update(client->config.radius);
88         radius_text->update((int64_t)client->config.radius);
89         a_key->update(client->config.a_key);
90         a->update(client->config.a);
91         r->update(client->config.r);
92         g->update(client->config.g);
93         b->update(client->config.b);
94 }
95
96
97 BlurRadius::BlurRadius(BlurMain *client, BlurWindow *gui, int x, int y)
98  : BC_IPot(x,
99         y,
100         client->config.radius,
101         0,
102         MAXRADIUS)
103 {
104         this->client = client;
105         this->gui = gui;
106 }
107 BlurRadius::~BlurRadius()
108 {
109 }
110 int BlurRadius::handle_event()
111 {
112         client->config.radius = get_value();
113         gui->radius_text->update((int64_t)client->config.radius);
114         client->send_configure_change();
115         return 1;
116 }
117
118
119
120
121 BlurRadiusText::BlurRadiusText(BlurMain *client, BlurWindow *gui, int x, int y, int w)
122  : BC_TextBox(x,
123         y,
124         w,
125         1,
126         client->config.radius)
127 {
128         this->client = client;
129         this->gui = gui;
130 }
131
132 int BlurRadiusText::handle_event()
133 {
134         client->config.radius = atoi(get_text());
135         gui->radius->update((int64_t)client->config.radius);
136         client->send_configure_change();
137         return 1;
138 }
139
140
141
142
143 BlurVertical::BlurVertical(BlurMain *client, BlurWindow *window, int x, int y)
144  : BC_CheckBox(x,
145         y,
146         client->config.vertical,
147         _("Vertical"))
148 {
149         this->client = client;
150         this->window = window;
151 }
152 BlurVertical::~BlurVertical()
153 {
154 }
155 int BlurVertical::handle_event()
156 {
157         client->config.vertical = get_value();
158         client->send_configure_change();
159         return 1;
160 }
161
162 BlurHorizontal::BlurHorizontal(BlurMain *client, BlurWindow *window, int x, int y)
163  : BC_CheckBox(x,
164         y,
165         client->config.horizontal,
166         _("Horizontal"))
167 {
168         this->client = client;
169         this->window = window;
170 }
171 BlurHorizontal::~BlurHorizontal()
172 {
173 }
174 int BlurHorizontal::handle_event()
175 {
176         client->config.horizontal = get_value();
177         client->send_configure_change();
178         return 1;
179 }
180
181
182
183
184 BlurA::BlurA(BlurMain *client, int x, int y)
185  : BC_CheckBox(x, y, client->config.a, _("Blur alpha"))
186 {
187         this->client = client;
188 }
189 int BlurA::handle_event()
190 {
191         client->config.a = get_value();
192         client->send_configure_change();
193         return 1;
194 }
195
196
197
198
199 BlurAKey::BlurAKey(BlurMain *client, int x, int y)
200  : BC_CheckBox(x, y, client->config.a_key, _("Alpha determines radius"))
201 {
202         this->client = client;
203 }
204 int BlurAKey::handle_event()
205 {
206         client->config.a_key = get_value();
207         client->send_configure_change();
208         return 1;
209 }
210
211 BlurR::BlurR(BlurMain *client, int x, int y)
212  : BC_CheckBox(x, y, client->config.r, _("Blur red"))
213 {
214         this->client = client;
215 }
216 int BlurR::handle_event()
217 {
218         client->config.r = get_value();
219         client->send_configure_change();
220         return 1;
221 }
222
223 BlurG::BlurG(BlurMain *client, int x, int y)
224  : BC_CheckBox(x, y, client->config.g, _("Blur green"))
225 {
226         this->client = client;
227 }
228 int BlurG::handle_event()
229 {
230         client->config.g = get_value();
231         client->send_configure_change();
232         return 1;
233 }
234
235 BlurB::BlurB(BlurMain *client, int x, int y)
236  : BC_CheckBox(x, y, client->config.b, _("Blur blue"))
237 {
238         this->client = client;
239 }
240 int BlurB::handle_event()
241 {
242         client->config.b = get_value();
243         client->send_configure_change();
244         return 1;
245 }
246
247 BlurReset::BlurReset(BlurMain *client, BlurWindow *window, int x, int y)
248  : BC_GenericButton(x, y, _("Reset"))
249 {
250         this->client = client;
251         this->window = window;
252 }
253 BlurReset::~BlurReset()
254 {
255 }
256 int BlurReset::handle_event()
257 {
258         client->config.reset();
259         window->update();
260         client->send_configure_change();
261         return 1;
262 }