fix delete clip deadlock
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / channeledit.h
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 #ifndef CHANNELEDIT_H
23 #define CHANNELEDIT_H
24
25 #include "bcdialog.h"
26 #include "bcprogressbox.inc"
27 #include "guicast.h"
28 #include "channel.inc"
29 #include "channeldb.inc"
30 #include "channelpicker.inc"
31 #include "condition.inc"
32 #include "mutex.inc"
33 #include "picture.inc"
34 #include "record.h"
35
36 class ChannelEditWindow;
37 class ScanThread;
38
39 class ChannelEditThread : public Thread
40 {
41 public:
42         ChannelEditThread(ChannelPicker *channel_picker,
43                 ChannelDB *channeldb);
44         ~ChannelEditThread();
45         void run();
46         void close_threads();
47         char* value_to_freqtable(int value);
48         char* value_to_norm(int value);
49         char* value_to_input(int value);
50
51         Condition *completion;
52         int in_progress;
53         int current_channel;
54         Channel scan_params;
55         ChannelPicker *channel_picker;
56         ChannelDB *channeldb;
57         ChannelDB *new_channels;
58         ChannelEditWindow *window;
59         ScanThread *scan_thread;
60 };
61
62 class ChannelEditList;
63 class ChannelEditEditThread;
64 class ChannelEditPictureThread;
65 class ConfirmScanThread;
66
67 class  ChannelEditWindow : public BC_Window
68 {
69 public:
70         ChannelEditWindow(ChannelEditThread *thread,
71                 ChannelPicker *channel_picker);
72         ~ChannelEditWindow();
73
74         void create_objects();
75         int translation_event();
76         int close_event();
77         int add_channel();  // Start the thread for adding a channel
78         void delete_channel(int channel);
79         void delete_channel(Channel *channel);
80         void edit_channel();
81         void edit_picture();
82         void update_list();  // Synchronize the list box with the channel arrays
83         void update_list(Channel *channel);  // Synchronize the list box and the channel
84         int update_output();
85         int move_channel_up();
86         int move_channel_down();
87         int change_channel_from_list(int channel_number);
88         void get_chan_num(Channel *channel, int &chan, int &stream);
89         void sort();
90         void scan_confirm();
91         void scan();
92
93
94         ArrayList<BC_ListBoxItem*> channel_list;
95         ChannelEditList *list_box;
96         ChannelEditThread *thread;
97         ChannelPicker *channel_picker;
98         ChannelEditEditThread *edit_thread;
99         ChannelEditPictureThread *picture_thread;
100         ConfirmScanThread *scan_confirm_thread;
101 };
102
103 class ChannelEditSelect : public BC_GenericButton
104 {
105 public:
106         ChannelEditSelect(ChannelEditWindow *window, int x, int y);
107         ~ChannelEditSelect();
108         int handle_event();
109         ChannelEditWindow *window;
110 };
111
112
113 class ChannelEditAdd : public BC_GenericButton
114 {
115 public:
116         ChannelEditAdd(ChannelEditWindow *window, int x, int y);
117         ~ChannelEditAdd();
118         int handle_event();
119         ChannelEditWindow *window;
120 };
121
122 class ChannelEditList : public BC_ListBox
123 {
124 public:
125         ChannelEditList(ChannelEditWindow *window, int x, int y);
126         ~ChannelEditList();
127         int handle_event();
128         ChannelEditWindow *window;
129         static char *column_titles[2];
130 };
131
132 class ChannelEditMoveUp : public BC_GenericButton
133 {
134 public:
135         ChannelEditMoveUp(ChannelEditWindow *window, int x, int y);
136         ~ChannelEditMoveUp();
137         int handle_event();
138         ChannelEditWindow *window;
139 };
140
141 class ChannelEditMoveDown : public BC_GenericButton
142 {
143 public:
144         ChannelEditMoveDown(ChannelEditWindow *window, int x, int y);
145         ~ChannelEditMoveDown();
146         int handle_event();
147         ChannelEditWindow *window;
148 };
149
150 class ChannelEditSort : public BC_GenericButton
151 {
152 public:
153         ChannelEditSort(ChannelEditWindow *window, int x, int y);
154         int handle_event();
155         ChannelEditWindow *window;
156 };
157
158 class ChannelEditScan : public BC_GenericButton
159 {
160 public:
161         ChannelEditScan(ChannelEditWindow *window, int x, int y);
162         int handle_event();
163         ChannelEditWindow *window;
164 };
165
166 class ChannelEditDel : public BC_GenericButton
167 {
168 public:
169         ChannelEditDel(ChannelEditWindow *window, int x, int y);
170         ~ChannelEditDel();
171         int handle_event();
172         ChannelEditWindow *window;
173 };
174
175 class ChannelEdit : public BC_GenericButton
176 {
177 public:
178         ChannelEdit(ChannelEditWindow *window, int x, int y);
179         ~ChannelEdit();
180         int handle_event();
181         ChannelEditWindow *window;
182 };
183
184 class ChannelEditPicture : public BC_GenericButton
185 {
186 public:
187         ChannelEditPicture(ChannelEditWindow *window, int x, int y);
188         ~ChannelEditPicture();
189         int handle_event();
190         ChannelEditWindow *window;
191 };
192
193
194
195
196
197
198
199 // ============================== Confirm overwrite with scanning
200
201 class ConfirmScan : public BC_Window
202 {
203 public:
204         ConfirmScan(ChannelEditWindow *gui, int x, int y);
205         void create_objects();
206         ChannelEditWindow *gui;
207 };
208
209 class ConfirmScanThread : public BC_DialogThread
210 {
211 public:
212         ConfirmScanThread(ChannelEditWindow *gui);
213         ~ConfirmScanThread();
214         void handle_done_event(int result);
215         BC_Window* new_gui();
216         ChannelEditWindow *gui;
217 };
218
219
220
221
222
223 // ============================= Scan
224
225 class ScanThread : public Thread
226 {
227 public:
228         ScanThread(ChannelEditThread *edit);
229         ~ScanThread();
230
231         void stop();
232         void start();
233         void run();
234
235         ChannelEditThread *edit;
236         int interrupt;
237         BC_ProgressBox *progress;
238 };
239
240
241
242
243
244
245
246 // ============================= Edit a single channel
247
248 class ChannelEditEditSource;
249 class ChannelEditEditWindow;
250
251 class ChannelEditEditThread : public Thread
252 {
253 public:
254         ChannelEditEditThread(ChannelEditWindow *window,
255                 ChannelPicker *channel_picker);
256         ~ChannelEditEditThread();
257
258         void run();
259         int edit_channel(Channel *channel, int editing);
260         void set_device();       // Set the device to the new channel
261         void change_source(const char *source_name);  // Change to the source matching the name
262         void change_source(char *source_name);   // Change to the source matching the name
263         void source_up();
264         void source_down();
265         void set_input(int value);
266         void set_norm(int value);
267         void set_freqtable(int value);
268         void close_threads();
269
270         Channel new_channel;
271         Channel *output_channel;
272         ChannelPicker *channel_picker;
273         ChannelEditWindow *window;
274         ChannelEditEditSource *source_text;
275         ChannelEditEditWindow *edit_window;
276         int editing;   // Tells whether or not to delete the channel on cancel
277         int in_progress;   // Allow only 1 thread at a time
278         int user_title;
279         Condition *completion;
280 };
281
282 class ChannelEditEditTitle;
283
284
285 class ChannelEditEditWindow : public BC_Window
286 {
287 public:
288         ChannelEditEditWindow(ChannelEditEditThread *thread,
289                 ChannelEditWindow *window,
290                 ChannelPicker *channel_picker);
291         ~ChannelEditEditWindow();
292         void create_objects(Channel *channel);
293
294         ChannelEditEditThread *thread;
295         ChannelEditWindow *window;
296         ChannelEditEditTitle *title_text;
297         Channel *new_channel;
298         ChannelPicker *channel_picker;
299 };
300
301 class ChannelEditEditTitle : public BC_TextBox
302 {
303 public:
304         ChannelEditEditTitle(int x, int y, ChannelEditEditThread *thread);
305         ~ChannelEditEditTitle();
306         int handle_event();
307         ChannelEditEditThread *thread;
308 };
309
310 class ChannelEditEditSource : public BC_TextBox
311 {
312 public:
313         ChannelEditEditSource(int x, int y, ChannelEditEditThread *thread);
314         ~ChannelEditEditSource();
315         int handle_event();
316         ChannelEditEditThread *thread;
317 };
318
319 class ChannelEditEditSourceTumbler : public BC_Tumbler
320 {
321 public:
322         ChannelEditEditSourceTumbler(int x, int y, ChannelEditEditThread *thread);
323         ~ChannelEditEditSourceTumbler();
324         int handle_up_event();
325         int handle_down_event();
326         ChannelEditEditThread *thread;
327 };
328
329 class ChannelEditEditInput : public BC_PopupMenu
330 {
331 public:
332         ChannelEditEditInput(int x,
333                 int y,
334                 ChannelEditEditThread *thread,
335                 ChannelEditThread *edit);
336         ~ChannelEditEditInput();
337         void add_items();
338         int handle_event();
339         ChannelEditEditThread *thread;
340         ChannelEditThread *edit;
341 };
342
343 class ChannelEditEditInputItem : public BC_MenuItem
344 {
345 public:
346         ChannelEditEditInputItem(ChannelEditEditThread *thread,
347                 ChannelEditThread *edit,
348                 char *text,
349                 int value);
350         ~ChannelEditEditInputItem();
351         int handle_event();
352         ChannelEditEditThread *thread;
353         ChannelEditThread *edit;
354         int value;
355 };
356
357 class ChannelEditEditNorm : public BC_PopupMenu
358 {
359 public:
360         ChannelEditEditNorm(int x,
361                 int y,
362                 ChannelEditEditThread *thread,
363                 ChannelEditThread *edit);
364         ~ChannelEditEditNorm();
365         void add_items();
366         ChannelEditEditThread *thread;
367         ChannelEditThread *edit;
368 };
369
370 class ChannelEditEditNormItem : public BC_MenuItem
371 {
372 public:
373         ChannelEditEditNormItem(ChannelEditEditThread *thread,
374                 ChannelEditThread *edit,
375                 char *text,
376                 int value);
377         ~ChannelEditEditNormItem();
378         int handle_event();
379         ChannelEditEditThread *thread;
380         ChannelEditThread *edit;
381         int value;
382 };
383
384 class ChannelEditEditFreqtable : public BC_PopupMenu
385 {
386 public:
387         ChannelEditEditFreqtable(int x,
388                 int y,
389                 ChannelEditEditThread *thread,
390                 ChannelEditThread *edit);
391         ~ChannelEditEditFreqtable();
392
393         void add_items();
394
395         ChannelEditEditThread *thread;
396         ChannelEditThread *edit;
397 };
398
399 class ChannelEditEditFreqItem : public BC_MenuItem
400 {
401 public:
402         ChannelEditEditFreqItem(ChannelEditEditThread *thread,
403                 ChannelEditThread *edit,
404                 char *text,
405                 int value);
406         ~ChannelEditEditFreqItem();
407
408         int handle_event();
409         ChannelEditEditThread *thread;
410         ChannelEditThread *edit;
411         int value;
412 };
413
414 class ChannelEditEditFine : public BC_ISlider
415 {
416 public:
417         ChannelEditEditFine(int x, int y, ChannelEditEditThread *thread);
418         ~ChannelEditEditFine();
419         int handle_event();
420         int button_release_event();
421         ChannelEditEditThread *thread;
422 };
423
424 // =================== Edit the picture quality
425
426
427 class ChannelEditPictureWindow;
428
429 class ChannelEditPictureThread : public BC_DialogThread
430 {
431 public:
432         ChannelEditPictureThread(ChannelPicker *channel_picker);
433         ~ChannelEditPictureThread();
434
435         void handle_done_event(int result);
436         BC_Window* new_gui();
437         void edit_picture();
438
439         ChannelPicker *channel_picker;
440         void close_threads();
441 };
442
443 class ChannelEditPictureWindow : public BC_Window
444 {
445 public:
446         ChannelEditPictureWindow(ChannelEditPictureThread *thread,
447                 ChannelPicker *channel_picker);
448         ~ChannelEditPictureWindow();
449
450         int calculate_h(ChannelPicker *channel_picker);
451         int calculate_w(ChannelPicker *channel_picker);
452         void create_objects();
453         int translation_event();
454
455         ChannelEditPictureThread *thread;
456         ChannelPicker *channel_picker;
457 };
458
459 class ChannelEditBright : public BC_IPot
460 {
461 public:
462         ChannelEditBright(int x, int y, ChannelPicker *channel_picker, int value);
463         ~ChannelEditBright();
464         int handle_event();
465         int button_release_event();
466         ChannelPicker *channel_picker;
467 };
468
469 class ChannelEditContrast : public BC_IPot
470 {
471 public:
472         ChannelEditContrast(int x, int y, ChannelPicker *channel_picker, int value);
473         ~ChannelEditContrast();
474         int handle_event();
475         int button_release_event();
476         ChannelPicker *channel_picker;
477 };
478
479 class ChannelEditColor : public BC_IPot
480 {
481 public:
482         ChannelEditColor(int x, int y, ChannelPicker *channel_picker, int value);
483         ~ChannelEditColor();
484         int handle_event();
485         int button_release_event();
486         ChannelPicker *channel_picker;
487 };
488
489 class ChannelEditHue : public BC_IPot
490 {
491 public:
492         ChannelEditHue(int x, int y, ChannelPicker *channel_picker, int value);
493         ~ChannelEditHue();
494         int handle_event();
495         int button_release_event();
496         ChannelPicker *channel_picker;
497 };
498
499 class ChannelEditWhiteness : public BC_IPot
500 {
501 public:
502         ChannelEditWhiteness(int x, int y, ChannelPicker *channel_picker, int value);
503         ~ChannelEditWhiteness();
504         int handle_event();
505         int button_release_event();
506         ChannelPicker *channel_picker;
507 };
508
509
510
511 class ChannelEditCommon : public BC_IPot
512 {
513 public:;
514         ChannelEditCommon(int x,
515                 int y,
516                 ChannelPicker *channel_picker,
517                 PictureItem *item);
518         ~ChannelEditCommon();
519         int handle_event();
520         int button_release_event();
521         int keypress_event();
522         ChannelPicker *channel_picker;
523         int device_id;
524 };
525
526
527
528 #endif