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