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