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