upgrade ffmpeg to 3.4.2, add proxy popup, undo/redo deadlock fix, rework nested edl
[goodguy/history.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 "assetpopup.inc"
28 #include "asset.inc"
29 #include "assets.inc"
30 #include "audiodevice.inc"
31 #include "awindow.inc"
32 #include "awindowgui.inc"
33 #include "clippopup.inc"
34 #include "edl.inc"
35 #include "effectlist.inc"
36 #include "folderlistmenu.inc"
37 #include "guicast.h"
38 #include "labeledit.inc"
39 #include "labelpopup.inc"
40 #include "labels.h"
41 #include "indexable.inc"
42 #include "mwindow.inc"
43 #include "newfolder.inc"
44 #include "pluginserver.inc"
45 #include "proxypopup.inc"
46 #include "renderengine.inc"
47 #include "samples.inc"
48 #include "vicon.h"
49
50 class AssetPicon : public BC_ListBoxItem
51 {
52 public:
53         AssetPicon(MWindow *mwindow, AWindowGUI *gui, Indexable *indexable);
54         AssetPicon(MWindow *mwindow, AWindowGUI *gui, EDL *edl);
55         AssetPicon(MWindow *mwindow, AWindowGUI *gui, PluginServer *plugin);
56         AssetPicon(MWindow *mwindow, AWindowGUI *gui, Label *plugin);
57         AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, int persist);
58         virtual ~AssetPicon();
59
60         void create_objects();
61         void reset();
62         static void draw_hue_bar(VFrame *frame, double t);
63         static void draw_wave(VFrame *frame, double *dp, int len,
64                 int base_color, int line_color);
65         void open_render_engine(EDL *edl, int is_audio);
66         void close_render_engine();
67         void render_video(int64_t pos, VFrame *vfrm);
68         void render_audio(int64_t pos, Samples **samples, int len);
69
70         MWindow *mwindow;
71         AWindowGUI *gui;
72         BC_Pixmap *icon;
73         VFrame *icon_vframe;
74         int foldernum;
75 // ID of thing pointed to
76         int id;
77
78 // Check ID first.  Update these next before dereferencing
79 // Asset if asset
80         Indexable *indexable;
81 // EDL if clip
82         EDL *edl;
83
84         int in_use;
85         time_t mtime;
86
87         int persistent;
88         PluginServer *plugin;
89         Label *label;
90         VIcon *vicon;
91         RenderEngine *render_engine;
92 };
93
94 typedef int16_t vicon_audio_t;
95
96 class AssetVIconAudio : public Thread
97 {
98 public:
99         AssetVIconAudio(AWindowGUI *gui);
100         ~AssetVIconAudio();
101
102         void run();
103         void start(AssetVIcon *vicon);
104         void stop(int wait);
105
106         AWindowGUI *gui;
107         AudioDevice *audio;
108         AssetVIcon *vicon;
109         int interrupted;
110         int audio_pos;
111 };
112
113 class AssetVIcon : public VIcon {
114 public:
115         AssetPicon *picon;
116         VFrame *temp;
117         int64_t length;
118
119         VFrame *frame();
120         int64_t set_seq_no(int64_t no);
121         int get_vx();
122         int get_vy();
123         void load_audio();
124         void start_audio();
125         void stop_audio();
126
127         AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
128         ~AssetVIcon();
129 };
130
131 class AWindowRemovePlugin;
132
133 class AWindowRemovePluginGUI : public BC_Window {
134 public:
135         AWindow *awindow;
136         AWindowRemovePlugin *thread;
137         PluginServer *plugin;
138         ArrayList<BC_ListBoxItem*> plugin_list;
139         BC_Pixmap *icon;
140         VFrame *icon_vframe;
141         BC_ListBox *list;
142
143         void create_objects();
144
145         AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
146                  int x, int y, PluginServer *plugin);
147         ~AWindowRemovePluginGUI();
148 };
149
150 class AWindowRemovePlugin : public BC_DialogThread {
151 public:
152         AWindow *awindow;
153         PluginServer *plugin;
154         BC_Window* new_gui();
155         void handle_close_event(int result);
156         int remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder);
157
158         AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin);
159         ~AWindowRemovePlugin();
160 };
161
162 class AWindowGUI : public BC_Window
163 {
164 public:
165         AWindowGUI(MWindow *mwindow, AWindow *awindow);
166         ~AWindowGUI();
167
168         void create_objects();
169         int resize_event(int w, int h);
170         int translation_event();
171         int close_event();
172         int keypress_event();
173         void async_update_assets();     // Sends update asset event
174         void update_effects();
175         void sort_assets(int use_mtime);
176         void sort_folders();
177         void reposition_objects();
178         static int folder_number(const char *name);
179 // Call back for MWindow entry point
180         int drag_motion();
181         int drag_stop();
182 // Collect items into the drag vectors of MainSession
183         void collect_assets(int proxy=0);
184         EDL *collect_proxy(Indexable *indexable);
185         void create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
186                 int do_audio,
187                 int do_video,
188                 int is_realtime,
189                 int is_transition);
190         void create_label_folder();
191         void copy_picons(ArrayList<BC_ListBoxItem*> *dst,
192                 ArrayList<BC_ListBoxItem*> *src, int folder);
193         void sort_picons(ArrayList<BC_ListBoxItem*> *src, int use_mtime=0);
194 // Return the selected asset in asset_list
195         Indexable* selected_asset();
196         PluginServer* selected_plugin();
197         AssetPicon* selected_folder();
198         bool protected_pixmap(BC_Pixmap *pixmap);
199         int save_defaults(BC_Hash *defaults);
200         int load_defaults(BC_Hash *defaults);
201         void start_vicon_drawing();
202         void stop_vicon_drawing();
203         void update_picon(Indexable *indexable);
204
205         VFrame *get_picon(const char *name, const char *plugin_icons);
206         VFrame *get_picon(const char *name);
207         void resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx);
208         void theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn);
209         void plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png);
210
211         MWindow *mwindow;
212         AWindow *awindow;
213
214         AWindowAssets *asset_list;
215         AWindowFolders *folder_list;
216         AWindowDivider *divider;
217         AWindowSearchText *search_text;
218
219 // Store data to speed up responses
220 // Persistant data for listboxes
221 // All assets in current EDL
222         ArrayList<BC_ListBoxItem*> assets;
223         ArrayList<BC_ListBoxItem*> folders;
224         ArrayList<BC_ListBoxItem*> aeffects;
225         ArrayList<BC_ListBoxItem*> veffects;
226         ArrayList<BC_ListBoxItem*> atransitions;
227         ArrayList<BC_ListBoxItem*> vtransitions;
228         ArrayList<BC_ListBoxItem*> labellist;
229
230 // Currently displayed data for listboxes
231 // Currently displayed assets + comments
232         ArrayList<BC_ListBoxItem*> displayed_assets[2];
233         const char *asset_titles[ASSET_COLUMNS];
234         int displayed_folder;
235
236         BC_Hash *defaults;
237 // Persistent icons
238         BC_Pixmap *aeffect_folder_icon;      VFrame *aeffect_folder_vframe;
239         BC_Pixmap *atransition_folder_icon;  VFrame *atransition_folder_vframe;
240         BC_Pixmap *clip_folder_icon;         VFrame *clip_folder_vframe;
241         BC_Pixmap *label_folder_icon;        VFrame *label_folder_vframe;
242         BC_Pixmap *media_folder_icon;        VFrame *media_folder_vframe;
243         BC_Pixmap *proxy_folder_icon;        VFrame *proxy_folder_vframe;
244         BC_Pixmap *veffect_folder_icon;      VFrame *veffect_folder_vframe;
245         BC_Pixmap *vtransition_folder_icon;  VFrame *vtransition_folder_vframe;
246         BC_Pixmap *folder_icons[AWINDOW_FOLDERS];
247
248         BC_Pixmap *folder_icon;       VFrame *folder_vframe;
249         BC_Pixmap *file_icon;         VFrame *file_vframe;
250         BC_Pixmap *audio_icon;        VFrame *audio_vframe;
251         BC_Pixmap *video_icon;        VFrame *video_vframe;
252         BC_Pixmap *label_icon;        VFrame *label_vframe;
253         BC_Pixmap *clip_icon;         VFrame *clip_vframe;
254         BC_Pixmap *atransition_icon;  VFrame *atransition_vframe;
255         BC_Pixmap *vtransition_icon;  VFrame *vtransition_vframe;
256         BC_Pixmap *aeffect_icon;      VFrame *aeffect_vframe;
257         BC_Pixmap *veffect_icon;      VFrame *veffect_vframe;
258         BC_Pixmap *ladspa_icon;       VFrame *ladspa_vframe;
259         BC_Pixmap *ff_aud_icon;       VFrame *ff_aud_vframe;
260         BC_Pixmap *ff_vid_icon;       VFrame *ff_vid_vframe;
261
262         NewFolderThread *newfolder_thread;
263
264 // Popup menus
265         AssetPopup *asset_menu;
266         ClipPopup *clip_menu;
267         LabelPopup *label_menu;
268         ProxyPopup *proxy_menu;
269         EffectListMenu *effectlist_menu;
270         AssetListMenu *assetlist_menu;
271         ClipListMenu *cliplist_menu;
272         LabelListMenu *labellist_menu;
273         ProxyListMenu *proxylist_menu;
274         FolderListMenu *folderlist_menu;
275         AddTools *add_tools;
276 // Temporary for reading picons from files
277         VFrame *temp_picon;
278         VIconThread *vicon_thread;
279         AssetVIconAudio *vicon_audio;
280
281         int64_t plugin_visibility;
282         AWindowRemovePlugin *remove_plugin;
283
284         AVIconDrawing *avicon_drawing;
285         int avicon_w, avicon_h, vicon_drawing;
286         int allow_iconlisting;
287
288 // Create custom atoms to be used for async messages between windows
289         int create_custom_xatoms();
290 // Function to overload to recieve customly defined atoms
291         virtual int recieve_custom_xatoms(xatom_event *event);
292         static const char *folder_names[];
293
294 private:
295         void update_folder_list();
296         void update_asset_list();
297         void filter_displayed_assets();
298         Atom UpdateAssetsXAtom;
299         void update_assets();
300
301 };
302
303 class AWindowAssets : public BC_ListBox
304 {
305 public:
306         AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
307         ~AWindowAssets();
308
309         int handle_event();
310         int selection_changed();
311         void draw_background();
312         int drag_start_event();
313         int drag_motion_event();
314         int drag_stop_event();
315         int button_press_event();
316         int column_resize_event();
317         int focus_in_event();
318         int focus_out_event();
319
320         MWindow *mwindow;
321         AWindowGUI *gui;
322 };
323
324 class AWindowDivider : public BC_SubWindow
325 {
326 public:
327         AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
328         ~AWindowDivider();
329
330         int button_press_event();
331         int cursor_motion_event();
332         int button_release_event();
333
334         MWindow *mwindow;
335         AWindowGUI *gui;
336 };
337
338 class AWindowFolders : public BC_ListBox
339 {
340 public:
341         AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
342         ~AWindowFolders();
343
344         int selection_changed();
345         int button_press_event();
346
347         MWindow *mwindow;
348         AWindowGUI *gui;
349 };
350
351 class AWindowSearchTextBox : public BC_TextBox
352 {
353 public:
354         AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w);
355         int handle_event();
356
357         AWindowSearchText *search_text;
358 };
359
360 class AWindowSearchText
361 {
362 public:
363         AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y);
364
365         int handle_event();
366         void create_objects();
367         int get_w();
368         int get_h();
369         void reposition_window(int x, int y, int w);
370         const char *get_text();
371         void clear();
372
373         MWindow *mwindow;
374         AWindowGUI *gui;
375         int x, y;
376         BC_Title *text_title;
377         BC_TextBox *text_box;
378 };
379
380 class AWindowNewFolder : public BC_Button
381 {
382 public:
383         AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y);
384         int handle_event();
385         MWindow *mwindow;
386         AWindowGUI *gui;
387         int x, y;
388 };
389
390 class AWindowDeleteFolder : public BC_Button
391 {
392 public:
393         AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y);
394         int handle_event();
395         MWindow *mwindow;
396         AWindowGUI *gui;
397         int x, y;
398 };
399
400 class AWindowRenameFolder : public BC_Button
401 {
402 public:
403         AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y);
404         int handle_event();
405         MWindow *mwindow;
406         AWindowGUI *gui;
407         int x, y;
408 };
409
410 class AWindowDeleteDisk : public BC_Button
411 {
412 public:
413         AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y);
414         int handle_event();
415         MWindow *mwindow;
416         AWindowGUI *gui;
417         int x, y;
418 };
419
420 class AWindowDeleteProject : public BC_Button
421 {
422 public:
423         AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y);
424         int handle_event();
425         MWindow *mwindow;
426         AWindowGUI *gui;
427         int x, y;
428 };
429
430 class AWindowInfo : public BC_Button
431 {
432 public:
433         AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y);
434         int handle_event();
435         MWindow *mwindow;
436         AWindowGUI *gui;
437         int x, y;
438 };
439
440 class AWindowRedrawIndex : public BC_Button
441 {
442 public:
443         AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y);
444         int handle_event();
445         MWindow *mwindow;
446         AWindowGUI *gui;
447         int x, y;
448 };
449
450 class AWindowPaste : public BC_Button
451 {
452 public:
453         AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y);
454         int handle_event();
455         MWindow *mwindow;
456         AWindowGUI *gui;
457         int x, y;
458 };
459
460 class AWindowAppend : public BC_Button
461 {
462 public:
463         AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y);
464         int handle_event();
465         MWindow *mwindow;
466         AWindowGUI *gui;
467         int x, y;
468 };
469
470 class AWindowView : public BC_Button
471 {
472 public:
473         AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y);
474         int handle_event();
475         MWindow *mwindow;
476         AWindowGUI *gui;
477         int x, y;
478 };
479
480 class AddTools : public BC_PopupMenu
481 {
482 public:
483         AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title);
484         void create_objects();
485
486         MWindow *mwindow;
487         AWindowGUI *gui;
488 };
489
490 class AddPluginItem : public BC_MenuItem
491 {
492 public:
493         AddPluginItem(AddTools *menu, const char *text, int idx);
494         int handle_event();
495
496         AddTools *menu;
497         int idx;
498 };
499
500 class AVIconDrawing : public BC_Toggle
501 {
502 public:
503         AWindowGUI *agui;
504
505         int handle_event();
506         static void calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh);
507
508         AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images);
509         ~AVIconDrawing();
510 };
511
512
513 class AWindowListFormat : public BC_MenuItem
514 {
515 public:
516         AWindowListFormat(MWindow *mwindow, AWindowGUI *gui);
517
518         void update();
519         int handle_event();
520         MWindow *mwindow;
521         AWindowGUI *gui;
522 };
523
524
525 class AWindowListSort : public BC_MenuItem
526 {
527 public:
528         AWindowListSort(MWindow *mwindow, AWindowGUI *gui);
529
530         void update();
531         int handle_event();
532         MWindow *mwindow;
533         AWindowGUI *gui;
534 };
535
536 #endif