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