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