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