4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
25 #include "arraylist.h"
27 #include "binfolder.inc"
28 #include "assetpopup.inc"
31 #include "audiodevice.inc"
32 #include "awindow.inc"
33 #include "awindowgui.inc"
34 #include "clippopup.inc"
36 #include "effectlist.inc"
37 #include "folderlistmenu.inc"
40 #include "labeledit.inc"
41 #include "labelpopup.inc"
43 #include "indexable.inc"
44 #include "mwindow.inc"
46 #include "pluginserver.inc"
47 #include "preferences.inc"
48 #include "proxypopup.inc"
49 #include "renderengine.inc"
50 #include "samples.inc"
55 #define SELECT_UNUSED 2
59 #define VIEW_POPUP_BAR_H 15
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
67 #define AVICON_FULL_PLAY 0
68 #define AVICON_MOUSE_OVER 1
69 #define AVICON_SRC_TARGET 2
70 #define AVICON_NO_PLAY 3
71 #define AVICON_PLAY_MODES 4
73 class AWindowFolderItem : public BC_ListBoxItem
77 AWindowFolderItem(const char *text, int color = -1);
78 AWindowFolderItem(const char *text, BC_Pixmap *icon, int color = -1);
80 AssetPicon *get_picon();
81 int matches(const char *text);
83 AWindowFolderItem *parent;
86 class AssetPicon : public AWindowFolderItem
89 AssetPicon(MWindow *mwindow, AWindowGUI *gui, Indexable *indexable);
90 AssetPicon(MWindow *mwindow, AWindowGUI *gui, EDL *edl);
91 AssetPicon(MWindow *mwindow, AWindowGUI *gui, PluginServer *plugin);
92 AssetPicon(MWindow *mwindow, AWindowGUI *gui, Label *plugin);
93 AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, int persist);
94 AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, const char *title);
95 virtual ~AssetPicon();
97 void create_objects();
99 static void draw_hue_bar(VFrame *frame, double t);
100 static void draw_wave(VFrame *frame, double *dp, int len,
101 int base_color, int line_color, int x, int y, int w, int h);
102 static void draw_wave(VFrame *frame, double *dp, int len,
103 int base_color, int line_color, int x=0, int y=0) {
104 draw_wave(frame, dp, len, base_color, line_color,
105 x,y,frame->get_w(),frame->get_h());
107 void open_render_engine(EDL *edl, int is_audio);
108 void close_render_engine();
109 void render_video(int64_t pos, VFrame *vfrm);
110 void render_audio(int64_t pos, Samples **samples, int len);
111 VFrame *get_vicon_frame();
119 // sublist items if set
120 AWindowFolderSubItems *sub_items;
122 // ID of thing pointed to
125 // Check ID first. Update these next before dereferencing
127 Indexable *indexable;
133 time_t comments_time;
135 PluginServer *plugin;
138 RenderEngine *render_engine;
141 typedef int16_t vicon_audio_t;
143 class AssetVIconAudio : public Thread
146 AssetVIconAudio(AWindowGUI *gui);
150 void start(AssetVIcon *vicon);
160 class AssetVIcon : public VIcon, public Garbage {
167 int64_t set_seq_no(int64_t no);
174 AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
178 class AssetViewPopup : public ViewPopup
181 AssetViewPopup(VIconThread *vt, int draw_mode,
182 int x, int y, int w, int h);
185 int button_press_event();
186 int button_release_event();
187 int cursor_motion_event();
188 int keypress_event();
190 void draw_vframe(VFrame *frame);
197 class AssetVIconThread : public VIconThread
200 AssetVIconThread(AWindowGUI *gui, Preferences *preferences);
203 void set_view_popup(AssetVIcon *v, int draw_mode);
204 void set_view_popup(AssetVIcon *v);
205 ViewPopup *new_view_window();
206 void drawing_started();
207 void drawing_stopped();
208 void close_view_popup();
217 class AWindowRemovePlugin;
219 class AWindowRemovePluginGUI : public BC_Window {
222 AWindowRemovePlugin *thread;
223 PluginServer *plugin;
224 ArrayList<BC_ListBoxItem*> plugin_list;
229 void create_objects();
231 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
232 int x, int y, PluginServer *plugin);
233 ~AWindowRemovePluginGUI();
236 class AWindowRemovePlugin : public BC_DialogThread {
239 PluginServer *plugin;
240 BC_Window* new_gui();
241 void handle_close_event(int result);
242 int remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder);
244 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin);
245 ~AWindowRemovePlugin();
248 class AWindowGUI : public BC_Window
251 AWindowGUI(MWindow *mwindow, AWindow *awindow);
254 void create_objects();
255 int resize_event(int w, int h);
256 int translation_event();
258 int keypress_event();
259 void async_update_assets(); // Sends update asset event
260 void update_effects();
263 void reposition_objects();
264 // Call back for MWindow entry point
267 // Collect items into the drag vectors of MainSession
268 void collect_assets(int proxy=0);
269 EDL *collect_proxy(Indexable *indexable);
270 void create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
275 void create_label_folder();
276 void copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src);
277 void sort_picons(ArrayList<BC_ListBoxItem*> *src);
278 // Return the selected asset in asset_list
279 Indexable* selected_asset();
280 PluginServer* selected_plugin();
281 AssetPicon* selected_folder();
282 bool protected_pixmap(BC_Pixmap *pixmap);
283 int save_defaults(BC_Hash *defaults);
284 int load_defaults(BC_Hash *defaults);
285 void start_vicon_drawing();
286 int stop_vicon_drawing();
287 void close_view_popup();
288 void update_picon(Indexable *indexable);
289 int cycle_assetlist_format();
291 VFrame *get_picon(const char *name, const char *plugin_icons);
292 VFrame *get_picon(const char *name);
293 void resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx);
294 void theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn);
295 void plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png);
300 AWindowAssets *asset_list;
301 AWindowFolders *folder_list;
302 AWindowDivider *divider;
303 AWindowSearchText *search_text;
306 // Store data to speed up responses
307 // Persistant data for listboxes
308 // All assets in current EDL
309 ArrayList<BC_ListBoxItem*> assets;
310 ArrayList<BC_ListBoxItem*> folders;
311 ArrayList<BC_ListBoxItem*> aeffects;
312 ArrayList<BC_ListBoxItem*> veffects;
313 ArrayList<BC_ListBoxItem*> atransitions;
314 ArrayList<BC_ListBoxItem*> vtransitions;
315 ArrayList<BC_ListBoxItem*> labellist;
317 // Currently displayed data for listboxes
318 // Currently displayed assets + comments
319 ArrayList<BC_ListBoxItem*> displayed_assets[2];
320 const char *asset_titles[ASSET_COLUMNS];
321 int displayed_folder;
325 BC_Pixmap *aeffect_folder_icon; VFrame *aeffect_folder_vframe;
326 BC_Pixmap *atransition_folder_icon; VFrame *atransition_folder_vframe;
327 BC_Pixmap *clip_folder_icon; VFrame *clip_folder_vframe;
328 BC_Pixmap *label_folder_icon; VFrame *label_folder_vframe;
329 BC_Pixmap *media_folder_icon; VFrame *media_folder_vframe;
330 BC_Pixmap *proxy_folder_icon; VFrame *proxy_folder_vframe;
331 BC_Pixmap *veffect_folder_icon; VFrame *veffect_folder_vframe;
332 BC_Pixmap *vtransition_folder_icon; VFrame *vtransition_folder_vframe;
333 BC_Pixmap *folder_icons[AWINDOW_FOLDERS];
335 BC_Pixmap *folder_icon; VFrame *folder_vframe;
336 BC_Pixmap *file_icon; VFrame *file_vframe;
337 BC_Pixmap *audio_icon; VFrame *audio_vframe;
338 BC_Pixmap *video_icon; VFrame *video_vframe;
339 BC_Pixmap *label_icon; VFrame *label_vframe;
340 BC_Pixmap *clip_icon; VFrame *clip_vframe;
341 BC_Pixmap *atransition_icon; VFrame *atransition_vframe;
342 BC_Pixmap *vtransition_icon; VFrame *vtransition_vframe;
343 BC_Pixmap *aeffect_icon; VFrame *aeffect_vframe;
344 BC_Pixmap *veffect_icon; VFrame *veffect_vframe;
345 BC_Pixmap *ladspa_icon; VFrame *ladspa_vframe;
346 BC_Pixmap *ff_aud_icon; VFrame *ff_aud_vframe;
347 BC_Pixmap *ff_vid_icon; VFrame *ff_vid_vframe;
350 AssetPopup *asset_menu;
351 ClipPopup *clip_menu;
352 LabelPopup *label_menu;
353 ProxyPopup *proxy_menu;
354 EffectListMenu *effectlist_menu;
355 AssetListMenu *assetlist_menu;
356 ClipListMenu *cliplist_menu;
357 LabelListMenu *labellist_menu;
358 ProxyListMenu *proxylist_menu;
359 FolderListMenu *folderlist_menu;
361 // Temporary for reading picons from files
363 AssetVIconThread *vicon_thread;
364 AssetVIconAudio *vicon_audio;
366 int64_t plugin_visibility;
367 AWindowRemovePlugin *remove_plugin;
369 AVIconDrawing *avicon_drawing;
370 int avicon_w, avicon_h;
372 int allow_iconlisting;
374 // Create custom atoms to be used for async messages between windows
375 int create_custom_xatoms();
376 // Function to overload to receive customly defined atoms
377 virtual int receive_custom_xatoms(xatom_event *event);
378 static const char *folder_names[];
379 NewFolderThread *new_folder_thread;
380 ModifyFolderThread *modify_folder_thread;
383 void update_folder_list();
384 void update_asset_list();
385 void filter_displayed_assets();
386 Atom UpdateAssetsXAtom;
387 void update_assets();
391 class AWindowAssets : public BC_ListBox
394 AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
398 int selection_changed();
399 void draw_background();
400 int drag_start_event();
401 int drag_motion_event();
402 int drag_stop_event();
403 int button_press_event();
404 int column_resize_event();
405 int focus_in_event();
406 int focus_out_event();
407 void update_vicon_area();
408 int mouse_over_event(int no);
414 class AWindowDivider : public BC_SubWindow
417 AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
420 int button_press_event();
421 int cursor_motion_event();
422 int button_release_event();
428 class AWindowSubFolderNames : public ArrayList<const char *>
431 AWindowSubFolderNames() { set_array_delete(); }
432 ~AWindowSubFolderNames() { remove_all_objects(); }
435 class AWindowFolderSubItems : public AWindowFolderItem
438 AWindowFolderSubItems(AWindowFolderItem *parent, const char *text);
439 int matches(const char *text);
441 AWindowSubFolderNames names;
444 class AWindowFolders : public BC_ListBox
447 AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
450 int selection_changed();
451 int button_press_event();
453 int load_expanders();
458 AWindowFolderItem *last_item0, *last_item1;
461 class AWindowSearchTextBox : public BC_TextBox
464 AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w);
467 AWindowSearchText *search_text;
470 class AWindowSearchText
473 AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y);
476 void create_objects();
479 void reposition_window(int x, int y, int w);
480 const char *get_text();
486 BC_Title *text_title;
487 BC_TextBox *text_box;
490 class AWindowDeleteDisk : public BC_Button
493 AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y);
500 class AWindowDeleteProject : public BC_Button
503 AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y);
510 class AWindowInfo : public BC_Button
513 AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y);
520 class AWindowRedrawIndex : public BC_Button
523 AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y);
530 class AWindowPaste : public BC_Button
533 AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y);
540 class AWindowAppend : public BC_Button
543 AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y);
550 class AWindowView : public BC_Button
553 AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y);
560 class AddTools : public BC_PopupMenu
563 AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title);
564 void create_objects();
570 class AddPluginItem : public BC_MenuItem
573 AddPluginItem(AddTools *menu, const char *text, int idx);
580 class AVIconDrawingItem : public BC_MenuItem
583 AVIconDrawingItem(AVIconDrawing *avicon, const char *text, int id);
586 AVIconDrawing *avicon;
590 class AVIconDrawing : public BC_PopupMenu
593 AVIconDrawing(AWindowGUI *agui, int x, int y, int w, const char *text);
596 void create_objects();
597 static const char *avicon_names[];
603 class AWindowListFormat : public BC_MenuItem
606 AWindowListFormat(MWindow *mwindow, AWindowGUI *gui);
615 class AWindowListSort : public BC_MenuItem
618 AWindowListSort(MWindow *mwindow, AWindowGUI *gui);
626 class AssetSelectUsedItem : public BC_MenuItem
629 AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action);
633 AssetSelectUsed *select_used;
636 class AssetSelectUsed : public BC_MenuItem
639 AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui);