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