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