add libdav1d codec, add remap_a/v_codec option keywords
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / binfolder.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 NEWFOLDER_H
23 #define NEWFOLDER_H
24
25 #include "arraylist.h"
26 #include "awindowgui.inc"
27 #include "binfolder.inc"
28 #include "datatype.h"
29 #include "edl.inc"
30 #include "filesystem.h"
31 #include "guicast.h"
32 #include "indexable.h"
33 #include "mutex.h"
34 #include "mwindow.inc"
35
36 enum {
37         FOLDER_COLUMN_ENABLE,
38         FOLDER_COLUMN_TARGET,
39         FOLDER_COLUMN_OP,
40         FOLDER_COLUMN_VALUE,
41         FOLDER_COLUMNS
42 };
43
44 enum {
45         FOLDER_ENABLED_OFF,
46         FOLDER_ENABLED_AND,
47         FOLDER_ENABLED_OR,
48         FOLDER_ENABLED_AND_NOT,
49         FOLDER_ENABLED_OR_NOT,
50 };
51 enum {
52         FOLDER_TARGET_PATTERNS,
53         FOLDER_TARGET_FILE_SIZE,
54         FOLDER_TARGET_MOD_TIME,
55         FOLDER_TARGET_TRACK_TYPE,
56         FOLDER_TARGET_WIDTH,
57         FOLDER_TARGET_HEIGHT,
58         FOLDER_TARGET_FRAMERATE,
59         FOLDER_TARGET_SAMPLERATE,
60         FOLDER_TARGET_CHANNELS,
61         FOLDER_TARGET_DURATION,
62 };
63 enum {
64         FOLDER_OP_AROUND,
65         FOLDER_OP_EQ, FOLDER_OP_GE, FOLDER_OP_GT,
66         FOLDER_OP_NE, FOLDER_OP_LE, FOLDER_OP_LT,
67         FOLDER_OP_MATCHES,
68 };
69
70 class BinFolderFilters : public ArrayList<BinFolderFilter *>
71 {
72 public:
73         BinFolderFilters() {}
74         ~BinFolderFilters() { remove_all_objects(); }
75         void copy_from(BinFolderFilters *filters);
76         void clear() { remove_all_objects(); }
77 };
78
79 class BinFolder
80 {
81 public:
82         BinFolder(int awindow_folder, int is_clips, const char *title);
83         BinFolder(BinFolder &that);
84         ~BinFolder();
85
86         BinFolderFilters filters;
87         void save_xml(FileXML *file);
88         int load_xml(FileXML *file);
89         double matches_indexable(Indexable *idxbl);
90         void copy_from(BinFolder *that);
91         const char *get_idxbl_title(Indexable *idxbl);
92         int add_patterns(ArrayList<Indexable*> *drag_assets, int use_basename);
93
94         char title[BCSTRLEN];
95         int awindow_folder;
96         int is_clips;
97 };
98
99 class BinFolders : public ArrayList<BinFolder *>
100 {
101 public:
102         BinFolders() {}
103         ~BinFolders() {}
104         void save_xml(FileXML *file);
105         int load_xml(FileXML *file);
106         double matches_indexable(int folder, Indexable *idxbl);
107         void copy_from(BinFolders *that);
108         void clear() { remove_all_objects(); }
109 };
110
111 class BinFolderFilter
112 {
113 public:
114         BinFolderFilter();
115         ~BinFolderFilter();
116
117         void update_enabled(int type);
118         void update_target(int type);
119         void update_op(int type);
120         void update_value(const char *text);
121         void save_xml(FileXML *file);
122         int load_xml(FileXML *file);
123
124         BinFolderEnabled *enabled;
125         BinFolderTarget *target;
126         BinFolderOp *op;
127         BinFolderValue *value;
128 };
129
130 class BinFolderEnabled : public BC_ListBoxItem
131 {
132 public:
133         BinFolderEnabled(BinFolderFilter *filter, int type);
134         virtual ~BinFolderEnabled();
135         void update(int type);
136
137         BinFolderFilter *filter;
138         int type;
139         static const char *types[];
140 };
141
142 class BinFolderEnabledType : public BC_MenuItem
143 {
144 public:
145         BinFolderEnabledType(int no);
146         ~BinFolderEnabledType();
147         int no;
148         int handle_event();
149 };
150 class BinFolderEnabledPopup : public BC_PopupMenu
151 {
152 public:
153         BinFolderEnabledPopup(BinFolderList *folder_list);
154         void create_objects();
155         void activate_menu(BC_ListBoxItem *item);
156
157         BinFolderList *folder_list;
158         BinFolderEnabled *enabled;
159 };
160
161 class BinFolderTarget : public BC_ListBoxItem
162 {
163 public:
164         BinFolderTarget(BinFolderFilter *filter, int type);
165         virtual ~BinFolderTarget();
166
167         virtual void save_xml(FileXML *file) = 0;
168         virtual void load_xml(FileXML *file) = 0;
169         virtual void copy_from(BinFolderTarget *that) = 0;
170         virtual BC_Window *new_gui(ModifyTargetThread *thread) = 0;
171
172         BinFolderFilter *filter;
173         int type;
174         double around;
175         static const char *types[];
176 };
177
178 class BinFolderTargetPatterns : public BinFolderTarget
179 {
180 public:
181         BinFolderTargetPatterns(BinFolderFilter *filter);
182         ~BinFolderTargetPatterns();
183
184         void save_xml(FileXML *file);
185         void load_xml(FileXML *file);
186         void copy_from(BinFolderTarget *that);
187         BC_Window *new_gui(ModifyTargetThread *thread);
188         void update(const char *text);
189
190         char *text;
191 };
192
193 class BinFolderTargetFileSize : public BinFolderTarget
194 {
195 public:
196         BinFolderTargetFileSize(BinFolderFilter *filter);
197         ~BinFolderTargetFileSize();
198
199         void save_xml(FileXML *file);
200         void load_xml(FileXML *file);
201         void copy_from(BinFolderTarget *that);
202         BC_Window *new_gui(ModifyTargetThread *thread);
203         void update(int64_t file_size, double around);
204
205         int64_t file_size;
206 };
207
208 class BinFolderTargetTime : public BinFolderTarget
209 {
210 public:
211         BinFolderTargetTime(BinFolderFilter *filter);
212         ~BinFolderTargetTime();
213
214         void save_xml(FileXML *file);
215         void load_xml(FileXML *file);
216         void copy_from(BinFolderTarget *that);
217         BC_Window *new_gui(ModifyTargetThread *thread);
218         void update(int64_t mtime, double around);
219
220         int64_t mtime;
221 };
222
223 class BinFolderTargetTrackType : public BinFolderTarget
224 {
225 public:
226         BinFolderTargetTrackType(BinFolderFilter *filter);
227         ~BinFolderTargetTrackType();
228
229         void save_xml(FileXML *file);
230         void load_xml(FileXML *file);
231         void copy_from(BinFolderTarget *that);
232         BC_Window *new_gui(ModifyTargetThread *thread);
233         void update(int data_types);
234
235         int data_types;
236 };
237
238 class BinFolderTargetWidth : public BinFolderTarget
239 {
240 public:
241         BinFolderTargetWidth(BinFolderFilter *filter);
242         ~BinFolderTargetWidth();
243
244         void save_xml(FileXML *file);
245         void load_xml(FileXML *file);
246         void copy_from(BinFolderTarget *that);
247         BC_Window *new_gui(ModifyTargetThread *thread);
248         void update(int width, double around);
249
250         int width;
251 };
252
253 class BinFolderTargetHeight : public BinFolderTarget
254 {
255 public:
256         BinFolderTargetHeight(BinFolderFilter *filter);
257         ~BinFolderTargetHeight();
258
259         void save_xml(FileXML *file);
260         void load_xml(FileXML *file);
261         void copy_from(BinFolderTarget *that);
262         BC_Window *new_gui(ModifyTargetThread *thread);
263         void update(int height, double around);
264
265         int height;
266 };
267
268 class BinFolderTargetFramerate : public BinFolderTarget
269 {
270 public:
271         BinFolderTargetFramerate(BinFolderFilter *filter);
272         ~BinFolderTargetFramerate();
273
274         void save_xml(FileXML *file);
275         void load_xml(FileXML *file);
276         void copy_from(BinFolderTarget *that);
277         BC_Window *new_gui(ModifyTargetThread *thread);
278         void update(double framerate, double around);
279
280         double framerate;
281 };
282
283 class BinFolderTargetSamplerate : public BinFolderTarget
284 {
285 public:
286         BinFolderTargetSamplerate(BinFolderFilter *filter);
287         ~BinFolderTargetSamplerate();
288
289         void save_xml(FileXML *file);
290         void load_xml(FileXML *file);
291         void copy_from(BinFolderTarget *that);
292         BC_Window *new_gui(ModifyTargetThread *thread);
293         void update(int samplerate, double around);
294
295         int samplerate;
296 };
297
298 class BinFolderTargetChannels : public BinFolderTarget
299 {
300 public:
301         BinFolderTargetChannels(BinFolderFilter *filter);
302         ~BinFolderTargetChannels();
303
304         void save_xml(FileXML *file);
305         void load_xml(FileXML *file);
306         void copy_from(BinFolderTarget *that);
307         BC_Window *new_gui(ModifyTargetThread *thread);
308         void update(int channels, double around);
309
310         int channels;
311 };
312
313 class BinFolderTargetDuration : public BinFolderTarget
314 {
315 public:
316         BinFolderTargetDuration(BinFolderFilter *filter);
317         ~BinFolderTargetDuration();
318
319         void save_xml(FileXML *file);
320         void load_xml(FileXML *file);
321         void copy_from(BinFolderTarget *that);
322         BC_Window *new_gui(ModifyTargetThread *thread);
323         void update(int64_t duration, double around);
324
325         int64_t duration;
326 };
327
328 class BinFolderTargetType : public BC_MenuItem
329 {
330 public:
331         BinFolderTargetType(int no);
332         ~BinFolderTargetType();
333         int no;
334         int handle_event();
335 };
336
337 class BinFolderTargetPopup : public BC_PopupMenu
338 {
339 public:
340         BinFolderTargetPopup(BinFolderList *folder_list);
341         void create_objects();
342         void activate_menu(BC_ListBoxItem *item);
343
344         BinFolderList *folder_list;
345         BinFolderTarget *target;
346 };
347
348
349 class BinFolderOp : public BC_ListBoxItem
350 {
351 public:
352         BinFolderOp(BinFolderFilter *filter, int type);
353         virtual ~BinFolderOp();
354
355         double compare(BinFolderTarget *target, Indexable *idxbl);
356         virtual double test(BinFolderTarget *target, Indexable *idxbl);
357         double around(double v, double a);
358         double around(const char *ap, const char *bp);
359
360         void copy_from(BinFolderOp *that);
361
362         BinFolderFilter *filter;
363         int type;
364         static const char *types[];
365 };
366
367 class BinFolderOpType : public BC_MenuItem
368 {
369 public:
370         BinFolderOpType(int no);
371         ~BinFolderOpType();
372         int no;
373         int handle_event();
374 };
375
376 class BinFolderOpPopup : public BC_PopupMenu
377 {
378 public:
379         BinFolderOpPopup(BinFolderList *folder_list);
380         void create_objects();
381         void activate_menu(BC_ListBoxItem *item);
382
383         BinFolderList *folder_list;
384         BinFolderOp *op;
385 };
386
387
388 class BinFolderOpAround : public BinFolderOp
389 {
390 public:
391         BinFolderOpAround(BinFolderFilter *filter)
392          : BinFolderOp(filter, FOLDER_OP_AROUND) {}
393         ~BinFolderOpAround() {}
394         double test(BinFolderTarget *target, Indexable *idxbl);
395 };
396
397 class BinFolderOpEQ : public BinFolderOp
398 {
399 public:
400         BinFolderOpEQ(BinFolderFilter *filter)
401          : BinFolderOp(filter, FOLDER_OP_EQ) {}
402         ~BinFolderOpEQ() {}
403         double test(BinFolderTarget *target, Indexable *idxbl);
404 };
405
406 class BinFolderOpGT : public BinFolderOp
407 {
408 public:
409         BinFolderOpGT(BinFolderFilter *filter)
410          : BinFolderOp(filter, FOLDER_OP_GT) {}
411         ~BinFolderOpGT() {}
412         double test(BinFolderTarget *target, Indexable *idxbl);
413 };
414
415 class BinFolderOpGE : public BinFolderOp
416 {
417 public:
418         BinFolderOpGE(BinFolderFilter *filter)
419          : BinFolderOp(filter, FOLDER_OP_GE) {}
420         ~BinFolderOpGE() {}
421         double test(BinFolderTarget *target, Indexable *idxbl);
422 };
423
424 class BinFolderOpNE : public BinFolderOp
425 {
426 public:
427         BinFolderOpNE(BinFolderFilter *filter)
428          : BinFolderOp(filter, FOLDER_OP_NE) {}
429         ~BinFolderOpNE() {}
430         double test(BinFolderTarget *target, Indexable *idxbl);
431 };
432
433 class BinFolderOpLT : public BinFolderOp
434 {
435 public:
436         BinFolderOpLT(BinFolderFilter *filter)
437          : BinFolderOp(filter, FOLDER_OP_LT) {}
438         ~BinFolderOpLT() {}
439         double test(BinFolderTarget *target, Indexable *idxbl);
440 };
441
442 class BinFolderOpLE : public BinFolderOp
443 {
444 public:
445         BinFolderOpLE(BinFolderFilter *filter)
446          : BinFolderOp(filter, FOLDER_OP_LE) {}
447         ~BinFolderOpLE() {}
448         double test(BinFolderTarget *target, Indexable *idxbl);
449 };
450
451 class BinFolderOpMatches : public BinFolderOp
452 {
453 public:
454         BinFolderOpMatches(BinFolderFilter *filter)
455          : BinFolderOp(filter, FOLDER_OP_MATCHES) {}
456         ~BinFolderOpMatches() {}
457         double test(BinFolderTarget *target, Indexable *idxbl);
458 };
459
460 class BinFolderValue : public BC_ListBoxItem
461 {
462 public:
463         BinFolderValue(BinFolderFilter *filter, const char *text);
464         virtual ~BinFolderValue();
465
466         void update(const char *text);
467
468         BinFolderFilter *filter;
469 };
470
471
472 class BinFolderList : public BC_ListBox
473 {
474 public:
475         BinFolderList(BinFolder *folder, MWindow *mwindow,
476                 ModifyFolderGUI *window, int x, int y, int w, int h);
477         ~BinFolderList();
478         void create_objects();
479
480         int handle_event();
481         int handle_event(int column);
482         int selection_changed();
483         int column_resize_event();
484         void create_list();
485         void save_defaults(BC_Hash *defaults);
486         void load_defaults(BC_Hash *defaults);
487         void move_filter(int src, int dst);
488
489         int drag_start_event();
490         int drag_motion_event();
491         int drag_stop_event();
492         int dragging_item;
493
494         BinFolder *folder;
495         MWindow *mwindow;
496         ModifyFolderGUI *window;
497         ArrayList<BC_ListBoxItem *>list_items[FOLDER_COLUMNS];
498         const char *list_titles[FOLDER_COLUMNS];
499         int list_width[FOLDER_COLUMNS];
500
501         BinFolderEnabledPopup *enabled_popup;
502         BinFolderOpPopup *op_popup;
503         BinFolderTargetPopup *target_popup;
504
505         ModifyTargetThread *modify_target;
506 };
507
508 class BinFolderAddFilter : public BC_GenericButton
509 {
510 public:
511         BinFolderAddFilter(BinFolderList *folder_list, int x, int y);
512         ~BinFolderAddFilter();
513         int handle_event();
514         BinFolderList *folder_list;
515 };
516
517 class BinFolderDelFilter : public BC_GenericButton
518 {
519 public:
520         BinFolderDelFilter(BinFolderList *folder_list, int x, int y);
521         ~BinFolderDelFilter();
522         int handle_event();
523         BinFolderList *folder_list;
524 };
525
526 class BinFolderApplyFilter : public BC_GenericButton
527 {
528 public:
529         BinFolderApplyFilter(BinFolderList *folder_list, int x, int y);
530         ~BinFolderApplyFilter();
531         int handle_event();
532         BinFolderList *folder_list;
533 };
534
535 class NewFolderGUI : public BC_Window
536 {
537 public:
538         NewFolderGUI(NewFolderThread *thread, int x, int y, int w, int h);
539         ~NewFolderGUI();
540         void create_objects();
541         const char *get_text();
542
543         NewFolderThread *thread;
544         BinFolderList *folder_list;
545         BC_TextBox *text_box;
546 };
547
548 class NewFolderThread : public BC_DialogThread
549 {
550 public:
551         NewFolderThread(AWindowGUI *agui);
552         ~NewFolderThread();
553         BC_Window *new_gui();
554         void handle_done_event(int result);
555         void handle_close_event(int result);
556         void start(int x, int y, int w, int h, int is_clips);
557
558         int wx, wy, ww, wh;
559         int is_clips;
560         AWindowGUI *agui;
561         NewFolderGUI *window;
562 };
563
564
565 class ModifyFolderGUI : public BC_Window
566 {
567 public:
568         ModifyFolderGUI(ModifyFolderThread *thread, int x, int y, int w, int h);
569         ~ModifyFolderGUI();
570         void create_objects();
571         int resize_event(int w, int h);
572         const char *get_text();
573         int receive_custom_xatoms(xatom_event *event);
574         void async_update_filters();
575         void update_filters();
576
577         ModifyFolderThread *thread;
578         BinFolderList *folder_list;
579         BinFolderAddFilter *add_filter;
580         BinFolderDelFilter *del_filter;
581         BinFolderApplyFilter *apply_filter;
582         BC_Title *text_title;
583         BC_TextBox *text_box;
584         Atom modify_folder_xatom;
585         BC_OKButton *ok_button;
586         BC_CancelButton *cancel_button;
587 };
588
589 class ModifyFolderThread : public BC_DialogThread
590 {
591 public:
592         ModifyFolderThread(AWindowGUI *agui);
593         ~ModifyFolderThread();
594         BC_Window *new_gui();
595         void handle_done_event(int result);
596         void handle_close_event(int result);
597         void start(BinFolder *folder, int x, int y, int w, int h);
598
599         int wx, wy, ww, wh;
600         AWindowGUI *agui;
601         BinFolder *original, *folder;
602         ModifyFolderGUI *window;
603         EDL *modify_edl;
604 };
605
606
607 class ModifyTargetGUI : public BC_Window
608 {
609 public:
610         ModifyTargetGUI(ModifyTargetThread *thread, int allow_resize=0);
611         ~ModifyTargetGUI();
612         virtual void create_objects() {}
613         virtual void update() {}
614         virtual int resize_event(int w, int h);
615         void create_objects(BC_TextBox *&text_box);
616
617         ModifyTargetThread *thread;
618 };
619
620 class ModifyTargetThread : public BC_DialogThread
621 {
622 public:
623         ModifyTargetThread(BinFolderList *folder_list);
624         ~ModifyTargetThread();
625         BC_Window *new_gui();
626         void handle_done_event(int result);
627         void handle_close_event(int result);
628         void start(BinFolderTarget *target, int x, int y, int w, int h);
629
630         int wx, wy, ww, wh;
631         BinFolderList *folder_list;
632         BinFolderTarget *target;
633         ModifyTargetGUI *window;
634 };
635
636 class ModifyTargetPatternsGUI : public ModifyTargetGUI
637 {
638 public:
639         ModifyTargetPatternsGUI(ModifyTargetThread *thread);
640         ~ModifyTargetPatternsGUI();
641         void create_objects();
642         int resize_event(int w, int h);
643         void update();
644
645         BC_ScrollTextBox *scroll_text_box;
646         BC_OKButton *ok_button;
647         BC_CancelButton *cancel_button;
648         int text_rowsz;
649 };
650
651 class ModifyTargetFileSizeGUI : public ModifyTargetGUI
652 {
653 public:
654         ModifyTargetFileSizeGUI(ModifyTargetThread *thread);
655         ~ModifyTargetFileSizeGUI();
656         void create_objects();
657         void update();
658
659         BC_TextBox *text_box;
660 };
661
662 class ModifyTargetTimeGUI : public ModifyTargetGUI
663 {
664 public:
665         ModifyTargetTimeGUI(ModifyTargetThread *thread);
666         ~ModifyTargetTimeGUI();
667         void create_objects();
668         void update();
669
670         BC_TextBox *text_box;
671 };
672
673 class ModifyTargetTrackTypeGUI : public ModifyTargetGUI
674 {
675 public:
676         ModifyTargetTrackTypeGUI(ModifyTargetThread *thread);
677         ~ModifyTargetTrackTypeGUI();
678         void create_objects();
679         void update();
680
681         BC_TextBox *text_box;
682 };
683
684 class ModifyTargetWidthGUI : public ModifyTargetGUI
685 {
686 public:
687         ModifyTargetWidthGUI(ModifyTargetThread *thread);
688         ~ModifyTargetWidthGUI();
689         void create_objects();
690         void update();
691
692         BC_TextBox *text_box;
693 };
694
695 class ModifyTargetHeightGUI : public ModifyTargetGUI
696 {
697 public:
698         ModifyTargetHeightGUI(ModifyTargetThread *thread);
699         ~ModifyTargetHeightGUI();
700         void create_objects();
701         void update();
702
703         BC_TextBox *text_box;
704 };
705
706 class ModifyTargetFramerateGUI : public ModifyTargetGUI
707 {
708 public:
709         ModifyTargetFramerateGUI(ModifyTargetThread *thread);
710         ~ModifyTargetFramerateGUI();
711         void create_objects();
712         void update();
713
714         BC_TextBox *text_box;
715 };
716
717 class ModifyTargetSamplerateGUI : public ModifyTargetGUI
718 {
719 public:
720         ModifyTargetSamplerateGUI(ModifyTargetThread *thread);
721         ~ModifyTargetSamplerateGUI();
722         void create_objects();
723         void update();
724
725         BC_TextBox *text_box;
726 };
727
728 class ModifyTargetChannelsGUI : public ModifyTargetGUI
729 {
730 public:
731         ModifyTargetChannelsGUI(ModifyTargetThread *thread);
732         ~ModifyTargetChannelsGUI();
733         void create_objects();
734         void update();
735
736         BC_TextBox *text_box;
737 };
738
739 class ModifyTargetDurationGUI : public ModifyTargetGUI
740 {
741 public:
742         ModifyTargetDurationGUI(ModifyTargetThread *thread);
743         ~ModifyTargetDurationGUI();
744         void create_objects();
745         void update();
746
747         BC_TextBox *text_box;
748 };
749
750 #endif