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