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