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