no longer need ffmpeg patch0 which was for Termux
[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         int broken;
169
170         VFrame *frame();
171         int64_t set_seq_no(int64_t no);
172         int get_vx();
173         int get_vy();
174         void load_audio();
175         void start_audio();
176         void stop_audio();
177
178         AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
179         ~AssetVIcon();
180 };
181
182 class AssetViewPopup : public ViewPopup
183 {
184 public:
185         AssetViewPopup(VIconThread *vt, int draw_mode,
186                         int x, int y, int w, int h);
187         ~AssetViewPopup();
188
189         int reposition_window(int x, int y, int w, int h);
190         int button_press_event();
191         int button_release_event();
192         int cursor_motion_event();
193         int keypress_event();
194
195         void draw_vframe(VFrame *frame);
196
197         int bar_h;
198         int draw_mode;
199         int dragging;
200 };
201
202 class AssetVIconThread : public VIconThread
203 {
204 public:
205         AssetVIconThread(AWindowGUI *gui, Preferences *preferences);
206         ~AssetVIconThread();
207
208         void set_view_popup(AssetVIcon *v, int draw_mode);
209         void set_view_popup(AssetVIcon *v);
210         ViewPopup *new_view_window(ViewPopup *popup);
211         void stop_vicon_drawing(int wait=0);
212
213         AWindowGUI *gui;
214         int draw_mode;
215         int vicon_cmodel;
216 };
217
218
219 class AWindowRemovePlugin;
220
221 class AWindowRemovePluginGUI : public BC_Window {
222 public:
223         AWindow *awindow;
224         AWindowRemovePlugin *thread;
225         PluginServer *plugin;
226         ArrayList<BC_ListBoxItem*> plugin_list;
227         BC_Pixmap *icon;
228         VFrame *icon_vframe;
229         BC_ListBox *list;
230
231         void create_objects();
232
233         AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
234                  int x, int y, PluginServer *plugin);
235         ~AWindowRemovePluginGUI();
236 };
237
238 class AWindowRemovePlugin : public BC_DialogThread {
239 public:
240         AWindow *awindow;
241         PluginServer *plugin;
242         BC_Window* new_gui();
243         void handle_close_event(int result);
244         int remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder);
245
246         AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin);
247         ~AWindowRemovePlugin();
248 };
249
250 class AWindowGUI : public BC_Window
251 {
252 public:
253         AWindowGUI(MWindow *mwindow, AWindow *awindow);
254         ~AWindowGUI();
255
256         void create_objects();
257         int resize_event(int w, int h);
258         int translation_event();
259         int close_event();
260         int keypress_event();
261         void async_update_assets();     // Sends update asset event
262         void update_effects();
263         void sort_assets();
264         void sort_folders();
265         void reposition_objects();
266 // Call back for MWindow entry point
267         int drag_motion();
268         int drag_stop();
269 // Collect items into the drag vectors of MainSession
270         void collect_assets(int proxy=0);
271         EDL *collect_proxy(Asset *asset);
272         void create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
273                 int do_audio,
274                 int do_video,
275                 int is_realtime,
276                 int is_transition);
277         void create_label_folder();
278         void copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src);
279         void sort_picons(ArrayList<BC_ListBoxItem*> *src);
280 // Return the selected asset in asset_list
281         Indexable* selected_asset();
282         PluginServer* selected_plugin();
283         AssetPicon* selected_folder();
284         bool protected_pixmap(BC_Pixmap *pixmap);
285         int save_defaults(BC_Hash *defaults);
286         int load_defaults(BC_Hash *defaults);
287         int start_vicon_drawing();
288         int stop_vicon_drawing(int wait=0);
289         void update_picon(Indexable *indexable);
290         int cycle_assetlist_format();
291         void hide_tip_info();
292
293         VFrame *get_picon(const char *name, const char *plugin_icons);
294         VFrame *get_picon(const char *name);
295         void resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx);
296         void theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn);
297         void plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png);
298
299         MWindow *mwindow;
300         AWindow *awindow;
301
302         AWindowAssets *asset_list;
303         AWindowFolders *folder_list;
304         AWindowDivider *divider;
305         AWindowSearchText *search_text;
306         Mutex *folder_lock;
307
308 // Store data to speed up responses
309 // Persistant data for listboxes
310 // All assets in current EDL
311         ArrayList<BC_ListBoxItem*> assets;
312         ArrayList<BC_ListBoxItem*> folders;
313         ArrayList<BC_ListBoxItem*> aeffects;
314         ArrayList<BC_ListBoxItem*> veffects;
315         ArrayList<BC_ListBoxItem*> atransitions;
316         ArrayList<BC_ListBoxItem*> vtransitions;
317         ArrayList<BC_ListBoxItem*> labellist;
318
319 // Currently displayed data for listboxes
320 // Currently displayed assets + comments
321         ArrayList<BC_ListBoxItem*> displayed_assets[2];
322         const char *asset_titles[ASSET_COLUMNS];
323         int displayed_folder;
324
325         BC_Hash *defaults;
326 // Persistent icons
327         BC_Pixmap *aeffect_folder_icon;      VFrame *aeffect_folder_vframe;
328         BC_Pixmap *atransition_folder_icon;  VFrame *atransition_folder_vframe;
329         BC_Pixmap *clip_folder_icon;         VFrame *clip_folder_vframe;
330         BC_Pixmap *label_folder_icon;        VFrame *label_folder_vframe;
331         BC_Pixmap *media_folder_icon;        VFrame *media_folder_vframe;
332         BC_Pixmap *proxy_folder_icon;        VFrame *proxy_folder_vframe;
333         BC_Pixmap *veffect_folder_icon;      VFrame *veffect_folder_vframe;
334         BC_Pixmap *vtransition_folder_icon;  VFrame *vtransition_folder_vframe;
335         BC_Pixmap *folder_icons[AWINDOW_FOLDERS];
336
337         BC_Pixmap *folder_icon;       VFrame *folder_vframe;
338         BC_Pixmap *file_icon;         VFrame *file_vframe;
339         BC_Pixmap *audio_icon;        VFrame *audio_vframe;
340         BC_Pixmap *video_icon;        VFrame *video_vframe;
341         BC_Pixmap *label_icon;        VFrame *label_vframe;
342         BC_Pixmap *clip_icon;         VFrame *clip_vframe;
343         BC_Pixmap *atransition_icon;  VFrame *atransition_vframe;
344         BC_Pixmap *vtransition_icon;  VFrame *vtransition_vframe;
345         BC_Pixmap *aeffect_icon;      VFrame *aeffect_vframe;
346         BC_Pixmap *veffect_icon;      VFrame *veffect_vframe;
347         BC_Pixmap *ladspa_icon;       VFrame *ladspa_vframe;
348         BC_Pixmap *ff_aud_icon;       VFrame *ff_aud_vframe;
349         BC_Pixmap *ff_vid_icon;       VFrame *ff_vid_vframe;
350
351 // Popup menus
352         AssetPopup *asset_menu;
353         ClipPopup *clip_menu;
354         LabelPopup *label_menu;
355         ProxyPopup *proxy_menu;
356         EffectListMenu *effectlist_menu;
357         AssetListMenu *assetlist_menu;
358         ClipListMenu *cliplist_menu;
359         LabelListMenu *labellist_menu;
360         ProxyListMenu *proxylist_menu;
361         FolderListMenu *folderlist_menu;
362         AddTools *add_tools;
363 // Temporary for reading picons from files
364         VFrame *temp_picon;
365         AssetVIconThread *vicon_thread;
366         AssetVIconAudio *vicon_audio;
367
368         int64_t plugin_visibility;
369         AWindowRemovePlugin *remove_plugin;
370
371         AVIconDrawing *avicon_drawing;
372         int avicon_w, avicon_h;
373         int vicon_drawing, play_off;
374         int allow_iconlisting;
375         int tip_info;
376
377 // Create custom atoms to be used for async messages between windows
378         int create_custom_xatoms();
379 // Function to overload to receive customly defined atoms
380         virtual int receive_custom_xatoms(xatom_event *event);
381         static const char *folder_names[];
382         NewFolderThread *new_folder_thread;
383         ModifyFolderThread *modify_folder_thread;
384
385 private:
386         void update_folder_list();
387         void update_asset_list();
388         void filter_displayed_assets();
389         Atom UpdateAssetsXAtom;
390         void update_assets();
391
392 };
393
394 class AWindowAssets : public BC_ListBox
395 {
396 public:
397         AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
398         ~AWindowAssets();
399
400         int handle_event();
401         int selection_changed();
402         void draw_background();
403         int drag_start_event();
404         int drag_motion_event();
405         int drag_stop_event();
406         int button_press_event();
407         int column_resize_event();
408         int cursor_enter_event();
409         int cursor_leave_event();
410         int focus_out_event();
411         void update_vicon_area();
412         int mouse_over_event(int no);
413         void show_tip_info(const char *info, int no);
414         void hide_tip_info();
415 // *** CONTEXT_HELP ***
416         int keypress_event();
417
418         MWindow *mwindow;
419         AWindowGUI *gui;
420         int info_tip;
421 };
422
423 class AWindowDivider : public BC_SubWindow
424 {
425 public:
426         AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
427         ~AWindowDivider();
428
429         int button_press_event();
430         int cursor_motion_event();
431         int button_release_event();
432
433         MWindow *mwindow;
434         AWindowGUI *gui;
435 };
436
437 class AWindowSubFolderNames : public ArrayList<const char *>
438 {
439 public:
440         AWindowSubFolderNames() { set_array_delete(); }
441         ~AWindowSubFolderNames() { remove_all_objects(); }
442 };
443
444 class AWindowFolderSubItems : public AWindowFolderItem
445 {
446 public:
447         AWindowFolderSubItems(AWindowFolderItem *parent, const char *text);
448         int matches(const char *text);
449
450         AWindowSubFolderNames names;
451 };
452
453 class AWindowFolders : public BC_ListBox
454 {
455 public:
456         AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
457         ~AWindowFolders();
458
459         int selection_changed();
460         int button_press_event();
461         int drag_stop();
462         int load_expanders();
463
464         MWindow *mwindow;
465         AWindowGUI *gui;
466 // last selection
467         AWindowFolderItem *last_item0, *last_item1;
468 };
469
470 class AWindowSearchTextBox : public BC_TextBox
471 {
472 public:
473         AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w);
474         int handle_event();
475
476         AWindowSearchText *search_text;
477 };
478
479 class AWindowSearchText
480 {
481 public:
482         AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y);
483
484         int handle_event();
485         void create_objects();
486         int get_w();
487         int get_h();
488         void reposition_window(int x, int y, int w);
489         const char *get_text();
490         void clear();
491
492         MWindow *mwindow;
493         AWindowGUI *gui;
494         int x, y;
495         BC_Title *text_title;
496         BC_TextBox *text_box;
497 };
498
499 class AWindowDeleteDisk : public BC_Button
500 {
501 public:
502         AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y);
503         int handle_event();
504         MWindow *mwindow;
505         AWindowGUI *gui;
506         int x, y;
507 };
508
509 class AWindowDeleteProject : public BC_Button
510 {
511 public:
512         AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y);
513         int handle_event();
514         MWindow *mwindow;
515         AWindowGUI *gui;
516         int x, y;
517 };
518
519 class AWindowInfo : public BC_Button
520 {
521 public:
522         AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y);
523         int handle_event();
524         MWindow *mwindow;
525         AWindowGUI *gui;
526         int x, y;
527 };
528
529 class AWindowRedrawIndex : public BC_Button
530 {
531 public:
532         AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y);
533         int handle_event();
534         MWindow *mwindow;
535         AWindowGUI *gui;
536         int x, y;
537 };
538
539 class AWindowPaste : public BC_Button
540 {
541 public:
542         AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y);
543         int handle_event();
544         MWindow *mwindow;
545         AWindowGUI *gui;
546         int x, y;
547 };
548
549 class AWindowAppend : public BC_Button
550 {
551 public:
552         AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y);
553         int handle_event();
554         MWindow *mwindow;
555         AWindowGUI *gui;
556         int x, y;
557 };
558
559 class AWindowView : public BC_Button
560 {
561 public:
562         AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y);
563         int handle_event();
564         MWindow *mwindow;
565         AWindowGUI *gui;
566         int x, y;
567 };
568
569 class AddTools : public BC_PopupMenu
570 {
571 public:
572         AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title);
573         void create_objects();
574
575         MWindow *mwindow;
576         AWindowGUI *gui;
577 };
578
579 class AddPluginItem : public BC_MenuItem
580 {
581 public:
582         AddPluginItem(AddTools *menu, const char *text, int idx);
583         int handle_event();
584
585         AddTools *menu;
586         int idx;
587 };
588
589 class AVIconDrawingItem : public BC_MenuItem
590 {
591 public:
592         AVIconDrawingItem(AVIconDrawing *avicon, const char *text, int id);
593         int handle_event();
594
595         AVIconDrawing *avicon;
596         int id;
597 };
598
599 class AVIconDrawing : public BC_PopupMenu
600 {
601 public:
602         AVIconDrawing(AWindowGUI *agui, int x, int y, int w, const char *text);
603         ~AVIconDrawing();
604
605         static const char *avicon_names[];
606         void create_objects();
607         int button_press_event();
608         int draw_face(int dx, int color);
609
610         AWindowGUI *agui;
611 };
612
613
614 class AWindowListFormat : public BC_MenuItem
615 {
616 public:
617         AWindowListFormat(MWindow *mwindow, AWindowGUI *gui);
618
619         void update();
620         int handle_event();
621         MWindow *mwindow;
622         AWindowGUI *gui;
623 };
624
625
626 class AWindowListSort : public BC_MenuItem
627 {
628 public:
629         AWindowListSort(MWindow *mwindow, AWindowGUI *gui);
630
631         void update();
632         int handle_event();
633         MWindow *mwindow;
634         AWindowGUI *gui;
635 };
636
637 class AssetSelectUsedItem : public BC_MenuItem
638 {
639 public:
640         AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action);
641         int handle_event();
642
643         int action;
644         AssetSelectUsed *select_used;
645 };
646
647 class AssetSelectUsed : public BC_MenuItem
648 {
649 public:
650         AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui);
651
652         MWindow *mwindow;
653         AWindowGUI *gui;
654 };
655
656 #endif