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