initial commit
[goodguy/history.git] / cinelerra-5.0 / cinelerra / channelinfo.h
1 #ifndef CHANNELINFO_H
2 #define CHANNELINFO_H
3
4 #include "channel.inc"
5 #include "channeldb.h"
6 #include "channelinfo.inc"
7 #include "devicedvbinput.h"
8 #include "guicast.h"
9 #include "mwindow.inc"
10 #include "record.inc"
11 #include "recordbatches.h"
12 #include "signalstatus.h"
13 #include "videodevice.inc"
14 #include "vdevicempeg.inc"
15
16 #define LTBLACK 0x001c1c1c
17
18
19 class ChanSearch : public Thread
20 {
21 public:
22         ChannelInfo *iwindow;
23         ChanSearchGUI *gui;
24         Mutex *window_lock;
25
26         void start();
27         void stop();
28         void run();
29
30         ChanSearch(ChannelInfo *iwindow);
31         ~ChanSearch();
32 };
33
34 class ChanSearchGUI : public BC_Window
35 {
36 public:
37         ChanSearch *cswindow;
38         ChannelInfo *iwindow;
39         ChannelPanel *panel;
40         ChanSearchText *search_text;
41         ChanSearchTitleText *title_text;
42         ChanSearchInfoText *info_text;
43         ChanSearchMatchCase *match_case;
44         ChanSearchStart *search_start;
45         ChanSearchCancel *cancel;
46         ChanSearchList *search_list;
47         BC_Title *click_tip;
48         BC_Title *results;
49
50         int title_text_enable;
51         int info_text_enable;
52         int match_case_enable;
53         ChannelEvent *highlighted_event;
54         int search_x, search_y, text_x, text_y;
55         int cancel_x, cancel_y, cancel_w, cancel_h;
56         int list_x, list_y, list_w, list_h;
57         int results_x, results_y;
58         int sort_column, sort_order;
59
60         const char *search_column_titles[3];
61         int search_column_widths[3];
62         int search_columns[3];
63         ArrayList<BC_ListBoxItem*> search_items[3];
64         ArrayList<ChannelEvent*> search_results;
65
66         void create_objects();
67         int close_event();
68         int resize_event(int x, int y);
69         void update();
70         int search(const char *);
71         void search();
72         static int cmpr_text_dn(const void *a, const void *b);
73         static int cmpr_Text_dn(const void *a, const void *b);
74         static int cmpr_text_up(const void *a, const void *b);
75         static int cmpr_Text_up(const void *a, const void *b);
76         static int cmpr_time_dn(const void *a, const void *b);
77         static int cmpr_time_up(const void *a, const void *b);
78         static int cmpr_title_dn(const void *a, const void *b);
79         static int cmpr_Title_dn(const void *a, const void *b);
80         static int cmpr_title_up(const void *a, const void *b);
81         static int cmpr_Title_up(const void *a, const void *b);
82         void sort_events(int column, int order);
83         void move_column(int src, int dst);
84
85         ChanSearchGUI(ChanSearch *cswindow);
86         ~ChanSearchGUI();
87 };
88
89 class ChanSearchTitleText : public BC_CheckBox
90 {
91 public:
92         ChanSearchGUI *gui;
93
94         int handle_event();
95         void update(int v) { set_value(gui->title_text_enable = v); }
96
97         ChanSearchTitleText(ChanSearchGUI *gui, int x, int y);
98         ~ChanSearchTitleText();
99 };
100
101 class ChanSearchInfoText : public BC_CheckBox
102 {
103 public:
104         ChanSearchGUI *gui;
105
106         int handle_event();
107         void update(int v) { set_value(gui->info_text_enable = v); }
108
109         ChanSearchInfoText(ChanSearchGUI *gui, int x, int y);
110         ~ChanSearchInfoText();
111 };
112
113 class ChanSearchMatchCase : public BC_CheckBox
114 {
115 public:
116         ChanSearchGUI *gui;
117
118         int handle_event();
119
120         ChanSearchMatchCase(ChanSearchGUI *gui, int x, int y);
121         ~ChanSearchMatchCase();
122 };
123
124 class ChanSearchText : public BC_TextBox
125 {
126 public:
127         ChanSearchGUI *gui;
128
129         int handle_event();
130         int keypress_event();
131
132         ChanSearchText(ChanSearchGUI *gui, int x, int y, int w);
133         ~ChanSearchText();
134 };
135
136 class ChanSearchStart : public BC_GenericButton
137 {
138 public:
139         ChanSearchGUI *gui;
140
141         int handle_event();
142
143         ChanSearchStart(ChanSearchGUI *gui, int x, int y);
144         ~ChanSearchStart();
145 };
146
147 class ChanSearchCancel : public BC_CancelButton
148 {
149 public:
150         ChanSearchGUI *gui;
151
152         int handle_event();
153
154         ChanSearchCancel(ChanSearchGUI *gui, int x, int y);
155         ~ChanSearchCancel();
156 };
157
158 class ChanSearchList : public BC_ListBox
159 {
160 public:
161         ChanSearchGUI *gui;
162
163         int handle_event();
164         int sort_order_event();
165         int move_column_event();
166
167         ChanSearchList(ChanSearchGUI *gui, int x, int y, int w, int h);
168         ~ChanSearchList();
169 };
170
171
172 class ChannelProgress : public Thread, public BC_SubWindow
173 {
174         ChannelInfoGUI *gui;
175         BC_Title *eta;
176         BC_ProgressBar *bar;
177         Timer *eta_timer;
178         double length, value;
179         int done;
180 public:
181         void create_objects();
182         void run();
183         void start();
184         void stop();
185         int update();
186         void set_value(int v) { value = v; }
187
188         ChannelProgress(ChannelInfoGUI *gui, int x, int y, int w, int h, int len);
189         ~ChannelProgress();
190 };
191
192
193
194 class ChannelPanel : public BC_SubWindow
195 {
196 public:
197         ChannelInfoGUI *gui;
198         TimeLine *time_line;
199         ChannelData *channel_data;
200         ChannelFrame *channel_frame;
201         ChannelScroll *channel_scroll;
202         TimeLineScroll *time_line_scroll;
203         ArrayList<TimeLineItem*> time_line_items;
204         ArrayList<ChannelDataItem*> channel_data_items;
205         ArrayList<ChannelEventLine *> channel_line_items;
206         ArrayList<ChannelEvent*> channel_event_items;
207
208         int x0, y0, x1, y1, t0, t1;
209         int iwd, iht;
210         int x_moved, y_moved;
211         int iwindow_w, iwindow_h;
212         int path_w, path_h, hhr_w, x_now;
213         int frame_x, frame_y;
214         int frame_w, frame_h;
215         int x_scroll, y_scroll;
216         struct timeval tv;
217         struct timezone tz;
218         time_t st_org;
219
220         void create_objects();
221         ChannelEventLine *NewChannelLine(int y, int h, int color);
222         ChannelEventLine *NewChannelLine(int y) {
223                 return NewChannelLine(y, path_h, LTBLACK);
224         }
225         int separator(int y) {
226                 NewChannelLine(y+path_h/8, path_h/4, BLACK);
227                 return path_h/2;
228         }
229         void resize(int w, int h);
230         void bounding_box(int ix0, int iy0, int ix1, int iy1);
231         void set_x_scroll(int v);
232         void set_y_scroll(int v);
233         void reposition();
234         void get_xtime(int x, char *text);
235         void time_line_update(int ix0, int ix1);
236         int button_press_event();
237
238         ChannelPanel(ChannelInfoGUI *gui, int x, int y, int w, int h);
239         ~ChannelPanel();
240 };
241
242 class TimeLineItem : public BC_Title
243 {
244 public:
245         ChannelPanel *panel;
246         int x0, y0;
247
248         TimeLineItem(ChannelPanel *panel, int x, int y, char *text);
249         ~TimeLineItem();
250 };
251
252 class TimeLine : public BC_SubWindow
253 {
254 public:
255         ChannelPanel *panel;
256         int resize_event(int w, int h);
257
258         TimeLine(ChannelPanel *panel);
259         ~TimeLine();
260 };
261
262 class ChannelDataItem : public BC_Title
263 {
264 public:
265         ChannelPanel *panel;
266         int x0, y0;
267         const char *tip_info;
268         int in_window, tooltip_done;
269
270         int cursor_enter_event();
271         int cursor_leave_event();
272         int repeat_event(int64_t duration);
273         void set_tooltip(const char *tip);
274
275         ChannelDataItem(ChannelPanel *panel, int x, int y, int w,
276                 int color, const char *text);
277         ~ChannelDataItem();
278 };
279
280 class ChannelData : public BC_SubWindow
281 {
282 public:
283         ChannelPanel *panel;
284
285         int resize_event(int w, int h);
286
287         ChannelData(ChannelPanel *panel, int x, int y, int w, int h);
288         ~ChannelData();
289 };
290
291 class ChannelScroll : public BC_ScrollBar
292 {
293 public:
294         ChannelPanel *panel;
295
296         int handle_event();
297
298         ChannelScroll(ChannelPanel *panel, int x, int y, int h);
299         ~ChannelScroll();
300 };
301
302 class TimeLineScroll : public BC_ScrollBar
303 {
304 public:
305         ChannelPanel *panel;
306
307         int handle_event();
308
309         TimeLineScroll(ChannelPanel *panel, int x, int y, int w);
310         ~TimeLineScroll();
311 };
312
313
314
315 class ChannelEvent : public BC_GenericButton
316 {
317 public:
318         ChannelEventLine *channel_line;
319         time_t start_time, end_time;
320         Channel *channel;
321         int x0, y0, no;
322         const char *tip_info;
323
324         int handle_event();
325         void set_tooltip(const char *tip);
326
327         ChannelEvent(ChannelEventLine *channel_line, Channel *channel,
328                 time_t start_time, time_t end_time, int x, int y, int w,
329                 const char *text);
330         ~ChannelEvent();
331 };
332
333 class ChannelEventLine : public BC_SubWindow
334 {
335 public:
336         ChannelPanel *panel;
337         int x0, y0;
338
339         void resize(int w, int h);
340
341         ChannelEventLine(ChannelPanel *panel, int x, int y, int w, int h, int color);
342         ~ChannelEventLine();
343 };
344
345 class ChannelFrame : public BC_SubWindow
346 {
347 public:
348         ChannelPanel *panel;
349
350         void resize(int w, int h);
351
352         ChannelFrame(ChannelPanel *panel);
353         ~ChannelFrame();
354 };
355
356
357
358 class ChannelInfoGUI : public BC_Window
359 {
360 public:
361         ChannelInfo *iwindow;
362         ChanSearch *channel_search;
363         ChannelPanel *panel;
364         ChannelProgress *progress;
365         ChannelStatus *channel_status;
366         ChannelInfoGUIBatches *batch_bay;
367         ChannelDir *channel_dir;
368         ChannelPath *channel_path;
369         ChannelStart *channel_start;
370         ChannelDuration *channel_duration;
371         ChannelSource *channel_source;
372         ChannelClearBatch *channel_clear_batch;
373         ChannelNewBatch *channel_new_batch;
374         ChannelDeleteBatch *channel_delete_batch;
375         TimeEntryTumbler *early_time, *late_time;
376         BC_Title *directory_title;
377         BC_Title *path_title;
378         BC_Title *start_title;
379         BC_Title *duration_title;
380         BC_Title *source_title;
381         BC_OKButton *ok;
382         BC_CancelButton *cancel;
383         ChannelInfoCron *channel_cron;
384         ChannelInfoPowerOff *channel_poweroff;
385         ChannelInfoFind *channel_find;
386         int x0, y0, title_w, data_w, pad;
387         int path_w, path_h, status_w;
388         int panel_w, panel_h, max_bay_w;
389         int bay_x, bay_y, bay_w, bay_h;
390         const char *cron_caption, *power_caption;
391         int cron_x, cron_y, cron_w, cron_h;
392         int power_x, power_y, power_w, power_h;
393         int find_x, find_y, find_h;
394         int ok_x, ok_y, ok_w, ok_h;
395         int cancel_x, cancel_y, cancel_w, cancel_h;
396
397         void create_objects();
398         void stop(int v);
399         int translation_event();
400         int resize_event(int w, int h);
401         int close_event();
402         void update_channel_tools();
403         void incr_event(int start_time_incr, int duration_incr);
404         void update_progress(int n) { progress->set_value(n); }
405
406         ChannelInfoGUI(ChannelInfo *iwindow, int x, int y, int w, int h);
407         ~ChannelInfoGUI();
408 };
409
410 class ChannelInfoOK : public BC_OKButton
411 {
412 public:
413         ChannelInfoGUI *gui;
414
415         int button_press_event();
416         int keypress_event();
417
418         ChannelInfoOK(ChannelInfoGUI *gui, int x, int y);
419         ~ChannelInfoOK();
420 };
421
422 class ChannelInfoCancel : public BC_CancelButton
423 {
424 public:
425         ChannelInfoGUI *gui;
426
427         int button_press_event();
428
429         ChannelInfoCancel(ChannelInfoGUI *gui, int x, int y);
430         ~ChannelInfoCancel();
431 };
432
433 class ChannelInfoCron : public BC_CheckBox
434 {
435 public:
436         ChannelInfoGUI *gui;
437
438         int handle_event();
439         ChannelInfoCron(ChannelInfoGUI *gui, int x, int y, int *value);
440         ~ChannelInfoCron();
441 };
442
443 class ChannelInfoPowerOff : public BC_CheckBox
444 {
445 public:
446         ChannelInfoGUI *gui;
447
448         int handle_event();
449
450         ChannelInfoPowerOff(ChannelInfoGUI *gui, int x, int y, int *value);
451         ~ChannelInfoPowerOff();
452 };
453
454 class ChannelInfoFind : public BC_GenericButton
455 {
456 public:
457         ChannelInfoGUI *gui;
458
459         int handle_event();
460         ChannelInfoFind(ChannelInfoGUI *gui, int x, int y);
461         ~ChannelInfoFind();
462 };
463
464
465 class ChannelInfoGUIBatches : public RecordBatchesGUI
466 {
467 public:
468         ChannelInfoGUI *gui;
469
470         int handle_event();
471         int selection_changed();
472
473         ChannelInfoGUIBatches(ChannelInfoGUI *gui,
474                 int x, int y, int w, int h);
475         ~ChannelInfoGUIBatches();
476 };
477
478 class ChannelDir : public RecordBatchesGUI::Dir
479 {
480 public:
481         ChannelInfoGUI *gui;
482
483         ChannelDir(ChannelInfoGUI *gui, const char *dir, int x, int y);
484 };
485
486 class ChannelPath : public RecordBatchesGUI::Path
487 {
488 public:
489         ChannelInfoGUI *gui;
490
491         ChannelPath(ChannelInfoGUI *gui, int x, int y);
492 };
493
494 class ChannelStart : public RecordBatchesGUI::StartTime
495 {
496 public:
497         ChannelInfoGUI *gui;
498
499         ChannelStart(ChannelInfoGUI *gui, int x, int y);
500 };
501
502 class ChannelDuration : public RecordBatchesGUI::Duration
503 {
504 public:
505         ChannelInfoGUI *gui;
506
507         ChannelDuration(ChannelInfoGUI *gui, int x, int y, int w);
508 };
509
510 class ChannelEarlyTime : public TimeEntryTumbler
511 {
512 public:
513         ChannelInfoGUI *gui;
514
515         int handle_up_event();
516         int handle_down_event();
517
518         ChannelEarlyTime(ChannelInfoGUI *gui, int x, int y,
519                 double *output_time);
520 };
521
522 class ChannelLateTime : public TimeEntryTumbler
523 {
524 public:
525         ChannelInfoGUI *gui;
526
527         int handle_up_event();
528         int handle_down_event();
529
530         ChannelLateTime(ChannelInfoGUI *gui, int x, int y,
531                 double *output_time);
532 };
533
534 class ChannelSource : public RecordBatchesGUI::Source
535 {
536 public:
537         ChannelInfoGUI *gui;
538         void create_objects();
539         int handle_event();
540         ChannelSource(ChannelInfoGUI *gui, int x, int y);
541 };
542
543
544 class ChannelNewBatch : public RecordBatchesGUI::NewBatch
545 {
546 public:
547         ChannelInfoGUI *gui;
548         int handle_event();
549         ChannelNewBatch(ChannelInfoGUI *gui, int x, int y);
550 };
551
552
553 class ChannelDeleteBatch : public RecordBatchesGUI::DeleteBatch
554 {
555 public:
556         ChannelInfoGUI *gui;
557         int handle_event();
558         ChannelDeleteBatch(ChannelInfoGUI *gui, int x, int y);
559 };
560
561 class ChannelClearBatch : public RecordBatchesGUI::ClearBatch
562 {
563 public:
564         ChannelInfoGUI *gui;
565         int handle_event();
566         ChannelClearBatch(ChannelInfoGUI *gui, int x, int y);
567 };
568
569
570
571 class ChannelInfo : public Thread
572 {
573 public:
574         MWindow *mwindow;
575         Record *record;
576         VideoDevice *vdevice;
577         Mutex *window_lock;
578         Mutex *vdevice_lock;
579         Mutex *progress_lock;
580         DeviceDVBInput *dvb_input;
581         RecordBatches record_batches;
582         ChannelInfoGUI *gui;
583         ChannelThread *thread;
584         ChannelDB *channeldb;
585         Condition *scan_lock;
586         int cron_enable, poweroff_enable;
587         int item;
588         int done, gui_done;
589
590         void run_scan();
591         void toggle_scan();
592         void start();
593         void stop();
594         void run();
595         void close_vdevice();
596         Batch *new_batch();
597         void delete_batch();
598         int current_batch() { return gui->batch_bay->current_batch(); }
599         int editing_batch() { return gui->batch_bay->editing_batch(); }
600         bool is_active() { return gui != 0; }
601
602         ChannelInfo(MWindow *mwindow);
603         ~ChannelInfo();
604 };
605
606 class ChannelThread : public Thread
607 {
608 public:
609         ChannelInfo *iwindow;
610         ChannelInfoGUI *gui;
611         ChannelPanel *panel;
612         zmpeg3_t *fd;
613         int done;
614
615         int load_ident(int n, int y, char *ident);
616         int load_info(Channel *channel, ChannelEventLine *channel_line);
617         void start();
618         void stop();
619         void run();
620         int total_channels() { return iwindow->channeldb->size(); }
621         Channel *get_channel(int ch) { return iwindow->channeldb->get(ch); }
622         int set_channel(Channel *chan);
623
624         ChannelThread(ChannelInfoGUI *gui);
625         ~ChannelThread();
626 };
627
628 class ChannelScan : public BC_MenuItem
629 {
630 public:
631         MWindow *mwindow;
632         int handle_event();
633
634         ChannelScan(MWindow *mwindow);
635         ~ChannelScan();
636 };
637
638 class ChannelStatus : public SignalStatus
639 {
640 public:
641         ChannelInfoGUI *gui;
642
643         ChannelStatus(ChannelInfoGUI *gui, int x, int y) :
644                 SignalStatus(gui, x, y) { this->gui = gui; }
645         ~ChannelStatus() {}
646 };
647
648
649
650 #endif