fc03cbc87d0c14d50a3f9912b97443d673dadab9
[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         int64_t length;
99
100         VFrame *frame();
101         int64_t next_frame(int n);
102         int get_vx();
103         int get_vy();
104
105         AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
106         ~AssetVIcon();
107 };
108
109 class AWindowRemovePlugin;
110
111 class AWindowRemovePluginGUI : public BC_Window {
112 public:
113         AWindow *awindow;
114         AWindowRemovePlugin *thread;
115         PluginServer *plugin;
116         ArrayList<BC_ListBoxItem*> plugin_list;
117         BC_Pixmap *icon;
118         VFrame *icon_vframe;
119         BC_ListBox *list;
120
121         void create_objects();
122
123         AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
124                  int x, int y, PluginServer *plugin);
125         ~AWindowRemovePluginGUI();
126 };
127
128 class AWindowRemovePlugin : public BC_DialogThread {
129 public:
130         AWindow *awindow;
131         PluginServer *plugin;
132         BC_Window* new_gui();
133         void handle_close_event(int result);
134         int remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder);
135
136         AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin);
137         ~AWindowRemovePlugin();
138 };
139
140 class AWindowGUI : public BC_Window
141 {
142 public:
143         AWindowGUI(MWindow *mwindow, AWindow *awindow);
144         ~AWindowGUI();
145
146         void create_objects();
147         int resize_event(int w, int h);
148         int translation_event();
149         int close_event();
150         int keypress_event();
151         void update_assets();
152         void update_effects();
153         void sort_assets();
154         void reposition_objects();
155         int current_folder_number();
156 // Call back for MWindow entry point
157         int drag_motion();
158         int drag_stop();
159 // Collect items into the drag vectors of MainSession
160         void collect_assets();
161         void create_persistent_folder(ArrayList<BC_ListBoxItem*> *output, 
162                 int do_audio, 
163                 int do_video, 
164                 int is_realtime, 
165                 int is_transition);
166         void copy_picons(ArrayList<BC_ListBoxItem*> *dst, 
167                 ArrayList<BC_ListBoxItem*> *src, 
168                 char *folder);
169         void sort_picons(ArrayList<BC_ListBoxItem*> *src, 
170                 char *folder);
171 // Return the selected asset in asset_list
172         Indexable* selected_asset();
173         PluginServer* selected_plugin();
174         AssetPicon* selected_folder();
175         bool protected_pixmap(BC_Pixmap *pixmap);
176         int save_defaults(BC_Hash *defaults);
177         int load_defaults(BC_Hash *defaults);
178         void start_vicon_drawing();
179         void stop_vicon_drawing();
180
181         MWindow *mwindow;
182         AWindow *awindow;
183
184         AWindowAssets *asset_list;
185         AWindowFolders *folder_list;
186         AWindowDivider *divider;
187
188 // Store data to speed up responses
189 // Persistant data for listboxes
190 // All assets in current EDL
191         ArrayList<BC_ListBoxItem*> assets;
192         ArrayList<BC_ListBoxItem*> folders;
193         ArrayList<BC_ListBoxItem*> aeffects;
194         ArrayList<BC_ListBoxItem*> veffects;
195         ArrayList<BC_ListBoxItem*> atransitions;
196         ArrayList<BC_ListBoxItem*> vtransitions;
197
198 // Currently displayed data for listboxes
199 // Currently displayed assets + comments
200         ArrayList<BC_ListBoxItem*> displayed_assets[2];
201
202         const char *asset_titles[ASSET_COLUMNS];
203
204         BC_Hash *defaults;
205 // Persistent icons
206         BC_Pixmap *folder_icon;
207         BC_Pixmap *file_icon;
208         BC_Pixmap *audio_icon;
209         BC_Pixmap *video_icon;
210         BC_Pixmap *clip_icon;         VFrame *clip_vframe;
211         BC_Pixmap *atransition_icon;  VFrame *atransition_vframe;
212         BC_Pixmap *vtransition_icon;  VFrame *vtransition_vframe;
213         BC_Pixmap *aeffect_icon;      VFrame *aeffect_vframe;
214         BC_Pixmap *ladspa_icon;       VFrame *ladspa_vframe;
215         BC_Pixmap *ff_aud_icon;       VFrame *ff_aud_vframe;
216         BC_Pixmap *ff_vid_icon;       VFrame *ff_vid_vframe;
217         BC_Pixmap *veffect_icon;      VFrame *veffect_vframe;
218         NewFolderThread *newfolder_thread;
219
220 // Popup menus
221         AssetPopup *asset_menu;
222         AssetListMenu *assetlist_menu;
223         FolderListMenu *folderlist_menu;
224         AddTools *add_tools;
225 // Temporary for reading picons from files
226         VFrame *temp_picon;
227         VIconThread *vicon_thread;
228
229         int64_t plugin_visibility;
230         AWindowRemovePlugin *remove_plugin;
231
232         AVIconDrawing *avicon_drawing;
233         int avicon_w, avicon_h, vicon_drawing;
234 private:
235         void update_folder_list();
236         void update_asset_list();
237         void filter_displayed_assets();
238 };
239
240 class AWindowAssets : public BC_ListBox
241 {
242 public:
243         AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
244         ~AWindowAssets();
245         
246         int handle_event();
247         int selection_changed();
248         void draw_background();
249         int drag_start_event();
250         int drag_motion_event();
251         int drag_stop_event();
252         int button_press_event();
253         int column_resize_event();
254         int cursor_enter_event();
255         int cursor_leave_event();
256
257         MWindow *mwindow;
258         AWindowGUI *gui;
259 };
260
261 class AWindowDivider : public BC_SubWindow
262 {
263 public:
264         AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
265         ~AWindowDivider();
266
267         int button_press_event();
268         int cursor_motion_event();
269         int button_release_event();
270
271         MWindow *mwindow;
272         AWindowGUI *gui;
273 };
274
275 class AWindowFolders : public BC_ListBox
276 {
277 public:
278         AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
279         ~AWindowFolders();
280         
281         int selection_changed();
282         int button_press_event();
283
284         MWindow *mwindow;
285         AWindowGUI *gui;
286 };
287
288 class AWindowNewFolder : public BC_Button
289 {
290 public:
291         AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y);
292         int handle_event();
293         MWindow *mwindow;
294         AWindowGUI *gui;
295         int x, y;
296 };
297
298 class AWindowDeleteFolder : public BC_Button
299 {
300 public:
301         AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y);
302         int handle_event();
303         MWindow *mwindow;
304         AWindowGUI *gui;
305         int x, y;
306 };
307
308 class AWindowRenameFolder : public BC_Button
309 {
310 public:
311         AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y);
312         int handle_event();
313         MWindow *mwindow;
314         AWindowGUI *gui;
315         int x, y;
316 };
317
318 class AWindowDeleteDisk : public BC_Button
319 {
320 public:
321         AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y);
322         int handle_event();
323         MWindow *mwindow;
324         AWindowGUI *gui;
325         int x, y;
326 };
327
328 class AWindowDeleteProject : public BC_Button
329 {
330 public:
331         AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y);
332         int handle_event();
333         MWindow *mwindow;
334         AWindowGUI *gui;
335         int x, y;
336 };
337
338 class AWindowInfo : public BC_Button
339 {
340 public:
341         AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y);
342         int handle_event();
343         MWindow *mwindow;
344         AWindowGUI *gui;
345         int x, y;
346 };
347
348 class AWindowRedrawIndex : public BC_Button
349 {
350 public:
351         AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y);
352         int handle_event();
353         MWindow *mwindow;
354         AWindowGUI *gui;
355         int x, y;
356 };
357
358 class AWindowPaste : public BC_Button
359 {
360 public:
361         AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y);
362         int handle_event();
363         MWindow *mwindow;
364         AWindowGUI *gui;
365         int x, y;
366 };
367
368 class AWindowAppend : public BC_Button
369 {
370 public:
371         AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y);
372         int handle_event();
373         MWindow *mwindow;
374         AWindowGUI *gui;
375         int x, y;
376 };
377
378 class AWindowView : public BC_Button
379 {
380 public:
381         AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y);
382         int handle_event();
383         MWindow *mwindow;
384         AWindowGUI *gui;
385         int x, y;
386 };
387
388 class AddTools : public BC_MenuBar
389 {
390 public:
391         AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w);
392         void create_objects();
393
394         MWindow *mwindow;
395         AWindowGUI *gui;
396         AddPluginsMenu *add_plugins;
397 };
398
399 class AddPluginsMenu : public BC_Menu
400 {
401 public:
402         AddPluginsMenu(MWindow *mwindow, AWindowGUI *gui);
403         void create_objects();
404
405         MWindow *mwindow;
406         AWindowGUI *gui;
407 };
408
409 class AddPluginItem : public BC_MenuItem
410 {
411 public:
412         AddPluginItem(AddPluginsMenu *menu, const char *text, int idx);
413         int handle_event();
414
415         AddPluginsMenu *menu;
416         int idx;
417 };
418
419 class AVIconDrawing : public BC_Toggle
420 {
421 public:
422         AWindowGUI *agui;
423
424         int handle_event();
425         static void calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh);
426
427         AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images);
428         ~AVIconDrawing();
429 };
430
431 #endif