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