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