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
66 class AWindowFolderItem : public BC_ListBoxItem
70 AWindowFolderItem(const char *text, int color = -1);
71 AWindowFolderItem(const char *text, BC_Pixmap *icon, int color = -1);
73 AssetPicon *get_picon();
74 int matches(const char *text);
76 AWindowFolderItem *parent;
79 class AssetPicon : public AWindowFolderItem
82 AssetPicon(MWindow *mwindow, AWindowGUI *gui, Indexable *indexable);
83 AssetPicon(MWindow *mwindow, AWindowGUI *gui, EDL *edl);
84 AssetPicon(MWindow *mwindow, AWindowGUI *gui, PluginServer *plugin);
85 AssetPicon(MWindow *mwindow, AWindowGUI *gui, Label *plugin);
86 AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, int persist);
87 AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, const char *title);
88 virtual ~AssetPicon();
90 void create_objects();
92 static void draw_hue_bar(VFrame *frame, double t);
93 static void draw_wave(VFrame *frame, double *dp, int len,
94 int base_color, int line_color, int x, int y, int w, int h);
95 static void draw_wave(VFrame *frame, double *dp, int len,
96 int base_color, int line_color, int x=0, int y=0) {
97 draw_wave(frame, dp, len, base_color, line_color,
98 x,y,frame->get_w(),frame->get_h());
100 void open_render_engine(EDL *edl, int is_audio);
101 void close_render_engine();
102 void render_video(int64_t pos, VFrame *vfrm);
103 void render_audio(int64_t pos, Samples **samples, int len);
104 VFrame *get_vicon_frame();
112 // sublist items if set
113 AWindowFolderSubItems *sub_items;
115 // ID of thing pointed to
118 // Check ID first. Update these next before dereferencing
120 Indexable *indexable;
126 time_t comments_time;
128 PluginServer *plugin;
131 RenderEngine *render_engine;
134 typedef int16_t vicon_audio_t;
136 class AssetVIconAudio : public Thread
139 AssetVIconAudio(AWindowGUI *gui);
143 void start(AssetVIcon *vicon);
153 class AssetVIcon : public VIcon, public Garbage {
160 int64_t set_seq_no(int64_t no);
167 AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
171 class AssetViewPopup : public ViewPopup
174 AssetViewPopup(VIconThread *vt, int draw_mode,
175 int x, int y, int w, int h);
178 int button_press_event();
179 int button_release_event();
180 int cursor_motion_event();
182 void draw_vframe(VFrame *frame);
189 class AssetVIconThread : public VIconThread
192 AssetVIconThread(AWindowGUI *gui, Preferences *preferences);
195 void set_view_popup(AssetVIcon *v, int draw_mode=-1);
196 ViewPopup *new_view_window();
204 class AWindowRemovePlugin;
206 class AWindowRemovePluginGUI : public BC_Window {
209 AWindowRemovePlugin *thread;
210 PluginServer *plugin;
211 ArrayList<BC_ListBoxItem*> plugin_list;
216 void create_objects();
218 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
219 int x, int y, PluginServer *plugin);
220 ~AWindowRemovePluginGUI();
223 class AWindowRemovePlugin : public BC_DialogThread {
226 PluginServer *plugin;
227 BC_Window* new_gui();
228 void handle_close_event(int result);
229 int remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder);
231 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin);
232 ~AWindowRemovePlugin();
235 class AWindowGUI : public BC_Window
238 AWindowGUI(MWindow *mwindow, AWindow *awindow);
241 void create_objects();
242 int resize_event(int w, int h);
243 int translation_event();
245 int keypress_event();
246 void async_update_assets(); // Sends update asset event
247 void update_effects();
250 void reposition_objects();
251 // Call back for MWindow entry point
254 // Collect items into the drag vectors of MainSession
255 void collect_assets(int proxy=0);
256 EDL *collect_proxy(Indexable *indexable);
257 void create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
262 void create_label_folder();
263 void copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src);
264 void sort_picons(ArrayList<BC_ListBoxItem*> *src);
265 // Return the selected asset in asset_list
266 Indexable* selected_asset();
267 PluginServer* selected_plugin();
268 AssetPicon* selected_folder();
269 bool protected_pixmap(BC_Pixmap *pixmap);
270 int save_defaults(BC_Hash *defaults);
271 int load_defaults(BC_Hash *defaults);
272 void start_vicon_drawing();
273 void stop_vicon_drawing();
274 void update_picon(Indexable *indexable);
275 int cycle_assetlist_format();
277 VFrame *get_picon(const char *name, const char *plugin_icons);
278 VFrame *get_picon(const char *name);
279 void resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx);
280 void theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn);
281 void plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png);
286 AWindowAssets *asset_list;
287 AWindowFolders *folder_list;
288 AWindowDivider *divider;
289 AWindowSearchText *search_text;
292 // Store data to speed up responses
293 // Persistant data for listboxes
294 // All assets in current EDL
295 ArrayList<BC_ListBoxItem*> assets;
296 ArrayList<BC_ListBoxItem*> folders;
297 ArrayList<BC_ListBoxItem*> aeffects;
298 ArrayList<BC_ListBoxItem*> veffects;
299 ArrayList<BC_ListBoxItem*> atransitions;
300 ArrayList<BC_ListBoxItem*> vtransitions;
301 ArrayList<BC_ListBoxItem*> labellist;
303 // Currently displayed data for listboxes
304 // Currently displayed assets + comments
305 ArrayList<BC_ListBoxItem*> displayed_assets[2];
306 const char *asset_titles[ASSET_COLUMNS];
307 int displayed_folder;
311 BC_Pixmap *aeffect_folder_icon; VFrame *aeffect_folder_vframe;
312 BC_Pixmap *atransition_folder_icon; VFrame *atransition_folder_vframe;
313 BC_Pixmap *clip_folder_icon; VFrame *clip_folder_vframe;
314 BC_Pixmap *label_folder_icon; VFrame *label_folder_vframe;
315 BC_Pixmap *media_folder_icon; VFrame *media_folder_vframe;
316 BC_Pixmap *proxy_folder_icon; VFrame *proxy_folder_vframe;
317 BC_Pixmap *veffect_folder_icon; VFrame *veffect_folder_vframe;
318 BC_Pixmap *vtransition_folder_icon; VFrame *vtransition_folder_vframe;
319 BC_Pixmap *folder_icons[AWINDOW_FOLDERS];
321 BC_Pixmap *folder_icon; VFrame *folder_vframe;
322 BC_Pixmap *file_icon; VFrame *file_vframe;
323 BC_Pixmap *audio_icon; VFrame *audio_vframe;
324 BC_Pixmap *video_icon; VFrame *video_vframe;
325 BC_Pixmap *label_icon; VFrame *label_vframe;
326 BC_Pixmap *clip_icon; VFrame *clip_vframe;
327 BC_Pixmap *atransition_icon; VFrame *atransition_vframe;
328 BC_Pixmap *vtransition_icon; VFrame *vtransition_vframe;
329 BC_Pixmap *aeffect_icon; VFrame *aeffect_vframe;
330 BC_Pixmap *veffect_icon; VFrame *veffect_vframe;
331 BC_Pixmap *ladspa_icon; VFrame *ladspa_vframe;
332 BC_Pixmap *ff_aud_icon; VFrame *ff_aud_vframe;
333 BC_Pixmap *ff_vid_icon; VFrame *ff_vid_vframe;
336 AssetPopup *asset_menu;
337 ClipPopup *clip_menu;
338 LabelPopup *label_menu;
339 ProxyPopup *proxy_menu;
340 EffectListMenu *effectlist_menu;
341 AssetListMenu *assetlist_menu;
342 ClipListMenu *cliplist_menu;
343 LabelListMenu *labellist_menu;
344 ProxyListMenu *proxylist_menu;
345 FolderListMenu *folderlist_menu;
347 // Temporary for reading picons from files
349 AssetVIconThread *vicon_thread;
350 AssetVIconAudio *vicon_audio;
352 int64_t plugin_visibility;
353 AWindowRemovePlugin *remove_plugin;
355 AVIconDrawing *avicon_drawing;
356 int avicon_w, avicon_h;
358 int allow_iconlisting;
360 // Create custom atoms to be used for async messages between windows
361 int create_custom_xatoms();
362 // Function to overload to receive customly defined atoms
363 virtual int receive_custom_xatoms(xatom_event *event);
364 static const char *folder_names[];
365 NewFolderThread *new_folder_thread;
366 ModifyFolderThread *modify_folder_thread;
369 void update_folder_list();
370 void update_asset_list();
371 void filter_displayed_assets();
372 Atom UpdateAssetsXAtom;
373 void update_assets();
377 class AWindowAssets : public BC_ListBox
380 AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
384 int selection_changed();
385 void draw_background();
386 int drag_start_event();
387 int drag_motion_event();
388 int drag_stop_event();
389 int button_press_event();
390 int column_resize_event();
391 int focus_in_event();
392 int focus_out_event();
393 void update_vicon_area();
394 int mouse_over_event(int no);
400 class AWindowDivider : public BC_SubWindow
403 AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
406 int button_press_event();
407 int cursor_motion_event();
408 int button_release_event();
414 class AWindowSubFolderNames : public ArrayList<const char *>
417 AWindowSubFolderNames() { set_array_delete(); }
418 ~AWindowSubFolderNames() { remove_all_objects(); }
421 class AWindowFolderSubItems : public AWindowFolderItem
424 AWindowFolderSubItems(AWindowFolderItem *parent, const char *text);
425 int matches(const char *text);
427 AWindowSubFolderNames names;
430 class AWindowFolders : public BC_ListBox
433 AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
436 int selection_changed();
437 int button_press_event();
439 int load_expanders();
444 AWindowFolderItem *last_item0, *last_item1;
447 class AWindowSearchTextBox : public BC_TextBox
450 AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w);
453 AWindowSearchText *search_text;
456 class AWindowSearchText
459 AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y);
462 void create_objects();
465 void reposition_window(int x, int y, int w);
466 const char *get_text();
472 BC_Title *text_title;
473 BC_TextBox *text_box;
476 class AWindowDeleteDisk : public BC_Button
479 AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y);
486 class AWindowDeleteProject : public BC_Button
489 AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y);
496 class AWindowInfo : public BC_Button
499 AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y);
506 class AWindowRedrawIndex : public BC_Button
509 AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y);
516 class AWindowPaste : public BC_Button
519 AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y);
526 class AWindowAppend : public BC_Button
529 AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y);
536 class AWindowView : public BC_Button
539 AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y);
546 class AddTools : public BC_PopupMenu
549 AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title);
550 void create_objects();
556 class AddPluginItem : public BC_MenuItem
559 AddPluginItem(AddTools *menu, const char *text, int idx);
566 class AVIconDrawing : public BC_Toggle
572 static void calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh);
574 AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images);
579 class AWindowListFormat : public BC_MenuItem
582 AWindowListFormat(MWindow *mwindow, AWindowGUI *gui);
591 class AWindowListSort : public BC_MenuItem
594 AWindowListSort(MWindow *mwindow, AWindowGUI *gui);
602 class AssetSelectUsedItem : public BC_MenuItem
605 AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action);
609 AssetSelectUsed *select_used;
612 class AssetSelectUsed : public BC_MenuItem
615 AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui);