add bluray support, add dialog close fixes, scale fix
[goodguy/history.git] / cinelerra-5.0 / 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 start();
232         void run();
233
234         ChannelEditThread *edit;
235         int interrupt;
236         BC_ProgressBox *progress;
237 };
238
239
240
241
242
243
244
245 // ============================= Edit a single channel
246
247 class ChannelEditEditSource;
248 class ChannelEditEditWindow;
249
250 class ChannelEditEditThread : public Thread
251 {
252 public:
253         ChannelEditEditThread(ChannelEditWindow *window, 
254                 ChannelPicker *channel_picker);
255         ~ChannelEditEditThread();
256
257         void run();
258         int edit_channel(Channel *channel, int editing);
259         void set_device();       // Set the device to the new channel
260         void change_source(const char *source_name);  // Change to the source matching the name
261         void change_source(char *source_name);   // Change to the source matching the name
262         void source_up();
263         void source_down();
264         void set_input(int value);
265         void set_norm(int value);
266         void set_freqtable(int value);
267         void close_threads();
268
269         Channel new_channel;
270         Channel *output_channel;
271         ChannelPicker *channel_picker;
272         ChannelEditWindow *window;
273         ChannelEditEditSource *source_text;
274         ChannelEditEditWindow *edit_window;
275         int editing;   // Tells whether or not to delete the channel on cancel
276         int in_progress;   // Allow only 1 thread at a time
277         int user_title;
278         Condition *completion;
279 };
280
281 class ChannelEditEditTitle;
282
283
284 class ChannelEditEditWindow : public BC_Window
285 {
286 public:
287         ChannelEditEditWindow(ChannelEditEditThread *thread, 
288                 ChannelEditWindow *window,
289                 ChannelPicker *channel_picker);
290         ~ChannelEditEditWindow();
291         void create_objects(Channel *channel);
292
293         ChannelEditEditThread *thread;
294         ChannelEditWindow *window;
295         ChannelEditEditTitle *title_text;
296         Channel *new_channel;
297         ChannelPicker *channel_picker;
298 };
299
300 class ChannelEditEditTitle : public BC_TextBox
301 {
302 public:
303         ChannelEditEditTitle(int x, int y, ChannelEditEditThread *thread);
304         ~ChannelEditEditTitle();
305         int handle_event();
306         ChannelEditEditThread *thread;
307 };
308
309 class ChannelEditEditSource : public BC_TextBox
310 {
311 public:
312         ChannelEditEditSource(int x, int y, ChannelEditEditThread *thread);
313         ~ChannelEditEditSource();
314         int handle_event();
315         ChannelEditEditThread *thread;
316 };
317
318 class ChannelEditEditSourceTumbler : public BC_Tumbler
319 {
320 public:
321         ChannelEditEditSourceTumbler(int x, int y, ChannelEditEditThread *thread);
322         ~ChannelEditEditSourceTumbler();
323         int handle_up_event();
324         int handle_down_event();
325         ChannelEditEditThread *thread;
326 };
327
328 class ChannelEditEditInput : public BC_PopupMenu
329 {
330 public:
331         ChannelEditEditInput(int x, 
332                 int y, 
333                 ChannelEditEditThread *thread, 
334                 ChannelEditThread *edit);
335         ~ChannelEditEditInput();
336         void add_items();
337         int handle_event();
338         ChannelEditEditThread *thread;
339         ChannelEditThread *edit;
340 };
341
342 class ChannelEditEditInputItem : public BC_MenuItem
343 {
344 public:
345         ChannelEditEditInputItem(ChannelEditEditThread *thread, 
346                 ChannelEditThread *edit,
347                 char *text, 
348                 int value);
349         ~ChannelEditEditInputItem();
350         int handle_event();
351         ChannelEditEditThread *thread;
352         ChannelEditThread *edit;
353         int value;
354 };
355
356 class ChannelEditEditNorm : public BC_PopupMenu
357 {
358 public:
359         ChannelEditEditNorm(int x, 
360                 int y, 
361                 ChannelEditEditThread *thread,
362                 ChannelEditThread *edit);
363         ~ChannelEditEditNorm();
364         void add_items();
365         ChannelEditEditThread *thread;
366         ChannelEditThread *edit;
367 };
368
369 class ChannelEditEditNormItem : public BC_MenuItem
370 {
371 public:
372         ChannelEditEditNormItem(ChannelEditEditThread *thread, 
373                 ChannelEditThread *edit,
374                 char *text, 
375                 int value);
376         ~ChannelEditEditNormItem();
377         int handle_event();
378         ChannelEditEditThread *thread;
379         ChannelEditThread *edit;
380         int value;
381 };
382
383 class ChannelEditEditFreqtable : public BC_PopupMenu
384 {
385 public:
386         ChannelEditEditFreqtable(int x, 
387                 int y, 
388                 ChannelEditEditThread *thread,
389                 ChannelEditThread *edit);
390         ~ChannelEditEditFreqtable();
391
392         void add_items();
393
394         ChannelEditEditThread *thread;
395         ChannelEditThread *edit;
396 };
397
398 class ChannelEditEditFreqItem : public BC_MenuItem
399 {
400 public:
401         ChannelEditEditFreqItem(ChannelEditEditThread *thread, 
402                 ChannelEditThread *edit,
403                 char *text, 
404                 int value);
405         ~ChannelEditEditFreqItem();
406
407         int handle_event();
408         ChannelEditEditThread *thread;
409         ChannelEditThread *edit;
410         int value;
411 };
412
413 class ChannelEditEditFine : public BC_ISlider
414 {
415 public:
416         ChannelEditEditFine(int x, int y, ChannelEditEditThread *thread);
417         ~ChannelEditEditFine();
418         int handle_event();
419         int button_release_event();
420         ChannelEditEditThread *thread;
421 };
422
423 // =================== Edit the picture quality
424
425
426 class ChannelEditPictureWindow;
427
428 class ChannelEditPictureThread : public BC_DialogThread
429 {
430 public:
431         ChannelEditPictureThread(ChannelPicker *channel_picker);
432         ~ChannelEditPictureThread();
433
434         void handle_done_event(int result);
435         BC_Window* new_gui();
436         void edit_picture();
437
438         ChannelPicker *channel_picker;
439 };
440
441 class ChannelEditPictureWindow : public BC_Window
442 {
443 public:
444         ChannelEditPictureWindow(ChannelEditPictureThread *thread, 
445                 ChannelPicker *channel_picker);
446         ~ChannelEditPictureWindow();
447
448         int calculate_h(ChannelPicker *channel_picker);
449         int calculate_w(ChannelPicker *channel_picker);
450         void create_objects();
451         int translation_event();
452
453         ChannelEditPictureThread *thread;
454         ChannelPicker *channel_picker;
455 };
456
457 class ChannelEditBright : public BC_IPot
458 {
459 public:
460         ChannelEditBright(int x, int y, ChannelPicker *channel_picker, int value);
461         ~ChannelEditBright();
462         int handle_event();
463         int button_release_event();
464         ChannelPicker *channel_picker;
465 };
466
467 class ChannelEditContrast : public BC_IPot
468 {
469 public:
470         ChannelEditContrast(int x, int y, ChannelPicker *channel_picker, int value);
471         ~ChannelEditContrast();
472         int handle_event();
473         int button_release_event();
474         ChannelPicker *channel_picker;
475 };
476
477 class ChannelEditColor : public BC_IPot
478 {
479 public:
480         ChannelEditColor(int x, int y, ChannelPicker *channel_picker, int value);
481         ~ChannelEditColor();
482         int handle_event();
483         int button_release_event();
484         ChannelPicker *channel_picker;
485 };
486
487 class ChannelEditHue : public BC_IPot
488 {
489 public:
490         ChannelEditHue(int x, int y, ChannelPicker *channel_picker, int value);
491         ~ChannelEditHue();
492         int handle_event();
493         int button_release_event();
494         ChannelPicker *channel_picker;
495 };
496
497 class ChannelEditWhiteness : public BC_IPot
498 {
499 public:
500         ChannelEditWhiteness(int x, int y, ChannelPicker *channel_picker, int value);
501         ~ChannelEditWhiteness();
502         int handle_event();
503         int button_release_event();
504         ChannelPicker *channel_picker;
505 };
506
507
508
509 class ChannelEditCommon : public BC_IPot
510 {
511 public:;
512         ChannelEditCommon(int x, 
513                 int y, 
514                 ChannelPicker *channel_picker,
515                 PictureItem *item);
516         ~ChannelEditCommon();
517         int handle_event();
518         int button_release_event();
519         int keypress_event();
520         ChannelPicker *channel_picker;
521         int device_id;
522 };
523
524
525
526 #endif