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