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