add x10tv ati remote rework, android remote rework, wintv remote tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / awindowgui.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 AWINDOWGUI_H
23 #define AWINDOWGUI_H
24
25 #include "arraylist.h"
26 #include "bcdialog.h"
27 #include "binfolder.inc"
28 #include "assetpopup.inc"
29 #include "asset.inc"
30 #include "assets.inc"
31 #include "audiodevice.inc"
32 #include "awindow.inc"
33 #include "awindowgui.inc"
34 #include "clippopup.inc"
35 #include "edl.inc"
36 #include "effectlist.inc"
37 #include "folderlistmenu.inc"
38 #include "garbage.h"
39 #include "guicast.h"
40 #include "labeledit.inc"
41 #include "labelpopup.inc"
42 #include "labels.h"
43 #include "indexable.inc"
44 #include "mwindow.inc"
45 #include "mutex.inc"
46 #include "pluginserver.inc"
47 #include "preferences.inc"
48 #include "proxypopup.inc"
49 #include "renderengine.inc"
50 #include "samples.inc"
51 #include "vicon.h"
52
53 #define SELECT_ALL 0
54 #define SELECT_USED 1
55 #define SELECT_UNUSED 2
56 #define SELECT_NONE 3
57
58 // in percent view_h
59 #define VIEW_POPUP_BAR_H 15
60
61 #define ASSET_VIEW_NONE 0
62 #define ASSET_VIEW_ICON 1
63 #define ASSET_VIEW_MEDIA 2
64 #define ASSET_VIEW_MEDIA_MAP 3
65 #define ASSET_VIEW_FULL 4
66
67 #define AVICON_FULL_PLAY   0
68 #define AVICON_MOUSE_OVER  1
69 #define AVICON_SRC_TARGET  2
70 #define AVICON_NO_PLAY     3
71 #define AVICON_PLAY_MODES  4
72
73 class AWindowFolderItem : public BC_ListBoxItem
74 {
75 public:
76         AWindowFolderItem();
77         AWindowFolderItem(const char *text, int color = -1);
78         AWindowFolderItem(const char *text, BC_Pixmap *icon, int color = -1);
79
80         AssetPicon *get_picon();
81         int matches(const char *text);
82
83         AWindowFolderItem *parent;
84 };
85
86 class AssetPicon : public AWindowFolderItem
87 {
88 public:
89         AssetPicon(MWindow *mwindow, AWindowGUI *gui, Indexable *indexable);
90         AssetPicon(MWindow *mwindow, AWindowGUI *gui, EDL *edl);
91         AssetPicon(MWindow *mwindow, AWindowGUI *gui, PluginServer *plugin);
92         AssetPicon(MWindow *mwindow, AWindowGUI *gui, Label *plugin);
93         AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, int persist);
94         AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, const char *title);
95         virtual ~AssetPicon();
96
97         void create_objects();
98         void reset();
99         static void draw_hue_bar(VFrame *frame, double t);
100         static void draw_wave(VFrame *frame, double *dp, int len,
101                 int base_color, int line_color, int x, int y, int w, int h);
102         static void draw_wave(VFrame *frame, double *dp, int len,
103                 int base_color, int line_color, int x=0, int y=0) {
104           draw_wave(frame, dp, len, base_color, line_color,
105                 x,y,frame->get_w(),frame->get_h());
106         }
107         void open_render_engine(EDL *edl, int is_audio);
108         void close_render_engine();
109         void render_video(int64_t pos, VFrame *vfrm);
110         void render_audio(int64_t pos, Samples **samples, int len);
111         VFrame *get_vicon_frame();
112
113         MWindow *mwindow;
114         AWindowGUI *gui;
115         BC_Pixmap *icon;
116         VFrame *icon_vframe;
117         VFrame *vicon_frame;
118         int foldernum;
119 // sublist items if set
120         AWindowFolderSubItems *sub_items;
121
122 // ID of thing pointed to
123         int id;
124
125 // Check ID first.  Update these next before dereferencing
126 // Asset if asset
127         Indexable *indexable;
128 // EDL if clip
129         EDL *edl;
130
131         int in_use;
132         int persistent;
133         time_t comments_time;
134         int comments_ffmt;
135         double comments_rate;
136         const char *comments_type;
137         double sort_key;
138         PluginServer *plugin;
139         Label *label;
140         AssetVIcon *vicon;
141         RenderEngine *render_engine;
142 };
143
144 typedef int16_t vicon_audio_t;
145
146 class AssetVIconAudio : public Thread
147 {
148 public:
149         AssetVIconAudio(AWindowGUI *gui);
150         ~AssetVIconAudio();
151
152         void run();
153         void start(AssetVIcon *vicon);
154         void stop(int wait);
155
156         AWindowGUI *gui;
157         AudioDevice *audio;
158         AssetVIcon *vicon;
159         int interrupted;
160         int audio_pos;
161 };
162
163 class AssetVIcon : public VIcon, public Garbage {
164 public:
165         AssetPicon *picon;
166         VFrame *temp;
167         int64_t length;
168
169         VFrame *frame();
170         int64_t set_seq_no(int64_t no);
171         int get_vx();
172         int get_vy();
173         void load_audio();
174         void start_audio();
175         void stop_audio();
176
177         AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
178         ~AssetVIcon();
179 };
180
181 class AssetViewPopup : public ViewPopup
182 {
183 public:
184         AssetViewPopup(VIconThread *vt, int draw_mode,
185                         int x, int y, int w, int h);
186         ~AssetViewPopup();
187
188         int reposition_window(int x, int y, int w, int h);
189         int button_press_event();
190         int button_release_event();
191         int cursor_motion_event();
192         int keypress_event();
193
194         void draw_vframe(VFrame *frame);
195
196         int bar_h;
197         int draw_mode;
198         int dragging;
199 };
200
201 class AssetVIconThread : public VIconThread
202 {
203 public:
204         AssetVIconThread(AWindowGUI *gui, Preferences *preferences);
205         ~AssetVIconThread();
206
207         void set_view_popup(AssetVIcon *v, int draw_mode);
208         void set_view_popup(AssetVIcon *v);
209         ViewPopup *new_view_window(ViewPopup *popup);
210         void drawing_started();
211         void drawing_stopped();
212         void close_view_popup();
213
214         AWindowGUI *gui;
215         int draw_mode;
216         int vicon_cmodel;
217         Mutex *draw_lock;
218 };
219
220
221 class AWindowRemovePlugin;
222
223 class AWindowRemovePluginGUI : public BC_Window {
224 public:
225         AWindow *awindow;
226         AWindowRemovePlugin *thread;
227         PluginServer *plugin;
228         ArrayList<BC_ListBoxItem*> plugin_list;
229         BC_Pixmap *icon;
230         VFrame *icon_vframe;
231         BC_ListBox *list;
232
233         void create_objects();
234
235         AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
236                  int x, int y, PluginServer *plugin);
237         ~AWindowRemovePluginGUI();
238 };
239
240 class AWindowRemovePlugin : public BC_DialogThread {
241 public:
242         AWindow *awindow;
243         PluginServer *plugin;
244         BC_Window* new_gui();
245         void handle_close_event(int result);
246         int remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder);
247
248         AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin);
249         ~AWindowRemovePlugin();
250 };
251
252 class AWindowGUI : public BC_Window
253 {
254 public:
255         AWindowGUI(MWindow *mwindow, AWindow *awindow);
256         ~AWindowGUI();
257
258         void create_objects();
259         int resize_event(int w, int h);
260         int translation_event();
261         int close_event();
262         int keypress_event();
263         void async_update_assets();     // Sends update asset event
264         void update_effects();
265         void sort_assets();
266         void sort_folders();
267         void reposition_objects();
268 // Call back for MWindow entry point
269         int drag_motion();
270         int drag_stop();
271 // Collect items into the drag vectors of MainSession
272         void collect_assets(int proxy=0);
273         EDL *collect_proxy(Indexable *indexable);
274         void create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
275                 int do_audio,
276                 int do_video,
277                 int is_realtime,
278                 int is_transition);
279         void create_label_folder();
280         void copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src);
281         void sort_picons(ArrayList<BC_ListBoxItem*> *src);
282 // Return the selected asset in asset_list
283         Indexable* selected_asset();
284         PluginServer* selected_plugin();
285         AssetPicon* selected_folder();
286         bool protected_pixmap(BC_Pixmap *pixmap);
287         int save_defaults(BC_Hash *defaults);
288         int load_defaults(BC_Hash *defaults);
289         int start_vicon_drawing();
290         int stop_vicon_drawing();
291         void close_view_popup();
292         void update_picon(Indexable *indexable);
293         int cycle_assetlist_format();
294         void hide_tip_info();
295
296         VFrame *get_picon(const char *name, const char *plugin_icons);
297         VFrame *get_picon(const char *name);
298         void resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx);
299         void theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn);
300         void plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png);
301
302         MWindow *mwindow;
303         AWindow *awindow;
304
305         AWindowAssets *asset_list;
306         AWindowFolders *folder_list;
307         AWindowDivider *divider;
308         AWindowSearchText *search_text;
309         Mutex *folder_lock;
310
311 // Store data to speed up responses
312 // Persistant data for listboxes
313 // All assets in current EDL
314         ArrayList<BC_ListBoxItem*> assets;
315         ArrayList<BC_ListBoxItem*> folders;
316         ArrayList<BC_ListBoxItem*> aeffects;
317         ArrayList<BC_ListBoxItem*> veffects;
318         ArrayList<BC_ListBoxItem*> atransitions;
319         ArrayList<BC_ListBoxItem*> vtransitions;
320         ArrayList<BC_ListBoxItem*> labellist;
321
322 // Currently displayed data for listboxes
323 // Currently displayed assets + comments
324         ArrayList<BC_ListBoxItem*> displayed_assets[2];
325         const char *asset_titles[ASSET_COLUMNS];
326         int displayed_folder;
327
328         BC_Hash *defaults;
329 // Persistent icons
330         BC_Pixmap *aeffect_folder_icon;      VFrame *aeffect_folder_vframe;
331         BC_Pixmap *atransition_folder_icon;  VFrame *atransition_folder_vframe;
332         BC_Pixmap *clip_folder_icon;         VFrame *clip_folder_vframe;
333         BC_Pixmap *label_folder_icon;        VFrame *label_folder_vframe;
334         BC_Pixmap *media_folder_icon;        VFrame *media_folder_vframe;
335         BC_Pixmap *proxy_folder_icon;        VFrame *proxy_folder_vframe;
336         BC_Pixmap *veffect_folder_icon;      VFrame *veffect_folder_vframe;
337         BC_Pixmap *vtransition_folder_icon;  VFrame *vtransition_folder_vframe;
338         BC_Pixmap *folder_icons[AWINDOW_FOLDERS];
339
340         BC_Pixmap *folder_icon;       VFrame *folder_vframe;
341         BC_Pixmap *file_icon;         VFrame *file_vframe;
342         BC_Pixmap *audio_icon;        VFrame *audio_vframe;
343         BC_Pixmap *video_icon;        VFrame *video_vframe;
344         BC_Pixmap *label_icon;        VFrame *label_vframe;
345         BC_Pixmap *clip_icon;         VFrame *clip_vframe;
346         BC_Pixmap *atransition_icon;  VFrame *atransition_vframe;
347         BC_Pixmap *vtransition_icon;  VFrame *vtransition_vframe;
348         BC_Pixmap *aeffect_icon;      VFrame *aeffect_vframe;
349         BC_Pixmap *veffect_icon;      VFrame *veffect_vframe;
350         BC_Pixmap *ladspa_icon;       VFrame *ladspa_vframe;
351         BC_Pixmap *ff_aud_icon;       VFrame *ff_aud_vframe;
352         BC_Pixmap *ff_vid_icon;       VFrame *ff_vid_vframe;
353
354 // Popup menus
355         AssetPopup *asset_menu;
356         ClipPopup *clip_menu;
357         LabelPopup *label_menu;
358         ProxyPopup *proxy_menu;
359         EffectListMenu *effectlist_menu;
360         AssetListMenu *assetlist_menu;
361         ClipListMenu *cliplist_menu;
362         LabelListMenu *labellist_menu;
363         ProxyListMenu *proxylist_menu;
364         FolderListMenu *folderlist_menu;
365         AddTools *add_tools;
366 // Temporary for reading picons from files
367         VFrame *temp_picon;
368         AssetVIconThread *vicon_thread;
369         AssetVIconAudio *vicon_audio;
370
371         int64_t plugin_visibility;
372         AWindowRemovePlugin *remove_plugin;
373
374         AVIconDrawing *avicon_drawing;
375         int avicon_w, avicon_h;
376         int vicon_drawing, play_off;
377         int allow_iconlisting;
378         int tip_info;
379
380 // Create custom atoms to be used for async messages between windows
381         int create_custom_xatoms();
382 // Function to overload to receive customly defined atoms
383         virtual int receive_custom_xatoms(xatom_event *event);
384         static const char *folder_names[];
385         NewFolderThread *new_folder_thread;
386         ModifyFolderThread *modify_folder_thread;
387
388 private:
389         void update_folder_list();
390         void update_asset_list();
391         void filter_displayed_assets();
392         Atom UpdateAssetsXAtom;
393         void update_assets();
394
395 };
396
397 class AWindowAssets : public BC_ListBox
398 {
399 public:
400         AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
401         ~AWindowAssets();
402
403         int handle_event();
404         int selection_changed();
405         void draw_background();
406         int drag_start_event();
407         int drag_motion_event();
408         int drag_stop_event();
409         int button_press_event();
410         int column_resize_event();
411         int cursor_enter_event();
412         int cursor_leave_event();
413         int focus_out_event();
414         void update_vicon_area();
415         int mouse_over_event(int no);
416         void show_tip_info(const char *info, int no);
417         void hide_tip_info();
418
419         MWindow *mwindow;
420         AWindowGUI *gui;
421         int info_tip;
422 };
423
424 class AWindowDivider : public BC_SubWindow
425 {
426 public:
427         AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
428         ~AWindowDivider();
429
430         int button_press_event();
431         int cursor_motion_event();
432         int button_release_event();
433
434         MWindow *mwindow;
435         AWindowGUI *gui;
436 };
437
438 class AWindowSubFolderNames : public ArrayList<const char *>
439 {
440 public:
441         AWindowSubFolderNames() { set_array_delete(); }
442         ~AWindowSubFolderNames() { remove_all_objects(); }
443 };
444
445 class AWindowFolderSubItems : public AWindowFolderItem
446 {
447 public:
448         AWindowFolderSubItems(AWindowFolderItem *parent, const char *text);
449         int matches(const char *text);
450
451         AWindowSubFolderNames names;
452 };
453
454 class AWindowFolders : public BC_ListBox
455 {
456 public:
457         AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
458         ~AWindowFolders();
459
460         int selection_changed();
461         int button_press_event();
462         int drag_stop();
463         int load_expanders();
464
465         MWindow *mwindow;
466         AWindowGUI *gui;
467 // last selection
468         AWindowFolderItem *last_item0, *last_item1;
469 };
470
471 class AWindowSearchTextBox : public BC_TextBox
472 {
473 public:
474         AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w);
475         int handle_event();
476
477         AWindowSearchText *search_text;
478 };
479
480 class AWindowSearchText
481 {
482 public:
483         AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y);
484
485         int handle_event();
486         void create_objects();
487         int get_w();
488         int get_h();
489         void reposition_window(int x, int y, int w);
490         const char *get_text();
491         void clear();
492
493         MWindow *mwindow;
494         AWindowGUI *gui;
495         int x, y;
496         BC_Title *text_title;
497         BC_TextBox *text_box;
498 };
499
500 class AWindowDeleteDisk : public BC_Button
501 {
502 public:
503         AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y);
504         int handle_event();
505         MWindow *mwindow;
506         AWindowGUI *gui;
507         int x, y;
508 };
509
510 class AWindowDeleteProject : public BC_Button
511 {
512 public:
513         AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y);
514         int handle_event();
515         MWindow *mwindow;
516         AWindowGUI *gui;
517         int x, y;
518 };
519
520 class AWindowInfo : public BC_Button
521 {
522 public:
523         AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y);
524         int handle_event();
525         MWindow *mwindow;
526         AWindowGUI *gui;
527         int x, y;
528 };
529
530 class AWindowRedrawIndex : public BC_Button
531 {
532 public:
533         AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y);
534         int handle_event();
535         MWindow *mwindow;
536         AWindowGUI *gui;
537         int x, y;
538 };
539
540 class AWindowPaste : public BC_Button
541 {
542 public:
543         AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y);
544         int handle_event();
545         MWindow *mwindow;
546         AWindowGUI *gui;
547         int x, y;
548 };
549
550 class AWindowAppend : public BC_Button
551 {
552 public:
553         AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y);
554         int handle_event();
555         MWindow *mwindow;
556         AWindowGUI *gui;
557         int x, y;
558 };
559
560 class AWindowView : public BC_Button
561 {
562 public:
563         AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y);
564         int handle_event();
565         MWindow *mwindow;
566         AWindowGUI *gui;
567         int x, y;
568 };
569
570 class AddTools : public BC_PopupMenu
571 {
572 public:
573         AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title);
574         void create_objects();
575
576         MWindow *mwindow;
577         AWindowGUI *gui;
578 };
579
580 class AddPluginItem : public BC_MenuItem
581 {
582 public:
583         AddPluginItem(AddTools *menu, const char *text, int idx);
584         int handle_event();
585
586         AddTools *menu;
587         int idx;
588 };
589
590 class AVIconDrawingItem : public BC_MenuItem
591 {
592 public:
593         AVIconDrawingItem(AVIconDrawing *avicon, const char *text, int id);
594         int handle_event();
595
596         AVIconDrawing *avicon;
597         int id;
598 };
599
600 class AVIconDrawing : public BC_PopupMenu
601 {
602 public:
603         AVIconDrawing(AWindowGUI *agui, int x, int y, int w, const char *text);
604         ~AVIconDrawing();
605
606         static const char *avicon_names[];
607         void create_objects();
608         int button_press_event();
609         int draw_face(int dx, int color);
610
611         AWindowGUI *agui;
612 };
613
614
615 class AWindowListFormat : public BC_MenuItem
616 {
617 public:
618         AWindowListFormat(MWindow *mwindow, AWindowGUI *gui);
619
620         void update();
621         int handle_event();
622         MWindow *mwindow;
623         AWindowGUI *gui;
624 };
625
626
627 class AWindowListSort : public BC_MenuItem
628 {
629 public:
630         AWindowListSort(MWindow *mwindow, AWindowGUI *gui);
631
632         void update();
633         int handle_event();
634         MWindow *mwindow;
635         AWindowGUI *gui;
636 };
637
638 class AssetSelectUsedItem : public BC_MenuItem
639 {
640 public:
641         AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action);
642         int handle_event();
643
644         int action;
645         AssetSelectUsed *select_used;
646 };
647
648 class AssetSelectUsed : public BC_MenuItem
649 {
650 public:
651         AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui);
652
653         MWindow *mwindow;
654         AWindowGUI *gui;
655 };
656
657 #endif