prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / 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 "indexable.inc"
35 #include "mwindow.inc"
36 #include "newfolder.inc"
37 #include "pluginserver.inc"
38 #include "vicon.h"
39
40 class AWindowAssets;
41 class AWindowFolders;
42 class AWindowNewFolder;
43 class AWindowDeleteFolder;
44 class AWindowRenameFolder;
45 class AWindowDeleteDisk;
46 class AWindowDeleteProject;
47 class AWindowDivider;
48 class AWindowInfo;
49 class AWindowRedrawIndex;
50 class AWindowPaste;
51 class AWindowAppend;
52 class AWindowView;
53 class AddTools;
54 class AddPluginsMenu;
55 class AddPluginItem;
56 class AVIconDrawing;
57
58 class AssetPicon;
59 class AssetVIcon;
60 class AWindowGUI;
61
62 class AssetPicon : public BC_ListBoxItem
63 {
64 public:
65         AssetPicon(MWindow *mwindow, AWindowGUI *gui, Indexable *indexable);
66         AssetPicon(MWindow *mwindow, AWindowGUI *gui, EDL *edl);
67         AssetPicon(MWindow *mwindow, AWindowGUI *gui, PluginServer *plugin);
68         AssetPicon(MWindow *mwindow, AWindowGUI *gui, const char *folder);
69         virtual ~AssetPicon();
70
71         void create_objects();
72         void reset();
73
74         MWindow *mwindow;
75         AWindowGUI *gui;
76         BC_Pixmap *icon;
77         VFrame *icon_vframe;
78 // ID of thing pointed to
79         int id;
80
81 // Check ID first.  Update these next before dereferencing
82 // Asset if asset
83         Indexable *indexable;
84 // EDL if clip
85         EDL *edl;
86
87         int in_use;
88
89
90         int persistent;
91         PluginServer *plugin;
92         VIcon *vicon;
93 };
94
95 class AssetVIcon : public VIcon {
96 public:
97         AssetPicon *picon;
98         VFrame *temp;
99         int64_t length;
100
101         VFrame *frame();
102         int64_t set_seq_no(int64_t no);
103         int get_vx();
104         int get_vy();
105
106         AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
107         ~AssetVIcon();
108 };
109
110 class AWindowRemovePlugin;
111
112 class AWindowRemovePluginGUI : public BC_Window {
113 public:
114         AWindow *awindow;
115         AWindowRemovePlugin *thread;
116         PluginServer *plugin;
117         ArrayList<BC_ListBoxItem*> plugin_list;
118         BC_Pixmap *icon;
119         VFrame *icon_vframe;
120         BC_ListBox *list;
121
122         void create_objects();
123
124         AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
125                  int x, int y, PluginServer *plugin);
126         ~AWindowRemovePluginGUI();
127 };
128
129 class AWindowRemovePlugin : public BC_DialogThread {
130 public:
131         AWindow *awindow;
132         PluginServer *plugin;
133         BC_Window* new_gui();
134         void handle_close_event(int result);
135         int remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder);
136
137         AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin);
138         ~AWindowRemovePlugin();
139 };
140
141 class AWindowGUI : public BC_Window
142 {
143 public:
144         AWindowGUI(MWindow *mwindow, AWindow *awindow);
145         ~AWindowGUI();
146
147         void create_objects();
148         int resize_event(int w, int h);
149         int translation_event();
150         int close_event();
151         int keypress_event();
152         void update_assets();
153         void update_effects();
154         void sort_assets();
155         void reposition_objects();
156         int current_folder_number();
157 // Call back for MWindow entry point
158         int drag_motion();
159         int drag_stop();
160 // Collect items into the drag vectors of MainSession
161         void collect_assets();
162         void create_persistent_folder(ArrayList<BC_ListBoxItem*> *output, 
163                 int do_audio, 
164                 int do_video, 
165                 int is_realtime, 
166                 int is_transition);
167         void copy_picons(ArrayList<BC_ListBoxItem*> *dst, 
168                 ArrayList<BC_ListBoxItem*> *src, 
169                 char *folder);
170         void sort_picons(ArrayList<BC_ListBoxItem*> *src, 
171                 char *folder);
172 // Return the selected asset in asset_list
173         Indexable* selected_asset();
174         PluginServer* selected_plugin();
175         AssetPicon* selected_folder();
176         bool protected_pixmap(BC_Pixmap *pixmap);
177         int save_defaults(BC_Hash *defaults);
178         int load_defaults(BC_Hash *defaults);
179         void start_vicon_drawing();
180         void stop_vicon_drawing();
181
182         MWindow *mwindow;
183         AWindow *awindow;
184
185         AWindowAssets *asset_list;
186         AWindowFolders *folder_list;
187         AWindowDivider *divider;
188
189 // Store data to speed up responses
190 // Persistant data for listboxes
191 // All assets in current EDL
192         ArrayList<BC_ListBoxItem*> assets;
193         ArrayList<BC_ListBoxItem*> folders;
194         ArrayList<BC_ListBoxItem*> aeffects;
195         ArrayList<BC_ListBoxItem*> veffects;
196         ArrayList<BC_ListBoxItem*> atransitions;
197         ArrayList<BC_ListBoxItem*> vtransitions;
198
199 // Currently displayed data for listboxes
200 // Currently displayed assets + comments
201         ArrayList<BC_ListBoxItem*> displayed_assets[2];
202
203         const char *asset_titles[ASSET_COLUMNS];
204
205         BC_Hash *defaults;
206 // Persistent icons
207         BC_Pixmap *folder_icon;
208         BC_Pixmap *file_icon;
209         BC_Pixmap *audio_icon;
210         BC_Pixmap *video_icon;
211         BC_Pixmap *clip_icon;         VFrame *clip_vframe;
212         BC_Pixmap *atransition_icon;  VFrame *atransition_vframe;
213         BC_Pixmap *vtransition_icon;  VFrame *vtransition_vframe;
214         BC_Pixmap *aeffect_icon;      VFrame *aeffect_vframe;
215         BC_Pixmap *ladspa_icon;       VFrame *ladspa_vframe;
216         BC_Pixmap *ff_aud_icon;       VFrame *ff_aud_vframe;
217         BC_Pixmap *ff_vid_icon;       VFrame *ff_vid_vframe;
218         BC_Pixmap *veffect_icon;      VFrame *veffect_vframe;
219         NewFolderThread *newfolder_thread;
220
221 // Popup menus
222         AssetPopup *asset_menu;
223         AssetListMenu *assetlist_menu;
224         FolderListMenu *folderlist_menu;
225         AddTools *add_tools;
226 // Temporary for reading picons from files
227         VFrame *temp_picon;
228         VIconThread *vicon_thread;
229
230         int64_t plugin_visibility;
231         AWindowRemovePlugin *remove_plugin;
232
233         AVIconDrawing *avicon_drawing;
234         int avicon_w, avicon_h, vicon_drawing;
235 private:
236         void update_folder_list();
237         void update_asset_list();
238         void filter_displayed_assets();
239 };
240
241 class AWindowAssets : public BC_ListBox
242 {
243 public:
244         AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
245         ~AWindowAssets();
246         
247         int handle_event();
248         int selection_changed();
249         void draw_background();
250         int drag_start_event();
251         int drag_motion_event();
252         int drag_stop_event();
253         int button_press_event();
254         int column_resize_event();
255         int cursor_enter_event();
256         int cursor_leave_event();
257
258         MWindow *mwindow;
259         AWindowGUI *gui;
260 };
261
262 class AWindowDivider : public BC_SubWindow
263 {
264 public:
265         AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
266         ~AWindowDivider();
267
268         int button_press_event();
269         int cursor_motion_event();
270         int button_release_event();
271
272         MWindow *mwindow;
273         AWindowGUI *gui;
274 };
275
276 class AWindowFolders : public BC_ListBox
277 {
278 public:
279         AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
280         ~AWindowFolders();
281         
282         int selection_changed();
283         int button_press_event();
284
285         MWindow *mwindow;
286         AWindowGUI *gui;
287 };
288
289 class AWindowNewFolder : public BC_Button
290 {
291 public:
292         AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y);
293         int handle_event();
294         MWindow *mwindow;
295         AWindowGUI *gui;
296         int x, y;
297 };
298
299 class AWindowDeleteFolder : public BC_Button
300 {
301 public:
302         AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y);
303         int handle_event();
304         MWindow *mwindow;
305         AWindowGUI *gui;
306         int x, y;
307 };
308
309 class AWindowRenameFolder : public BC_Button
310 {
311 public:
312         AWindowRenameFolder(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 AWindowDeleteDisk : public BC_Button
320 {
321 public:
322         AWindowDeleteDisk(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 AWindowDeleteProject : public BC_Button
330 {
331 public:
332         AWindowDeleteProject(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 AWindowInfo : public BC_Button
340 {
341 public:
342         AWindowInfo(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 AWindowRedrawIndex : public BC_Button
350 {
351 public:
352         AWindowRedrawIndex(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 AWindowPaste : public BC_Button
360 {
361 public:
362         AWindowPaste(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 AWindowAppend : public BC_Button
370 {
371 public:
372         AWindowAppend(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 AWindowView : public BC_Button
380 {
381 public:
382         AWindowView(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 AddTools : public BC_PopupMenu
390 {
391 public:
392         AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title);
393         void create_objects();
394
395         MWindow *mwindow;
396         AWindowGUI *gui;
397         AddPluginsMenu *add_plugins;
398 };
399
400 class AddPluginItem : public BC_MenuItem
401 {
402 public:
403         AddPluginItem(AddTools *menu, const char *text, int idx);
404         int handle_event();
405
406         AddTools *menu;
407         int idx;
408 };
409
410 class AVIconDrawing : public BC_Toggle
411 {
412 public:
413         AWindowGUI *agui;
414
415         int handle_event();
416         static void calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh);
417
418         AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images);
419         ~AVIconDrawing();
420 };
421
422 #endif