d15e19f5d30a87607f2651749c9f7f9ee9e2239c
[goodguy/cinelerra.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 "binfolder.inc"
28 #include "assetpopup.inc"
29 #include "asset.inc"
30 #include "assets.inc"
31 #include "audiodevice.inc"
32 #include "awindow.inc"
33 #include "awindowgui.inc"
34 #include "clippopup.inc"
35 #include "edl.inc"
36 #include "effectlist.inc"
37 #include "folderlistmenu.inc"
38 #include "garbage.h"
39 #include "guicast.h"
40 #include "labeledit.inc"
41 #include "labelpopup.inc"
42 #include "labels.h"
43 #include "indexable.inc"
44 #include "mwindow.inc"
45 #include "mutex.inc"
46 #include "pluginserver.inc"
47 #include "proxypopup.inc"
48 #include "renderengine.inc"
49 #include "samples.inc"
50 #include "vicon.h"
51
52 #define SELECT_ALL 0
53 #define SELECT_USED 1
54 #define SELECT_UNUSED 2
55 #define SELECT_NONE 3
56 #define VIEW_POPUP_BAR_H 15
57
58 class AWindowFolderItem : public BC_ListBoxItem
59 {
60 public:
61         AWindowFolderItem();
62         AWindowFolderItem(const char *text, int color = -1);
63         AWindowFolderItem(const char *text, BC_Pixmap *icon, int color = -1);
64
65         AssetPicon *get_picon();
66         int matches(const char *text);
67
68         AWindowFolderItem *parent;
69 };
70
71 class AssetPicon : public AWindowFolderItem
72 {
73 public:
74         AssetPicon(MWindow *mwindow, AWindowGUI *gui, Indexable *indexable);
75         AssetPicon(MWindow *mwindow, AWindowGUI *gui, EDL *edl);
76         AssetPicon(MWindow *mwindow, AWindowGUI *gui, PluginServer *plugin);
77         AssetPicon(MWindow *mwindow, AWindowGUI *gui, Label *plugin);
78         AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, int persist);
79         AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, const char *title);
80         virtual ~AssetPicon();
81
82         void create_objects();
83         void reset();
84         static void draw_hue_bar(VFrame *frame, double t);
85         static void draw_wave(VFrame *frame, double *dp, int len,
86                 int base_color, int line_color, int x, int y, int w, int h);
87         static void draw_wave(VFrame *frame, double *dp, int len,
88                 int base_color, int line_color, int x=0, int y=0) {
89           draw_wave(frame, dp, len, base_color, line_color,
90                 x,y,frame->get_w(),frame->get_h());
91         }
92         void open_render_engine(EDL *edl, int is_audio);
93         void close_render_engine();
94         void render_video(int64_t pos, VFrame *vfrm);
95         void render_audio(int64_t pos, Samples **samples, int len);
96         VFrame *get_vicon_frame();
97
98         MWindow *mwindow;
99         AWindowGUI *gui;
100         BC_Pixmap *icon;
101         VFrame *icon_vframe;
102         VFrame *vicon_frame;
103         int foldernum;
104 // sublist items if set
105         AWindowFolderSubItems *sub_items;
106
107 // ID of thing pointed to
108         int id;
109
110 // Check ID first.  Update these next before dereferencing
111 // Asset if asset
112         Indexable *indexable;
113 // EDL if clip
114         EDL *edl;
115
116         int in_use;
117         int persistent;
118         time_t comments_time;
119         double sort_key;
120         PluginServer *plugin;
121         Label *label;
122         AssetVIcon *vicon;
123         RenderEngine *render_engine;
124 };
125
126 typedef int16_t vicon_audio_t;
127
128 class AssetVIconAudio : public Thread
129 {
130 public:
131         AssetVIconAudio(AWindowGUI *gui);
132         ~AssetVIconAudio();
133
134         void run();
135         void start(AssetVIcon *vicon);
136         void stop(int wait);
137
138         AWindowGUI *gui;
139         AudioDevice *audio;
140         AssetVIcon *vicon;
141         int interrupted;
142         int audio_pos;
143 };
144
145 class AssetVIcon : public VIcon, public Garbage {
146 public:
147         AssetPicon *picon;
148         VFrame *temp;
149         int64_t length;
150
151         VFrame *frame();
152         int64_t set_seq_no(int64_t no);
153         int get_vx();
154         int get_vy();
155         void load_audio();
156         void start_audio();
157         void stop_audio();
158
159         AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
160         ~AssetVIcon();
161 };
162
163 class AssetVIconThread : public VIconThread
164 {
165 public:
166         AssetVIconThread(AWindowAssets *asset_list);
167         ~AssetVIconThread();
168
169         int popup_button_press(int x, int y);
170         int popup_button_release(int x, int y);
171         int popup_cursor_motion(int x, int y);
172
173         int popup_dragging;
174 };
175
176
177 class AWindowRemovePlugin;
178
179 class AWindowRemovePluginGUI : public BC_Window {
180 public:
181         AWindow *awindow;
182         AWindowRemovePlugin *thread;
183         PluginServer *plugin;
184         ArrayList<BC_ListBoxItem*> plugin_list;
185         BC_Pixmap *icon;
186         VFrame *icon_vframe;
187         BC_ListBox *list;
188
189         void create_objects();
190
191         AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
192                  int x, int y, PluginServer *plugin);
193         ~AWindowRemovePluginGUI();
194 };
195
196 class AWindowRemovePlugin : public BC_DialogThread {
197 public:
198         AWindow *awindow;
199         PluginServer *plugin;
200         BC_Window* new_gui();
201         void handle_close_event(int result);
202         int remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder);
203
204         AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin);
205         ~AWindowRemovePlugin();
206 };
207
208 class AWindowGUI : public BC_Window
209 {
210 public:
211         AWindowGUI(MWindow *mwindow, AWindow *awindow);
212         ~AWindowGUI();
213
214         void create_objects();
215         int resize_event(int w, int h);
216         int translation_event();
217         int close_event();
218         int keypress_event();
219         void async_update_assets();     // Sends update asset event
220         void update_effects();
221         void sort_assets();
222         void sort_folders();
223         void reposition_objects();
224 // Call back for MWindow entry point
225         int drag_motion();
226         int drag_stop();
227 // Collect items into the drag vectors of MainSession
228         void collect_assets(int proxy=0);
229         EDL *collect_proxy(Indexable *indexable);
230         void create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
231                 int do_audio,
232                 int do_video,
233                 int is_realtime,
234                 int is_transition);
235         void create_label_folder();
236         void copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src);
237         void sort_picons(ArrayList<BC_ListBoxItem*> *src);
238 // Return the selected asset in asset_list
239         Indexable* selected_asset();
240         PluginServer* selected_plugin();
241         AssetPicon* selected_folder();
242         bool protected_pixmap(BC_Pixmap *pixmap);
243         int save_defaults(BC_Hash *defaults);
244         int load_defaults(BC_Hash *defaults);
245         void start_vicon_drawing();
246         void stop_vicon_drawing();
247         void update_picon(Indexable *indexable);
248         int cycle_assetlist_format();
249
250         VFrame *get_picon(const char *name, const char *plugin_icons);
251         VFrame *get_picon(const char *name);
252         void resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx);
253         void theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn);
254         void plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png);
255
256         MWindow *mwindow;
257         AWindow *awindow;
258
259         AWindowAssets *asset_list;
260         AWindowFolders *folder_list;
261         AWindowDivider *divider;
262         AWindowSearchText *search_text;
263         Mutex *folder_lock;
264
265 // Store data to speed up responses
266 // Persistant data for listboxes
267 // All assets in current EDL
268         ArrayList<BC_ListBoxItem*> assets;
269         ArrayList<BC_ListBoxItem*> folders;
270         ArrayList<BC_ListBoxItem*> aeffects;
271         ArrayList<BC_ListBoxItem*> veffects;
272         ArrayList<BC_ListBoxItem*> atransitions;
273         ArrayList<BC_ListBoxItem*> vtransitions;
274         ArrayList<BC_ListBoxItem*> labellist;
275
276 // Currently displayed data for listboxes
277 // Currently displayed assets + comments
278         ArrayList<BC_ListBoxItem*> displayed_assets[2];
279         const char *asset_titles[ASSET_COLUMNS];
280         int displayed_folder;
281
282         BC_Hash *defaults;
283 // Persistent icons
284         BC_Pixmap *aeffect_folder_icon;      VFrame *aeffect_folder_vframe;
285         BC_Pixmap *atransition_folder_icon;  VFrame *atransition_folder_vframe;
286         BC_Pixmap *clip_folder_icon;         VFrame *clip_folder_vframe;
287         BC_Pixmap *label_folder_icon;        VFrame *label_folder_vframe;
288         BC_Pixmap *media_folder_icon;        VFrame *media_folder_vframe;
289         BC_Pixmap *proxy_folder_icon;        VFrame *proxy_folder_vframe;
290         BC_Pixmap *veffect_folder_icon;      VFrame *veffect_folder_vframe;
291         BC_Pixmap *vtransition_folder_icon;  VFrame *vtransition_folder_vframe;
292         BC_Pixmap *folder_icons[AWINDOW_FOLDERS];
293
294         BC_Pixmap *folder_icon;       VFrame *folder_vframe;
295         BC_Pixmap *file_icon;         VFrame *file_vframe;
296         BC_Pixmap *audio_icon;        VFrame *audio_vframe;
297         BC_Pixmap *video_icon;        VFrame *video_vframe;
298         BC_Pixmap *label_icon;        VFrame *label_vframe;
299         BC_Pixmap *clip_icon;         VFrame *clip_vframe;
300         BC_Pixmap *atransition_icon;  VFrame *atransition_vframe;
301         BC_Pixmap *vtransition_icon;  VFrame *vtransition_vframe;
302         BC_Pixmap *aeffect_icon;      VFrame *aeffect_vframe;
303         BC_Pixmap *veffect_icon;      VFrame *veffect_vframe;
304         BC_Pixmap *ladspa_icon;       VFrame *ladspa_vframe;
305         BC_Pixmap *ff_aud_icon;       VFrame *ff_aud_vframe;
306         BC_Pixmap *ff_vid_icon;       VFrame *ff_vid_vframe;
307
308 // Popup menus
309         AssetPopup *asset_menu;
310         ClipPopup *clip_menu;
311         LabelPopup *label_menu;
312         ProxyPopup *proxy_menu;
313         EffectListMenu *effectlist_menu;
314         AssetListMenu *assetlist_menu;
315         ClipListMenu *cliplist_menu;
316         LabelListMenu *labellist_menu;
317         ProxyListMenu *proxylist_menu;
318         FolderListMenu *folderlist_menu;
319         AddTools *add_tools;
320 // Temporary for reading picons from files
321         VFrame *temp_picon;
322         VIconThread *vicon_thread;
323         AssetVIconAudio *vicon_audio;
324
325         int64_t plugin_visibility;
326         AWindowRemovePlugin *remove_plugin;
327
328         AVIconDrawing *avicon_drawing;
329         int avicon_w, avicon_h, vicon_drawing;
330         int allow_iconlisting;
331
332 // Create custom atoms to be used for async messages between windows
333         int create_custom_xatoms();
334 // Function to overload to receive customly defined atoms
335         virtual int receive_custom_xatoms(xatom_event *event);
336         static const char *folder_names[];
337         NewFolderThread *new_folder_thread;
338         ModifyFolderThread *modify_folder_thread;
339
340 private:
341         void update_folder_list();
342         void update_asset_list();
343         void filter_displayed_assets();
344         Atom UpdateAssetsXAtom;
345         void update_assets();
346
347 };
348
349 class AWindowAssets : public BC_ListBox
350 {
351 public:
352         AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
353         ~AWindowAssets();
354
355         int handle_event();
356         int selection_changed();
357         void draw_background();
358         int drag_start_event();
359         int drag_motion_event();
360         int drag_stop_event();
361         int button_press_event();
362         int column_resize_event();
363         int focus_in_event();
364         int focus_out_event();
365         int cursor_enter_event();
366         int cursor_leave_event();
367         void update_vicon_area();
368         int mouse_over_event(int no);
369         static VIconDrawVFrame draw_vframe;
370         VIconDrawVFrame *draw_func;
371
372         MWindow *mwindow;
373         AWindowGUI *gui;
374 };
375
376 class AWindowDivider : public BC_SubWindow
377 {
378 public:
379         AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
380         ~AWindowDivider();
381
382         int button_press_event();
383         int cursor_motion_event();
384         int button_release_event();
385
386         MWindow *mwindow;
387         AWindowGUI *gui;
388 };
389
390 class AWindowSubFolderNames : public ArrayList<const char *>
391 {
392 public:
393         AWindowSubFolderNames() { set_array_delete(); }
394         ~AWindowSubFolderNames() { remove_all_objects(); }
395 };
396
397 class AWindowFolderSubItems : public AWindowFolderItem
398 {
399 public:
400         AWindowFolderSubItems(AWindowFolderItem *parent, const char *text);
401         int matches(const char *text);
402
403         AWindowSubFolderNames names;
404 };
405
406 class AWindowFolders : public BC_ListBox
407 {
408 public:
409         AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
410         ~AWindowFolders();
411
412         int selection_changed();
413         int button_press_event();
414         int drag_stop();
415         int load_expanders();
416
417         MWindow *mwindow;
418         AWindowGUI *gui;
419 // last selection
420         AWindowFolderItem *last_item0, *last_item1;
421 };
422
423 class AWindowSearchTextBox : public BC_TextBox
424 {
425 public:
426         AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w);
427         int handle_event();
428
429         AWindowSearchText *search_text;
430 };
431
432 class AWindowSearchText
433 {
434 public:
435         AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y);
436
437         int handle_event();
438         void create_objects();
439         int get_w();
440         int get_h();
441         void reposition_window(int x, int y, int w);
442         const char *get_text();
443         void clear();
444
445         MWindow *mwindow;
446         AWindowGUI *gui;
447         int x, y;
448         BC_Title *text_title;
449         BC_TextBox *text_box;
450 };
451
452 class AWindowDeleteDisk : public BC_Button
453 {
454 public:
455         AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y);
456         int handle_event();
457         MWindow *mwindow;
458         AWindowGUI *gui;
459         int x, y;
460 };
461
462 class AWindowDeleteProject : public BC_Button
463 {
464 public:
465         AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y);
466         int handle_event();
467         MWindow *mwindow;
468         AWindowGUI *gui;
469         int x, y;
470 };
471
472 class AWindowInfo : public BC_Button
473 {
474 public:
475         AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y);
476         int handle_event();
477         MWindow *mwindow;
478         AWindowGUI *gui;
479         int x, y;
480 };
481
482 class AWindowRedrawIndex : public BC_Button
483 {
484 public:
485         AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y);
486         int handle_event();
487         MWindow *mwindow;
488         AWindowGUI *gui;
489         int x, y;
490 };
491
492 class AWindowPaste : public BC_Button
493 {
494 public:
495         AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y);
496         int handle_event();
497         MWindow *mwindow;
498         AWindowGUI *gui;
499         int x, y;
500 };
501
502 class AWindowAppend : public BC_Button
503 {
504 public:
505         AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y);
506         int handle_event();
507         MWindow *mwindow;
508         AWindowGUI *gui;
509         int x, y;
510 };
511
512 class AWindowView : public BC_Button
513 {
514 public:
515         AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y);
516         int handle_event();
517         MWindow *mwindow;
518         AWindowGUI *gui;
519         int x, y;
520 };
521
522 class AddTools : public BC_PopupMenu
523 {
524 public:
525         AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title);
526         void create_objects();
527
528         MWindow *mwindow;
529         AWindowGUI *gui;
530 };
531
532 class AddPluginItem : public BC_MenuItem
533 {
534 public:
535         AddPluginItem(AddTools *menu, const char *text, int idx);
536         int handle_event();
537
538         AddTools *menu;
539         int idx;
540 };
541
542 class AVIconDrawing : public BC_Toggle
543 {
544 public:
545         AWindowGUI *agui;
546
547         int handle_event();
548         static void calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh);
549
550         AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images);
551         ~AVIconDrawing();
552 };
553
554
555 class AWindowListFormat : public BC_MenuItem
556 {
557 public:
558         AWindowListFormat(MWindow *mwindow, AWindowGUI *gui);
559
560         void update();
561         int handle_event();
562         MWindow *mwindow;
563         AWindowGUI *gui;
564 };
565
566
567 class AWindowListSort : public BC_MenuItem
568 {
569 public:
570         AWindowListSort(MWindow *mwindow, AWindowGUI *gui);
571
572         void update();
573         int handle_event();
574         MWindow *mwindow;
575         AWindowGUI *gui;
576 };
577
578 class AssetSelectUsedItem : public BC_MenuItem
579 {
580 public:
581         AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action);
582         int handle_event();
583
584         int action;
585         AssetSelectUsed *select_used;
586 };
587
588 class AssetSelectUsed : public BC_MenuItem
589 {
590 public:
591         AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui);
592
593         MWindow *mwindow;
594         AWindowGUI *gui;
595 };
596
597 #endif