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"
39 #include "labeledit.inc"
40 #include "labelpopup.inc"
42 #include "indexable.inc"
43 #include "mwindow.inc"
45 #include "pluginserver.inc"
46 #include "proxypopup.inc"
47 #include "renderengine.inc"
48 #include "samples.inc"
51 class AWindowFolderItem : public BC_ListBoxItem
55 AWindowFolderItem(const char *text, int color = -1);
56 AWindowFolderItem(const char *text, BC_Pixmap *icon, int color = -1);
58 AssetPicon *get_picon();
59 int matches(const char *text);
61 AWindowFolderItem *parent;
64 class AssetPicon : public AWindowFolderItem
67 AssetPicon(MWindow *mwindow, AWindowGUI *gui, Indexable *indexable);
68 AssetPicon(MWindow *mwindow, AWindowGUI *gui, EDL *edl);
69 AssetPicon(MWindow *mwindow, AWindowGUI *gui, PluginServer *plugin);
70 AssetPicon(MWindow *mwindow, AWindowGUI *gui, Label *plugin);
71 AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, int persist);
72 AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder, const char *title);
73 virtual ~AssetPicon();
75 void create_objects();
77 static void draw_hue_bar(VFrame *frame, double t);
78 static void draw_wave(VFrame *frame, double *dp, int len,
79 int base_color, int line_color);
80 void open_render_engine(EDL *edl, int is_audio);
81 void close_render_engine();
82 void render_video(int64_t pos, VFrame *vfrm);
83 void render_audio(int64_t pos, Samples **samples, int len);
84 VFrame *get_vicon_frame();
92 // sublist items if set
93 AWindowFolderSubItems *sub_items;
95 // ID of thing pointed to
98 // Check ID first. Update these next before dereferencing
100 Indexable *indexable;
106 time_t comments_time;
108 PluginServer *plugin;
111 RenderEngine *render_engine;
114 typedef int16_t vicon_audio_t;
116 class AssetVIconAudio : public Thread
119 AssetVIconAudio(AWindowGUI *gui);
123 void start(AssetVIcon *vicon);
133 class AssetVIcon : public VIcon {
140 int64_t set_seq_no(int64_t no);
147 AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
151 class AWindowRemovePlugin;
153 class AWindowRemovePluginGUI : public BC_Window {
156 AWindowRemovePlugin *thread;
157 PluginServer *plugin;
158 ArrayList<BC_ListBoxItem*> plugin_list;
163 void create_objects();
165 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
166 int x, int y, PluginServer *plugin);
167 ~AWindowRemovePluginGUI();
170 class AWindowRemovePlugin : public BC_DialogThread {
173 PluginServer *plugin;
174 BC_Window* new_gui();
175 void handle_close_event(int result);
176 int remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder);
178 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin);
179 ~AWindowRemovePlugin();
182 class AWindowGUI : public BC_Window
185 AWindowGUI(MWindow *mwindow, AWindow *awindow);
188 void create_objects();
189 int resize_event(int w, int h);
190 int translation_event();
192 int keypress_event();
193 void async_update_assets(); // Sends update asset event
194 void update_effects();
197 void reposition_objects();
198 // Call back for MWindow entry point
201 // Collect items into the drag vectors of MainSession
202 void collect_assets(int proxy=0);
203 EDL *collect_proxy(Indexable *indexable);
204 void create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
209 void create_label_folder();
210 void copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src);
211 void sort_picons(ArrayList<BC_ListBoxItem*> *src);
212 // Return the selected asset in asset_list
213 Indexable* selected_asset();
214 PluginServer* selected_plugin();
215 AssetPicon* selected_folder();
216 bool protected_pixmap(BC_Pixmap *pixmap);
217 int save_defaults(BC_Hash *defaults);
218 int load_defaults(BC_Hash *defaults);
219 void start_vicon_drawing();
220 void stop_vicon_drawing();
221 void update_picon(Indexable *indexable);
222 int cycle_assetlist_format();
224 VFrame *get_picon(const char *name, const char *plugin_icons);
225 VFrame *get_picon(const char *name);
226 void resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx);
227 void theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn);
228 void plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png);
233 AWindowAssets *asset_list;
234 AWindowFolders *folder_list;
235 AWindowDivider *divider;
236 AWindowSearchText *search_text;
239 // Store data to speed up responses
240 // Persistant data for listboxes
241 // All assets in current EDL
242 ArrayList<BC_ListBoxItem*> assets;
243 ArrayList<BC_ListBoxItem*> folders;
244 ArrayList<BC_ListBoxItem*> aeffects;
245 ArrayList<BC_ListBoxItem*> veffects;
246 ArrayList<BC_ListBoxItem*> atransitions;
247 ArrayList<BC_ListBoxItem*> vtransitions;
248 ArrayList<BC_ListBoxItem*> labellist;
250 // Currently displayed data for listboxes
251 // Currently displayed assets + comments
252 ArrayList<BC_ListBoxItem*> displayed_assets[2];
253 const char *asset_titles[ASSET_COLUMNS];
254 int displayed_folder;
258 BC_Pixmap *aeffect_folder_icon; VFrame *aeffect_folder_vframe;
259 BC_Pixmap *atransition_folder_icon; VFrame *atransition_folder_vframe;
260 BC_Pixmap *clip_folder_icon; VFrame *clip_folder_vframe;
261 BC_Pixmap *label_folder_icon; VFrame *label_folder_vframe;
262 BC_Pixmap *media_folder_icon; VFrame *media_folder_vframe;
263 BC_Pixmap *proxy_folder_icon; VFrame *proxy_folder_vframe;
264 BC_Pixmap *veffect_folder_icon; VFrame *veffect_folder_vframe;
265 BC_Pixmap *vtransition_folder_icon; VFrame *vtransition_folder_vframe;
266 BC_Pixmap *folder_icons[AWINDOW_FOLDERS];
268 BC_Pixmap *folder_icon; VFrame *folder_vframe;
269 BC_Pixmap *file_icon; VFrame *file_vframe;
270 BC_Pixmap *audio_icon; VFrame *audio_vframe;
271 BC_Pixmap *video_icon; VFrame *video_vframe;
272 BC_Pixmap *label_icon; VFrame *label_vframe;
273 BC_Pixmap *clip_icon; VFrame *clip_vframe;
274 BC_Pixmap *atransition_icon; VFrame *atransition_vframe;
275 BC_Pixmap *vtransition_icon; VFrame *vtransition_vframe;
276 BC_Pixmap *aeffect_icon; VFrame *aeffect_vframe;
277 BC_Pixmap *veffect_icon; VFrame *veffect_vframe;
278 BC_Pixmap *ladspa_icon; VFrame *ladspa_vframe;
279 BC_Pixmap *ff_aud_icon; VFrame *ff_aud_vframe;
280 BC_Pixmap *ff_vid_icon; VFrame *ff_vid_vframe;
283 AssetPopup *asset_menu;
284 ClipPopup *clip_menu;
285 LabelPopup *label_menu;
286 ProxyPopup *proxy_menu;
287 EffectListMenu *effectlist_menu;
288 AssetListMenu *assetlist_menu;
289 ClipListMenu *cliplist_menu;
290 LabelListMenu *labellist_menu;
291 ProxyListMenu *proxylist_menu;
292 FolderListMenu *folderlist_menu;
294 // Temporary for reading picons from files
296 VIconThread *vicon_thread;
297 AssetVIconAudio *vicon_audio;
299 int64_t plugin_visibility;
300 AWindowRemovePlugin *remove_plugin;
302 AVIconDrawing *avicon_drawing;
303 int avicon_w, avicon_h, vicon_drawing;
304 int allow_iconlisting;
306 // Create custom atoms to be used for async messages between windows
307 int create_custom_xatoms();
308 // Function to overload to receive customly defined atoms
309 virtual int receive_custom_xatoms(xatom_event *event);
310 static const char *folder_names[];
311 NewFolderThread *new_folder_thread;
312 ModifyFolderThread *modify_folder_thread;
315 void update_folder_list();
316 void update_asset_list();
317 void filter_displayed_assets();
318 Atom UpdateAssetsXAtom;
319 void update_assets();
323 class AWindowAssets : public BC_ListBox
326 AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
330 int selection_changed();
331 void draw_background();
332 int drag_start_event();
333 int drag_motion_event();
334 int drag_stop_event();
335 int button_press_event();
336 int column_resize_event();
337 int focus_in_event();
338 int focus_out_event();
339 int cursor_enter_event();
340 int cursor_leave_event();
341 void update_vicon_area();
342 int mouse_over_event(int no);
348 class AWindowDivider : public BC_SubWindow
351 AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
354 int button_press_event();
355 int cursor_motion_event();
356 int button_release_event();
362 class AWindowSubFolderNames : public ArrayList<const char *>
365 AWindowSubFolderNames() { set_array_delete(); }
366 ~AWindowSubFolderNames() { remove_all_objects(); }
369 class AWindowFolderSubItems : public AWindowFolderItem
372 AWindowFolderSubItems(AWindowFolderItem *parent, const char *text);
373 int matches(const char *text);
375 AWindowSubFolderNames names;
378 class AWindowFolders : public BC_ListBox
381 AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h);
384 int selection_changed();
385 int button_press_event();
387 int load_expanders();
392 AWindowFolderItem *last_item0, *last_item1;
395 class AWindowSearchTextBox : public BC_TextBox
398 AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w);
401 AWindowSearchText *search_text;
404 class AWindowSearchText
407 AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y);
410 void create_objects();
413 void reposition_window(int x, int y, int w);
414 const char *get_text();
420 BC_Title *text_title;
421 BC_TextBox *text_box;
424 class AWindowDeleteDisk : public BC_Button
427 AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y);
434 class AWindowDeleteProject : public BC_Button
437 AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y);
444 class AWindowInfo : public BC_Button
447 AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y);
454 class AWindowRedrawIndex : public BC_Button
457 AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y);
464 class AWindowPaste : public BC_Button
467 AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y);
474 class AWindowAppend : public BC_Button
477 AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y);
484 class AWindowView : public BC_Button
487 AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y);
494 class AddTools : public BC_PopupMenu
497 AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title);
498 void create_objects();
504 class AddPluginItem : public BC_MenuItem
507 AddPluginItem(AddTools *menu, const char *text, int idx);
514 class AVIconDrawing : public BC_Toggle
520 static void calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh);
522 AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images);
527 class AWindowListFormat : public BC_MenuItem
530 AWindowListFormat(MWindow *mwindow, AWindowGUI *gui);
539 class AWindowListSort : public BC_MenuItem
542 AWindowListSort(MWindow *mwindow, AWindowGUI *gui);