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