r622: Fixes misplacement of the mask when resizing track and misplacement of the
[cinelerra_cv/mob.git] / plugins / diffkey / diffkeywindow.C
blobec5fa610b4b125f452a975ff023bf9d47cab44a2
1 #ifdef HAVE_CONFIG_H
2 #  include <config.h>
3 #endif
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <unistd.h>
8 #include <string.h>
9 #include <stdio.h>
11 #include "bcdisplayinfo.h"
12 #include "diffkeywindow.h"
13 #include "language.h"
15 //#define NO_GUI
17 PLUGIN_THREAD_OBJECT(DiffKeyMain, DiffKeyThread, DiffKeyWindow)
20 extern int grab_key_frame;
21 extern int add_key_frame;
25 DiffKeyWindow::DiffKeyWindow(DiffKeyMain *client, int x, int y)
26  : BC_Window(client->get_gui_string(),
27         x,
28         y,
29         430, 
30         310, // height was 360
31         10,
32         10,
33 #ifdef DEBUG
34         1,
35 #endif
36 #ifndef DEBUG
37         0,
38 #endif
39         0,
40         1)
41
42         #ifdef DEBUG
43                 printf("\nConstructing window....");
44                 printf("\n");
45                 printf("\n");
46         #endif
48         this->client = client; 
51 DiffKeyWindow::~DiffKeyWindow()
53         #ifdef DEBUG
54                 printf("\nDestroying window....");
55                 printf("\n");
56                 printf("\n");
57         #endif
68 int DiffKeyWindow::create_objects()
70 #ifndef NO_GUI
71         #ifdef DEBUG
72                 printf("\nPopulating window....");
73                 printf("\n");
74                 printf("\n");
75         #endif
77         int x = 10, y = 10;
78         add_tool(new BC_Title(x, y, _("Hue sensitivity")));
79         x += 170;
80         add_tool(hue_on = new DiffKeyToggle(client, 
81                 &(client->config.hue_on), 
82                 "",
83                 x, 
84                 y));
85         x -= 170;
86         y += 30;
87         add_tool(hue_imp = new DiffKeySlider(client,
88                 &(client->config.hue_imp),
89                 x,
90                 y));
91         y += 30;
92         add_tool(new BC_Title(x, y, _("Saturation sensitivity")));
93         x += 170;
94         add_tool(sat_on = new DiffKeyToggle(client, 
95                 &(client->config.sat_on), 
96                 "",
97                 x, 
98                 y));
99         x -= 170;
100         y += 30;
101         add_tool(sat_imp = new DiffKeySlider(client,
102                 &(client->config.sat_imp),
103                 x,
104                 y));
105         y += 30;
106         add_tool(new BC_Title(x, y, _("Value sensitivity")));
107         x += 170;
108         add_tool(val_on = new DiffKeyToggle(client, 
109                 &(client->config.val_on), 
110                 "",
111                 x, 
112                 y));
113         x -= 170;
114         y += 30;
115         add_tool(val_imp = new DiffKeySlider(client,
116                 &(client->config.val_imp),
117                 x,
118                 y));
119         y += 30;
120         add_tool(new BC_Title(x, y, _("Visibility threshold")));
121         x += 170;
122         add_tool(vis_on = new DiffKeyToggle(client, 
123                 &(client->config.vis_on), 
124                 "",
125                 x, 
126                 y));
127         x -= 170;
128         y += 30;
129         add_tool(vis_thresh = new DiffKeySlider(client,
130                 &(client->config.vis_thresh),
131                 x,
132                 y));
133         y += 30;
134         add_tool(new BC_Title(x, y, _("Desaturation threshold")));
135         x += 170;
136         add_tool(desat_on = new DiffKeyToggle(client, 
137                 &(client->config.desat_on), 
138                 "",
139                 x, 
140                 y));
141         x -= 170;
142         y += 30;
143         add_tool(desat_thresh = new DiffKeySlider(client,
144                 &(client->config.desat_thresh),
145                 x,
146                 y));
147         y += 30;
148 /*      add_tool(add_key_frame = new DiffKeyAddButton(client,
149                 x,
150                 y));
151         y += 40;*/// This button doesn't do anything yet.
161         x = 220;
162         y = 10;
163         add_tool(new BC_Title(x, y, _("Red sensitivity")));
164         x += 170;
165         add_tool(r_on = new DiffKeyToggle(client, 
166                 &(client->config.r_on), 
167                 "",
168                 x, 
169                 y));
170         x -= 170;
171         y += 30;
172         add_tool(r_imp = new DiffKeySlider(client,
173                 &(client->config.r_imp),
174                 x,
175                 y));
176         y += 30;
177         add_tool(new BC_Title(x, y, _("Green sensitivity")));
178         x += 170;
179         add_tool(g_on = new DiffKeyToggle(client, 
180                 &(client->config.g_on), 
181                 "",
182                 x, 
183                 y));
184         x -= 170;
185         y += 30;
186         add_tool(g_imp = new DiffKeySlider(client,
187                 &(client->config.g_imp),
188                 x,
189                 y));
190         y += 30;
191         add_tool(new BC_Title(x, y, _("Blue sensitivity")));
192         x += 170;
193         add_tool(b_on = new DiffKeyToggle(client, 
194                 &(client->config.b_on), 
195                 "",
196                 x, 
197                 y));
198         x -= 170;
199         y += 30;
200         add_tool(b_imp = new DiffKeySlider(client,
201                 &(client->config.b_imp),
202                 x,
203                 y));
204         y += 30;
205         add_tool(new BC_Title(x, y, _("Transparency threshold")));
206         x += 170;
207         add_tool(trans_on = new DiffKeyToggle(client, 
208                 &(client->config.trans_on), 
209                 "",
210                 x, 
211                 y));
212         x -= 170;
213         y += 30;
214         add_tool(trans_thresh = new DiffKeySlider(client,
215                 &(client->config.trans_thresh),
216                 x,
217                 y));
218         x += 25;
219         y += 25; // was 30
220         add_tool(reset_key_frame = new DiffKeyResetButton(client,
221                 x,
222                 y));
223         x += 15;
224         y += 30;
225 //      y += 30;
226         add_tool(show_mask = new DiffKeyToggle(client, 
227                 &(client->config.show_mask), 
228                 "Show mask",
229                 x, 
230                 y));
231         y += 40;
236 #endif
238         show_window();
239         flush();
253 int DiffKeyWindow::close_event()
255         #ifdef DEBUG
256                 printf("\nClosing window....");
257         #endif
258         set_done(1);
259         return 1;
262 DiffKeyToggle::DiffKeyToggle(DiffKeyMain *client, int *output, char *string, int x, int y)
263  : BC_CheckBox(x, y, *output, string)
265         #ifdef DEBUG
266         printf("\nDiffKeyToggle::DiffKeyToggle");
267         #endif
268         this->client = client;
269         this->output = output;
271 DiffKeyToggle::~DiffKeyToggle()
273         #ifdef DEBUG
274         printf("\nDiffKeyToggle::~DiffKeyToggle");
275         #endif
277 int DiffKeyToggle::handle_event()
279 #ifdef DEBUG
280         printf("\nToggle changed from %i", *output);
281 #endif
282         *output = get_value();
283         client->send_configure_change();
284 #ifdef DEBUG
285         printf(" to %i", *output);
286         printf("\n");
287         printf("\n");
288 #endif
289         return 1;
293 DiffKeyResetButton::DiffKeyResetButton(DiffKeyMain *client, int x, int y) : BC_GenericButton(x, y, "Reset key frame")
295         #ifdef DEBUG
296         printf("\nDiffKeyResetButton::DiffKeyResetButton");
297         #endif
298         this->client = client;
301 int DiffKeyResetButton::handle_event()
303 #ifdef DEBUG
304         printf("\nReset frame button pressed.");
305         printf("\ngrab_key_frame changed from %i", grab_key_frame);
306 #endif
308         grab_key_frame = 1;
309         client->send_configure_change();
310 #ifdef DEBUG
311         printf(" to %i", grab_key_frame);
312         printf("\n");
313         printf("\n");
314 #endif
315         return 1;
319 DiffKeyAddButton::DiffKeyAddButton(DiffKeyMain *client, int x, int y) : BC_GenericButton(x, y, "Add key frame")
321         #ifdef DEBUG
322         printf("\nDiffKeyAddButton::DiffKeyAddButton");
323         #endif
324         this->client = client;
327 int DiffKeyAddButton::handle_event()
329 #ifdef DEBUG
330         printf("\nAdd frame button pressed.");
331         printf("\nadd_key_frame changed from %i", add_key_frame);
332 #endif
334         add_key_frame = 1;
335         client->send_configure_change();
336 #ifdef DEBUG
337         printf(" to %i", add_key_frame);
338         printf("\n");
339         printf("\n");
340 #endif
341         return 1;
345 DiffKeySlider::DiffKeySlider(DiffKeyMain *client, 
346         float *output, 
347         int x, 
348         int y)
349  : BC_ISlider(x, 
350         y, 
351         0, 
352         200, 
353         200,
354         0, 
355         100, 
356         (int)*output)
358         #ifdef DEBUG
359         printf("\nDiffKeySlider::DiffKeySlider");
360         #endif
361         this->client = client;
362         this->output = output;
365 int DiffKeySlider::handle_event()
367         *output = get_value();
368         client->send_configure_change();
369         return 1;