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