merged hv7 mod
[goodguy/history.git] / cinelerra-5.1 / cinelerra / awindowgui.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2012 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 #include "asset.h"
23 #include "assetedit.h"
24 #include "assetpopup.h"
25 #include "assets.h"
26 #include "awindowgui.h"
27 #include "awindow.h"
28 #include "bcsignals.h"
29 #include "bchash.h"
30 #include "cache.h"
31 #include "bccmodels.h"
32 #include "clippopup.h"
33 #include "cursors.h"
34 #include "cwindowgui.h"
35 #include "cwindow.h"
36 #include "edl.h"
37 #include "edlsession.h"
38 #include "effectlist.h"
39 #include "file.h"
40 #include "filesystem.h"
41 #include "folderlistmenu.h"
42 #include "indexable.h"
43 #include "keys.h"
44 #include "language.h"
45 #include "labels.h"
46 #include "labelpopup.h"
47 #include "localsession.h"
48 #include "mainmenu.h"
49 #include "mainsession.h"
50 #include "mwindowgui.h"
51 #include "mwindow.h"
52 #include "nestededls.h"
53 #include "newfolder.h"
54 #include "preferences.h"
55 #include "theme.h"
56 #include "vframe.h"
57 #include "vicon.h"
58 #include "vwindowgui.h"
59 #include "vwindow.h"
60
61 #include "data/lad_picon_png.h"
62 #include "data/ff_audio_png.h"
63 #include "data/ff_video_png.h"
64
65 #include<stdio.h>
66 #include<unistd.h>
67 #include<fcntl.h>
68
69
70 const char *AWindowGUI::folder_names[] =
71 {
72         N_("Audio Effects"),
73         N_("Video Effects"),
74         N_("Audio Transitions"),
75         N_("Video Transitions"),
76         N_("Labels"),
77         N_("Clips"),
78         N_("Media"),
79         N_("Proxy"),
80 };
81
82
83 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
84  : VIcon(w, h, framerate)
85 {
86         this->picon = picon;
87         this->length = length;
88         temp = 0;
89 }
90
91 AssetVIcon::~AssetVIcon()
92 {
93         delete temp;
94 }
95
96 VFrame *AssetVIcon::frame()
97 {
98         if( seq_no >= images.size() ) {
99                 MWindow *mwindow = picon->mwindow;
100                 Asset *asset = (Asset *)picon->indexable;
101                 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
102                 if( !file ) return 0;
103                 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
104                         delete temp;  temp = 0;
105                 }
106                 if( !temp )
107                         temp = new VFrame(asset->width, asset->height, BC_RGB888);
108                 int ww = picon->gui->vicon_thread->view_w;
109                 int hh = picon->gui->vicon_thread->view_h;
110                 while( seq_no >= images.size() ) {
111                         file->set_layer(0);
112                         int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
113                         file->set_video_position(pos,0);
114                         file->read_frame(temp);
115                         add_image(temp, ww, hh, BC_RGB8);
116                 }
117                 mwindow->video_cache->check_in(asset);
118         }
119         return *images[seq_no];
120 }
121
122 int64_t AssetVIcon::set_seq_no(int64_t no)
123 {
124         if( no >= length ) no = 0;
125         return seq_no = no;
126 }
127
128 int AssetVIcon::get_vx()
129 {
130         BC_ListBox *lbox = picon->gui->asset_list;
131         return lbox->get_item_x(picon);
132 }
133 int AssetVIcon::get_vy()
134 {
135         BC_ListBox *lbox = picon->gui->asset_list;
136         return lbox->get_item_y(picon) + lbox->get_title_h();
137 }
138
139
140 AssetPicon::AssetPicon(MWindow *mwindow,
141         AWindowGUI *gui, Indexable *indexable)
142  : BC_ListBoxItem()
143 {
144         reset();
145         this->mwindow = mwindow;
146         this->gui = gui;
147         this->indexable = indexable;
148         indexable->add_user();
149         this->id = indexable->id;
150 }
151
152 AssetPicon::AssetPicon(MWindow *mwindow,
153         AWindowGUI *gui, EDL *edl)
154  : BC_ListBoxItem()
155 {
156         reset();
157         this->mwindow = mwindow;
158         this->gui = gui;
159         this->edl = edl;
160         edl->add_user();
161         this->id = edl->id;
162 }
163
164 AssetPicon::AssetPicon(MWindow *mwindow,
165         AWindowGUI *gui, int folder, int persist)
166  : BC_ListBoxItem(_(AWindowGUI::folder_names[folder]),
167         folder>=0 && folder<AWINDOW_FOLDERS ?
168                 gui->folder_icons[folder]: gui->folder_icon)
169 {
170         reset();
171         foldernum = folder;
172         this->mwindow = mwindow;
173         this->gui = gui;
174         persistent = persist;
175 }
176
177 AssetPicon::AssetPicon(MWindow *mwindow,
178         AWindowGUI *gui, PluginServer *plugin)
179  : BC_ListBoxItem()
180 {
181         reset();
182         this->mwindow = mwindow;
183         this->gui = gui;
184         this->plugin = plugin;
185 }
186
187 AssetPicon::AssetPicon(MWindow *mwindow,
188         AWindowGUI *gui, Label *label)
189  : BC_ListBoxItem()
190 {
191         reset();
192         this->mwindow = mwindow;
193         this->gui = gui;
194         this->label = label;
195         indexable = 0;
196         icon = 0;
197         id = 0;
198 }
199
200 AssetPicon::~AssetPicon()
201 {
202         if( vicon )
203                 gui->vicon_thread->del_vicon(vicon);
204         if( indexable ) indexable->remove_user();
205         if( edl ) edl->remove_user();
206         if( icon && !gui->protected_pixmap(icon) ) {
207                 delete icon;
208                 if( !plugin ) delete icon_vframe;
209         }
210 }
211
212 void AssetPicon::reset()
213 {
214         plugin = 0;
215         label = 0;
216         indexable = 0;
217         edl = 0;
218         foldernum = AW_NO_FOLDER;
219         icon = 0;
220         icon_vframe = 0;
221         vicon = 0;
222         in_use = 1;
223         id = 0;
224         persistent = 0;
225 }
226
227 void AssetPicon::create_objects()
228 {
229         FileSystem fs;
230         char name[BCTEXTLEN];
231         int pixmap_w, pixmap_h;
232
233         pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
234
235         if( indexable ) {
236                 fs.extract_name(name, indexable->path);
237                 set_text(name);
238         }
239
240         if( indexable && indexable->is_asset ) {
241                 Asset *asset = (Asset*)indexable;
242                 if( asset->video_data ) {
243                         if( mwindow->preferences->use_thumbnails ) {
244                                 gui->unlock_window();
245                                 File *file = mwindow->video_cache->check_out(asset,
246                                         mwindow->edl,
247                                         1);
248
249                                 if( file ) {
250                                         int height = asset->height > 0 ? asset->height : 1;
251                                         pixmap_w = pixmap_h * asset->width / height;
252
253                                         file->set_layer(0);
254                                         file->set_video_position(0, 0);
255
256                                         if( gui->temp_picon &&
257                                                 (gui->temp_picon->get_w() != asset->width ||
258                                                 gui->temp_picon->get_h() != asset->height) ) {
259                                                 delete gui->temp_picon;
260                                                 gui->temp_picon = 0;
261                                         }
262
263                                         if( !gui->temp_picon ) {
264                                                 gui->temp_picon = new VFrame(0, -1,
265                                                         asset->width, asset->height,
266                                                         BC_RGB888, -1);
267                                         }
268                                         { char string[BCTEXTLEN];
269                                         sprintf(string, _("Reading %s"), name);
270                                         mwindow->gui->lock_window("AssetPicon::create_objects");
271                                         mwindow->gui->show_message(string);
272                                         mwindow->gui->unlock_window(); }
273                                         file->read_frame(gui->temp_picon);
274                                         mwindow->video_cache->check_in(asset);
275
276                                         gui->lock_window("AssetPicon::create_objects 1");
277                                         icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
278                                         icon->draw_vframe(gui->temp_picon,
279                                                 0, 0, pixmap_w, pixmap_h, 0, 0);
280                                         icon_vframe = new VFrame(0,
281                                                 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
282                                         icon_vframe->transfer_from(gui->temp_picon);
283                                         if( asset->awindow_folder == AW_MEDIA_FOLDER ) {
284 // vicon images
285                                                 double framerate = asset->get_frame_rate();
286                                                 if( !framerate ) framerate = VICON_RATE;
287                                                 int64_t frames = asset->get_video_frames();
288                                                 double secs = frames / framerate;
289                                                 if( secs > 5 ) secs = 5;
290                                                 int64_t length = secs * gui->vicon_thread->refresh_rate;
291                                                 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
292                                                 gui->vicon_thread->add_vicon(vicon);
293                                         }
294
295                                 }
296                                 else {
297                                         gui->lock_window("AssetPicon::create_objects 2");
298                                         icon = gui->video_icon;
299                                         icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
300                                 }
301                         }
302                         else {
303                                 icon = gui->video_icon;
304                                 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
305                         }
306                 }
307                 else
308                 if( asset->audio_data ) {
309                         icon = gui->audio_icon;
310                         icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND];
311                 }
312
313         }
314         else
315         if( indexable && !indexable->is_asset ) {
316                 icon = gui->video_icon;
317                 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
318         }
319         else
320         if( edl ) {
321                 set_text(strcpy(name, edl->local_session->clip_title));
322                 icon = gui->clip_icon;
323                 icon_vframe = mwindow->theme->get_image("clip_icon");
324         }
325         else
326         if( plugin ) {
327                 strcpy(name,  plugin->title);
328                 set_text(name);
329                 icon_vframe = plugin->get_picon();
330                 if( icon_vframe )
331                         icon = gui->create_pixmap(icon_vframe);
332                 else if( plugin->audio ) {
333                         if( plugin->transition ) {
334                                 icon = gui->atransition_icon;
335                                 icon_vframe = gui->atransition_vframe;
336                         }
337                         else if( plugin->is_ffmpeg() ) {
338                                 icon = gui->ff_aud_icon;
339                                 icon_vframe = gui->ff_aud_vframe;
340                         }
341                         else if( plugin->is_ladspa() ) {
342                                 icon = gui->ladspa_icon;
343                                 icon_vframe = gui->ladspa_vframe;
344                         }
345                         else {
346                                 icon = gui->aeffect_icon;
347                                 icon_vframe = gui->aeffect_vframe;
348                         }
349                 }
350                 else if( plugin->video ) {
351                         if( plugin->transition ) {
352                                 icon = gui->vtransition_icon;
353                                 icon_vframe = gui->vtransition_vframe;
354                         }
355                         else if( plugin->is_ffmpeg() ) {
356                                 icon = gui->ff_vid_icon;
357                                 icon_vframe = gui->ff_vid_vframe;
358                         }
359                         else {
360                                 icon = gui->veffect_icon;
361                                 icon_vframe = gui->veffect_vframe;
362                         }
363                 }
364         }
365         else
366         if( label ) {
367                 Units::totext(name,
368                               label->position,
369                               mwindow->edl->session->time_format,
370                               mwindow->edl->session->sample_rate,
371                               mwindow->edl->session->frame_rate,
372                               mwindow->edl->session->frames_per_foot);
373                 set_text(name);
374                 icon = gui->label_icon;
375                 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_LABEL];
376                 set_icon(icon);
377                 set_icon_vframe(icon_vframe);
378         }
379         if( !icon ) {
380                 icon = gui->file_icon;
381                 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
382         }
383         set_icon(icon);
384         set_icon_vframe(icon_vframe);
385 }
386
387 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
388  : BC_Window(_(PROGRAM_NAME ": Resources"),
389         mwindow->session->awindow_x, mwindow->session->awindow_y,
390         mwindow->session->awindow_w, mwindow->session->awindow_h,
391         100, 100, 1, 1, 1)
392 {
393         this->mwindow = mwindow;
394         this->awindow = awindow;
395         file_icon = 0;
396         audio_icon = 0;
397         video_icon = 0;
398         folder_icon = 0;
399         clip_icon = 0;
400         label_icon = 0;
401         atransition_icon = 0;  atransition_vframe = 0;
402         vtransition_icon = 0;  vtransition_vframe = 0;
403         aeffect_icon = 0;      aeffect_vframe = 0;
404         ladspa_icon = 0;       ladspa_vframe = 0;
405         veffect_icon = 0;      veffect_vframe = 0;
406         ff_aud_icon = 0;       ff_aud_vframe = 0;
407         ff_vid_icon = 0;       ff_vid_vframe = 0;
408         plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
409         newfolder_thread = 0;
410         asset_menu = 0;
411         effectlist_menu = 0;
412         assetlist_menu = 0;
413         cliplist_menu = 0;
414         labellist_menu = 0;
415         folderlist_menu = 0;
416         temp_picon = 0;
417         allow_iconlisting = 1;
418         remove_plugin = 0;
419         vicon_thread = 0;
420         vicon_drawing = 1;
421         displayed_folder = AW_NO_FOLDER;
422 }
423
424 AWindowGUI::~AWindowGUI()
425 {
426         assets.remove_all_objects();
427         folders.remove_all_objects();
428         aeffects.remove_all_objects();
429         veffects.remove_all_objects();
430         atransitions.remove_all_objects();
431         vtransitions.remove_all_objects();
432         labellist.remove_all_objects();
433         displayed_assets[1].remove_all_objects();
434
435         delete vicon_thread;
436         delete file_icon;
437         delete audio_icon;
438         delete video_icon;
439         delete folder_icon;
440         delete clip_icon;
441         delete label_icon;
442         delete atransition_icon;
443         delete vtransition_icon;
444         delete aeffect_icon;
445         delete veffect_icon;
446         delete ladspa_icon;
447         delete ff_aud_icon;
448         delete ff_vid_icon;
449         delete newfolder_thread;
450         delete asset_menu;
451         delete clip_menu;
452         delete label_menu;
453         delete effectlist_menu;
454         delete assetlist_menu;
455         delete cliplist_menu;
456         delete labellist_menu;
457         delete folderlist_menu;
458         delete temp_picon;
459         delete remove_plugin;
460 }
461
462 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
463 {
464         return  icon == file_icon ||
465                 icon == folder_icon ||
466                 icon == audio_icon ||
467                 icon == video_icon ||
468                 icon == clip_icon ||
469                 icon == label_icon ||
470                 icon == vtransition_icon ||
471                 icon == atransition_icon ||
472                 icon == veffect_icon ||
473                 icon == aeffect_icon ||
474                 icon == ladspa_icon ||
475                 icon == ff_aud_icon ||
476                 icon == ff_vid_icon ||
477                 icon == aeffect_folder_icon ||
478                 icon == veffect_folder_icon ||
479                 icon == atransition_folder_icon ||
480                 icon == vtransition_folder_icon ||
481                 icon == label_folder_icon ||
482                 icon == clip_folder_icon ||
483                 icon == media_folder_icon ||
484                 icon == proxy_folder_icon;
485 }
486
487 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
488 {
489         char png_path[BCTEXTLEN];
490         char *pp = png_path, *ep = pp + sizeof(png_path)-1;
491         snprintf(pp, ep-pp, "%s/picon_%s/%s.png",
492                 File::get_plugin_path(), plugin_icons, name);
493         return VFramePng::vframe_png(png_path,0,0);
494 }
495
496 VFrame *AWindowGUI::get_picon(const char *name)
497 {
498         VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
499         if( !vframe ) vframe = get_picon(name, DEFAULT_PICON);
500         return vframe;
501 }
502
503 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
504 {
505         vfrm = get_picon(fn);
506         if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
507         icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
508 }
509 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
510 {
511         vfrm = get_picon(fn);
512         if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
513         icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
514 }
515 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
516 {
517         vfrm = get_picon(fn);
518         if( !vfrm ) vfrm = new VFramePng(png);
519         icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
520 }
521
522 void AWindowGUI::create_objects()
523 {
524         lock_window("AWindowGUI::create_objects");
525         asset_titles[0] = _("Title");
526         asset_titles[1] = _("Comments");
527
528         set_icon(mwindow->theme->get_image("awindow_icon"));
529
530         resource_icon(file_vframe,   file_icon,   "film_icon",   ICON_UNKNOWN);
531         resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
532         resource_icon(audio_vframe,  audio_icon,  "audio_icon",  ICON_SOUND);
533         resource_icon(video_vframe,  video_icon,  "video_icon",  ICON_FILM);
534         resource_icon(label_vframe,  label_icon,  "label_icon",  ICON_LABEL);
535
536         theme_icon(aeffect_folder_vframe,      aeffect_folder_icon,     "aeffect_folder");
537         theme_icon(atransition_folder_vframe,  atransition_folder_icon, "atransition_folder");
538         theme_icon(clip_folder_vframe,         clip_folder_icon,        "clip_folder");
539         theme_icon(label_folder_vframe,        label_folder_icon,       "label_folder");
540         theme_icon(media_folder_vframe,        media_folder_icon,       "media_folder");
541         theme_icon(proxy_folder_vframe,        proxy_folder_icon,       "proxy_folder");
542         theme_icon(veffect_folder_vframe,      veffect_folder_icon,     "veffect_folder");
543         theme_icon(vtransition_folder_vframe,  vtransition_folder_icon, "vtransition_folder");
544
545         folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
546         folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
547         folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
548         folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
549         folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
550         folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
551         folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
552         folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
553
554         theme_icon(clip_vframe,        clip_icon,        "clip_icon");
555         theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
556         theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
557         theme_icon(aeffect_vframe,     aeffect_icon,     "aeffect_icon");
558         theme_icon(veffect_vframe,     veffect_icon,     "veffect_icon");
559
560         plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
561         plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio",  ff_audio_png);
562         plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video",  ff_video_png);
563
564 // Mandatory folders
565         folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
566         folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
567         folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
568         folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
569         folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
570         folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
571         folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
572         folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
573
574         create_label_folder();
575
576         mwindow->theme->get_awindow_sizes(this);
577         load_defaults(mwindow->defaults);
578
579         add_subwindow(asset_list = new AWindowAssets(mwindow,
580                 this,
581                 mwindow->theme->alist_x,
582                 mwindow->theme->alist_y,
583                 mwindow->theme->alist_w,
584                 mwindow->theme->alist_h));
585
586         vicon_thread = new VIconThread(asset_list);
587         vicon_thread->start();
588
589         add_subwindow(divider = new AWindowDivider(mwindow,
590                 this,
591                 mwindow->theme->adivider_x,
592                 mwindow->theme->adivider_y,
593                 mwindow->theme->adivider_w,
594                 mwindow->theme->adivider_h));
595
596         divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
597
598         int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
599         int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
600         VFrame **images = mwindow->theme->get_image_set("playpatch_data");
601         AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
602         add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
603         add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
604         add_tools->create_objects();
605         fy += add_tools->get_h();  fh -= add_tools->get_h();
606         add_subwindow(folder_list = new AWindowFolders(mwindow,
607                 this, fx, fy, fw, fh));
608         update_effects();
609
610         //int x = mwindow->theme->abuttons_x;
611         //int y = mwindow->theme->abuttons_y;
612
613
614         newfolder_thread = new NewFolderThread(mwindow, this);
615
616         add_subwindow(asset_menu = new AssetPopup(mwindow, this));
617         asset_menu->create_objects();
618         add_subwindow(clip_menu = new ClipPopup(mwindow, this));
619         clip_menu->create_objects();
620         add_subwindow(label_menu = new LabelPopup(mwindow, this));
621         label_menu->create_objects();
622
623         add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
624         effectlist_menu->create_objects();
625         add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
626         assetlist_menu->create_objects();
627         add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
628         cliplist_menu->create_objects();
629         add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
630         labellist_menu->create_objects();
631
632         add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
633         folderlist_menu->create_objects();
634
635         create_custom_xatoms();
636         unlock_window();
637 }
638
639 int AWindowGUI::resize_event(int w, int h)
640 {
641         mwindow->session->awindow_x = get_x();
642         mwindow->session->awindow_y = get_y();
643         mwindow->session->awindow_w = w;
644         mwindow->session->awindow_h = h;
645
646         mwindow->theme->get_awindow_sizes(this);
647         mwindow->theme->draw_awindow_bg(this);
648         reposition_objects();
649
650 //      int x = mwindow->theme->abuttons_x;
651 //      int y = mwindow->theme->abuttons_y;
652 //      new_bin->reposition_window(x, y);
653 //      x += new_bin->get_w();
654 //      delete_bin->reposition_window(x, y);
655 //      x += delete_bin->get_w();
656 //      rename_bin->reposition_window(x, y);
657 //      x += rename_bin->get_w();
658 //      delete_disk->reposition_window(x, y);
659 //      x += delete_disk->get_w();
660 //      delete_project->reposition_window(x, y);
661 //      x += delete_project->get_w();
662 //      info->reposition_window(x, y);
663 //      x += info->get_w();
664 //      redraw_index->reposition_window(x, y);
665 //      x += redraw_index->get_w();
666 //      paste->reposition_window(x, y);
667 //      x += paste->get_w();
668 //      append->reposition_window(x, y);
669 //      x += append->get_w();
670 //      view->reposition_window(x, y);
671
672         BC_WindowBase::resize_event(w, h);
673         return 1;
674 }
675
676 int AWindowGUI::translation_event()
677 {
678         mwindow->session->awindow_x = get_x();
679         mwindow->session->awindow_y = get_y();
680         return 0;
681 }
682
683 void AWindowGUI::reposition_objects()
684 {
685         asset_list->reposition_window(
686                 mwindow->theme->alist_x, mwindow->theme->alist_y,
687                 mwindow->theme->alist_w, mwindow->theme->alist_h);
688         divider->reposition_window(
689                 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
690                 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
691         int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
692         int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
693         add_tools->resize_event(fw-avicon_w, add_tools->get_h());
694         avicon_drawing->reposition_window(fw-avicon_w, fy);
695         fy += add_tools->get_h();  fh -= add_tools->get_h();
696         folder_list->reposition_window(fx, fy, fw, fh);
697 }
698
699 int AWindowGUI::save_defaults(BC_Hash *defaults)
700 {
701         defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
702         defaults->update("VICON_DRAWING", vicon_drawing);
703         return 0;
704 }
705
706 int AWindowGUI::load_defaults(BC_Hash *defaults)
707 {
708         plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
709         vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
710         return 0;
711 }
712
713 int AWindowGUI::close_event()
714 {
715         hide_window();
716         mwindow->session->show_awindow = 0;
717         unlock_window();
718
719         mwindow->gui->lock_window("AWindowGUI::close_event");
720         mwindow->gui->mainmenu->show_awindow->set_checked(0);
721         mwindow->gui->unlock_window();
722
723         lock_window("AWindowGUI::close_event");
724         save_defaults(mwindow->defaults);
725         mwindow->save_defaults();
726         return 1;
727 }
728
729 void AWindowGUI::start_vicon_drawing()
730 {
731         if( !vicon_drawing ) return;
732         if( mwindow->edl->session->awindow_folder != AW_MEDIA_FOLDER ) return;
733         if( mwindow->edl->session->assetlist_format != ASSETS_ICONS ) return;
734         vicon_thread->start_drawing();
735 }
736
737 void AWindowGUI::stop_vicon_drawing()
738 {
739         vicon_thread->stop_drawing();
740 }
741
742 AWindowRemovePluginGUI::
743 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
744         int x, int y, PluginServer *plugin)
745  : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
746 {
747         this->awindow = awindow;
748         this->thread = thread;
749         this->plugin = plugin;
750         VFrame *vframe = plugin->get_picon();
751         icon = vframe ? create_pixmap(vframe) : 0;
752         plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
753 }
754
755 AWindowRemovePluginGUI::
756 ~AWindowRemovePluginGUI()
757 {
758         if( !awindow->gui->protected_pixmap(icon) )
759                 delete icon;
760         plugin_list.remove_all();
761 }
762
763 void AWindowRemovePluginGUI::create_objects()
764 {
765         BC_Button *ok_button = new BC_OKButton(this);
766         add_subwindow(ok_button);
767         BC_Button *cancel_button = new BC_CancelButton(this);
768         add_subwindow(cancel_button);
769         int x = 10, y = 10;
770         BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
771         add_subwindow(title);
772         y += title->get_h() + 5;
773         list = new BC_ListBox(x, y,
774                 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
775                 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
776         add_subwindow(list);
777         show_window();
778 }
779
780 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
781 {
782         int ret = 0;
783         for( int i=0; i<folder.size(); ) {
784                 AssetPicon *picon = (AssetPicon *)folder[i];
785                 if( picon->plugin == plugin ) {
786                         folder.remove_object_number(i);
787                         ++ret;
788                         continue;
789                 }
790                 ++i;
791         }
792         return ret;
793 }
794
795 void AWindowRemovePlugin::handle_close_event(int result)
796 {
797         if( !result ) {
798                 printf(_("remove %s\n"), plugin->path);
799                 ArrayList<BC_ListBoxItem*> *folder =
800                         plugin->audio ? plugin->transition ?
801                                 &awindow->gui->atransitions :
802                                 &awindow->gui->aeffects :
803                         plugin->video ?  plugin->transition ?
804                                 &awindow->gui->vtransitions :
805                                 &awindow->gui->veffects :
806                         0;
807                 if( folder ) remove_plugin(plugin, *folder);
808                 char plugin_path[BCTEXTLEN];
809                 strcpy(plugin_path, plugin->path);
810                 MWindow *mwindow = awindow->mwindow;
811                 mwindow->plugindb->remove(plugin);
812                 remove(plugin_path);
813                 char index_path[BCTEXTLEN];
814                 snprintf(index_path, sizeof(index_path), "%s/%s",
815                         mwindow->preferences->plugin_dir, PLUGIN_FILE);
816                 remove(index_path);
817                 FileSystem fs;
818                 fs.update(File::get_plugin_path());
819                 for( int i=0; i<fs.dir_list.total; ++i ) {
820                         char *fs_path = fs.dir_list[i]->path;
821                         if( !fs.is_dir(fs_path) ) continue;
822                         char *cp = strrchr(fs_path,'/');
823                         cp = !cp ? fs_path : cp+1;
824                         if( strncmp("picon_", cp, 6) ) continue;
825                         char png_path[BCTEXTLEN];
826                         if( !plugin->get_plugin_png_path(png_path, cp+6) )
827                                 remove(png_path);
828                 }
829                 delete plugin;  plugin = 0;
830                 awindow->gui->async_update_assets();
831         }
832 }
833
834 AWindowRemovePlugin::
835 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
836  : BC_DialogThread()
837 {
838         this->awindow = awindow;
839         this->plugin = plugin;
840 }
841
842 AWindowRemovePlugin::
843 ~AWindowRemovePlugin()
844 {
845         close_window();
846 }
847
848 BC_Window* AWindowRemovePlugin::new_gui()
849 {
850         int x = awindow->gui->get_abs_cursor_x(0);
851         int y = awindow->gui->get_abs_cursor_y(0);
852         AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
853         gui->create_objects();
854         return gui;
855 }
856
857 int AWindowGUI::keypress_event()
858 {
859         switch( get_keypress() ) {
860         case 'w': case 'W':
861                 if( ctrl_down() ) {
862                         close_event();
863                         return 1;
864                 }
865                 break;
866         case DELETE:
867                 if( shift_down() ) {
868                         PluginServer* plugin = selected_plugin();
869                         if( !plugin ) break;
870                         remove_plugin = new AWindowRemovePlugin(awindow, plugin);
871                         unlock_window();
872                         remove_plugin->start();
873                         lock_window();
874                 }
875         }
876         return 0;
877 }
878
879
880
881 int AWindowGUI::create_custom_xatoms()
882 {
883         UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
884         return 0;
885 }
886 int AWindowGUI::recieve_custom_xatoms(xatom_event *event)
887 {
888         if( event->message_type == UpdateAssetsXAtom ) {
889                 update_assets();
890                 return 1;
891         }
892         return 0;
893 }
894
895 void AWindowGUI::async_update_assets()
896 {
897         xatom_event event;
898         event.message_type = UpdateAssetsXAtom;
899         send_custom_xatom(&event);
900 }
901
902
903 void AWindowGUI::update_folder_list()
904 {
905         stop_vicon_drawing();
906         for( int i = 0; i < folders.total; i++ ) {
907                 AssetPicon *picon = (AssetPicon*)folders.values[i];
908                 picon->in_use = 0;
909         }
910
911 // Search assets for folders
912         for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
913                 const char *folder = mwindow->edl->folders.values[i];
914                 int exists = 0;
915
916                 for( int j = 0; j < folders.total; j++ ) {
917                         AssetPicon *picon = (AssetPicon*)folders.values[j];
918                         if( !strcasecmp(picon->get_text(), folder) ) {
919                                 exists = 1;
920                                 picon->in_use = 1;
921                                 break;
922                         }
923                 }
924
925                 if( !exists ) {
926                         int aw_folder = folder_number(folder);
927                         if( aw_folder >= 0 ) {
928                                 AssetPicon *picon = new AssetPicon(mwindow, this, aw_folder, 1);
929                                 picon->create_objects();
930                                 folders.append(picon);
931                         }
932                 }
933         }
934
935 // Delete unused non-persistent folders
936         for( int i=folders.total; --i>=0; ) {
937                 AssetPicon *picon = (AssetPicon*)folders.values[i];
938                 if( !picon->in_use && !picon->persistent ) {
939                         delete picon;
940                         folders.remove_number(i);
941                 }
942         }
943
944         start_vicon_drawing();
945 }
946
947 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
948         int do_audio, int do_video, int is_realtime, int is_transition)
949 {
950         ArrayList<PluginServer*> plugin_list;
951 // Get pointers to plugindb entries
952         mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
953                         0, plugin_list);
954
955         for( int i = 0; i < plugin_list.total; i++ ) {
956                 PluginServer *server = plugin_list.values[i];
957                 int visible = plugin_visibility & (1<<server->dir_idx);
958                 if( !visible ) continue;
959 // Create new listitem
960                 AssetPicon *picon = new AssetPicon(mwindow, this, server);
961                 picon->create_objects();
962                 output->append(picon);
963         }
964 }
965
966 void AWindowGUI::create_label_folder()
967 {
968         Label *current;
969         for( current = mwindow->edl->labels->first; current; current = NEXT ) {
970                 AssetPicon *picon = new AssetPicon(mwindow, this, current);
971                 picon->create_objects();
972                 labellist.append(picon);
973         }
974 }
975
976
977 void AWindowGUI::update_asset_list()
978 {
979         for( int i = 0; i < assets.total; i++ ) {
980                 AssetPicon *picon = (AssetPicon*)assets.values[i];
981                 picon->in_use = 0;
982         }
983
984 // Synchronize EDL clips
985         for( int i = 0; i < mwindow->edl->clips.total; i++ ) {
986                 int exists = 0;
987
988 // Look for clip in existing listitems
989                 for( int j = 0; j < assets.total && !exists; j++ ) {
990                         AssetPicon *picon = (AssetPicon*)assets.values[j];
991
992                         if( picon->id == mwindow->edl->clips.values[i]->id ) {
993                                 picon->edl = mwindow->edl->clips.values[i];
994                                 picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title);
995                                 exists = 1;
996                                 picon->in_use = 1;
997                         }
998                 }
999
1000 // Create new listitem
1001                 if( !exists ) {
1002                         AssetPicon *picon = new AssetPicon(mwindow,
1003                                 this, mwindow->edl->clips.values[i]);
1004                         picon->create_objects();
1005                         assets.append(picon);
1006                 }
1007         }
1008
1009 // Synchronize EDL assets
1010         for( Asset *current = mwindow->edl->assets->first;
1011                 current;
1012                 current = NEXT ) {
1013                 int exists = 0;
1014
1015 // Look for asset in existing listitems
1016                 for( int j = 0; j < assets.total && !exists; j++ ) {
1017                         AssetPicon *picon = (AssetPicon*)assets.values[j];
1018
1019                         if( picon->id == current->id ) {
1020                                 picon->indexable = current;
1021                                 exists = 1;
1022                                 picon->in_use = 1;
1023                                 break;
1024                         }
1025                 }
1026
1027 // Create new listitem
1028                 if( !exists ) {
1029                         AssetPicon *picon = new AssetPicon(mwindow,
1030                                 this, current);
1031                         picon->create_objects();
1032                         assets.append(picon);
1033                 }
1034         }
1035
1036         mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1037         mwindow->gui->default_message();
1038         mwindow->gui->unlock_window();
1039
1040 // Synchronize nested EDLs
1041         for( int i = 0; i < mwindow->edl->nested_edls->size(); i++ ) {
1042                 int exists = 0;
1043                 Indexable *indexable = mwindow->edl->nested_edls->get(i);
1044
1045 // Look for asset in existing listitems
1046                 for( int j = 0; j < assets.total && !exists; j++ ) {
1047                         AssetPicon *picon = (AssetPicon*)assets.values[j];
1048
1049                         if( picon->id == indexable->id ) {
1050                                 picon->indexable = indexable;
1051                                 exists = 1;
1052                                 picon->in_use = 1;
1053                                 break;
1054                         }
1055                 }
1056
1057 // Create new listitem
1058                 if( !exists ) {
1059                         AssetPicon *picon = new AssetPicon(mwindow,
1060                                 this, indexable);
1061                         picon->create_objects();
1062                         assets.append(picon);
1063                 }
1064         }
1065
1066         for( int i = assets.size() - 1; i >= 0; i-- ) {
1067                 AssetPicon *picon = (AssetPicon*)assets.get(i);
1068                 if( !picon->in_use ) {
1069                         delete picon;
1070                         assets.remove_number(i);
1071                 }
1072         }
1073 }
1074
1075 void AWindowGUI::update_picon(Indexable *indexable)
1076 {
1077         VIcon *vicon = 0;
1078         for( int i = 0; i < assets.total; i++ ) {
1079                 AssetPicon *picon = (AssetPicon*)assets.values[i];
1080                 if( picon->indexable == indexable ||
1081                     picon->edl == (EDL *)indexable ) {
1082                         char name[BCTEXTLEN];
1083                         FileSystem fs;
1084                         fs.extract_name(name, indexable->path);
1085                         picon->set_text(name);
1086                         vicon = picon->vicon;
1087                         break;
1088                 }
1089         }
1090         if( vicon ) {
1091                 stop_vicon_drawing();
1092                 vicon->clear_images();
1093                 vicon->reset(indexable->get_frame_rate());
1094                 start_vicon_drawing();
1095         }
1096 }
1097
1098 void AWindowGUI::sort_assets()
1099 {
1100         switch( mwindow->edl->session->awindow_folder ) {
1101         case AW_AEFFECT_FOLDER:
1102                 sort_picons(&aeffects);
1103                 break;
1104         case AW_VEFFECT_FOLDER:
1105                 sort_picons(&veffects);
1106                 break;
1107         case AW_ATRANSITION_FOLDER:
1108                 sort_picons(&atransitions);
1109                 break;
1110         case AW_VTRANSITION_FOLDER:
1111                 sort_picons(&vtransitions);
1112                 break;
1113         case AW_LABEL_FOLDER:
1114                 sort_picons(&labellist);
1115                 break;
1116         default:
1117                 sort_picons(&assets);
1118         }
1119
1120         update_assets();
1121 }
1122
1123 void AWindowGUI::sort_folders()
1124 {
1125         sort_picons(&folders);
1126         update_assets();
1127 }
1128
1129 void AWindowGUI::collect_assets()
1130 {
1131         int i = 0;
1132         mwindow->session->drag_assets->remove_all();
1133         mwindow->session->drag_clips->remove_all();
1134         while(1)
1135         {
1136                 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
1137                 if( !result ) break;
1138
1139                 if( result->indexable ) mwindow->session->drag_assets->append(result->indexable);
1140                 if( result->edl ) mwindow->session->drag_clips->append(result->edl);
1141         }
1142 }
1143
1144 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
1145         ArrayList<BC_ListBoxItem*> *src, int folder)
1146 {
1147 // Remove current pointers
1148         dst[0].remove_all();
1149         dst[1].remove_all_objects();
1150
1151 // Create new pointers
1152         for( int i = 0; i < src->total; i++ ) {
1153                 AssetPicon *picon = (AssetPicon*)src->values[i];
1154                 if( folder < 0 ||
1155                     (picon->indexable && picon->indexable->awindow_folder == folder) ||
1156                     (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
1157                         BC_ListBoxItem *item2, *item1;
1158                         dst[0].append(item1 = picon);
1159                         if( picon->edl )
1160                                 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1161                         else
1162                         if( picon->label && picon->label->textstr )
1163                                 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1164                         else
1165                                 dst[1].append(item2 = new BC_ListBoxItem(""));
1166                         item1->set_autoplace_text(1);
1167                         item2->set_autoplace_text(1);
1168                 }
1169         }
1170 }
1171
1172 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
1173 {
1174         int done = 0;
1175         while(!done)
1176         {
1177                 done = 1;
1178                 for( int i = 0; i < src->total - 1; i++ ) {
1179                         BC_ListBoxItem *item1 = src->values[i];
1180                         BC_ListBoxItem *item2 = src->values[i + 1];
1181                         item1->set_autoplace_icon(1);
1182                         item2->set_autoplace_icon(1);
1183                         item1->set_autoplace_text(1);
1184                         item2->set_autoplace_text(1);
1185                         if( strcmp(item1->get_text(), item2->get_text()) > 0 ) {
1186                                 src->values[i + 1] = item1;
1187                                 src->values[i] = item2;
1188                                 done = 0;
1189                         }
1190                 }
1191         }
1192 }
1193
1194
1195 void AWindowGUI::filter_displayed_assets()
1196 {
1197         //allow_iconlisting = 1;
1198         asset_titles[0] = _("Title");
1199         asset_titles[1] = _("Comments");
1200
1201         switch( mwindow->edl->session->awindow_folder ) {
1202         case AW_AEFFECT_FOLDER:
1203                 copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
1204                 break;
1205         case AW_VEFFECT_FOLDER:
1206                 copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
1207                 break;
1208         case AW_ATRANSITION_FOLDER:
1209                 copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
1210                 break;
1211         case AW_VTRANSITION_FOLDER:
1212                 copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
1213                 break;
1214         case AW_LABEL_FOLDER:
1215                 copy_picons(displayed_assets, &labellist, AW_NO_FOLDER);
1216                 asset_titles[0] = _("Time Stamps");
1217                 asset_titles[1] = _("Title");
1218                 //allow_iconlisting = 0;
1219                 break;
1220         default:
1221                 copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
1222                 break;
1223         }
1224
1225         // Ensure the current folder icon is highlighted
1226         int selected_folder = mwindow->edl->session->awindow_folder;
1227         for( int i = 0; i < folders.total; i++ ) {
1228                 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
1229                 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
1230                 folder_item->set_selected(selected);
1231         }
1232 }
1233
1234
1235 void AWindowGUI::update_assets()
1236 {
1237         update_folder_list();
1238         update_asset_list();
1239         labellist.remove_all_objects();
1240         create_label_folder();
1241         filter_displayed_assets();
1242
1243         if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
1244                 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1245         }
1246         int folder_xposition = folder_list->get_xposition();
1247         int folder_yposition = folder_list->get_yposition();
1248         folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
1249
1250         if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
1251                 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1252         }
1253         int asset_xposition = asset_list->get_xposition();
1254         int asset_yposition = asset_list->get_yposition();
1255         if( displayed_folder != mwindow->edl->session->awindow_folder ) {
1256                 displayed_folder = mwindow->edl->session->awindow_folder;
1257                 asset_xposition = asset_yposition = 0;
1258         }
1259         asset_list->update(displayed_assets, asset_titles,
1260                 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
1261                 asset_xposition, asset_yposition, -1, 0);
1262         asset_list->center_selection();
1263
1264         flush();
1265         return;
1266 }
1267
1268 void AWindowGUI::update_effects()
1269 {
1270         aeffects.remove_all_objects();
1271         create_persistent_folder(&aeffects, 1, 0, 1, 0);
1272         veffects.remove_all_objects();
1273         create_persistent_folder(&veffects, 0, 1, 1, 0);
1274         atransitions.remove_all_objects();
1275         create_persistent_folder(&atransitions, 1, 0, 0, 1);
1276         vtransitions.remove_all_objects();
1277         create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1278 }
1279
1280 int AWindowGUI::folder_number(const char *name)
1281 {
1282         for( int i = 0; i < AWINDOW_FOLDERS; i++ ) {
1283                 if( !strcasecmp(name, folder_names[i]) ) return i;
1284         }
1285         return AW_NO_FOLDER;
1286 }
1287
1288 int AWindowGUI::drag_motion()
1289 {
1290         if( get_hidden() ) return 0;
1291
1292         int result = 0;
1293         return result;
1294 }
1295
1296 int AWindowGUI::drag_stop()
1297 {
1298         if( get_hidden() ) return 0;
1299
1300         return 0;
1301 }
1302
1303 Indexable* AWindowGUI::selected_asset()
1304 {
1305         AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1306         return picon ? picon->indexable : 0;
1307 }
1308
1309 PluginServer* AWindowGUI::selected_plugin()
1310 {
1311         AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1312         return picon ? picon->plugin : 0;
1313 }
1314
1315 AssetPicon* AWindowGUI::selected_folder()
1316 {
1317         AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1318         return picon;
1319 }
1320
1321
1322
1323
1324
1325
1326
1327
1328 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1329  : BC_SubWindow(x, y, w, h)
1330 {
1331         this->mwindow = mwindow;
1332         this->gui = gui;
1333 }
1334 AWindowDivider::~AWindowDivider()
1335 {
1336 }
1337
1338 int AWindowDivider::button_press_event()
1339 {
1340         if( is_event_win() && cursor_inside() ) {
1341                 mwindow->session->current_operation = DRAG_PARTITION;
1342                 return 1;
1343         }
1344         return 0;
1345 }
1346
1347 int AWindowDivider::cursor_motion_event()
1348 {
1349         if( mwindow->session->current_operation == DRAG_PARTITION ) {
1350                 int wmin = 25;
1351                 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
1352                 int fw = gui->get_relative_cursor_x();
1353                 if( fw > wmax ) fw = wmax;
1354                 if( fw < wmin ) fw = wmin;
1355                 mwindow->session->afolders_w = fw;
1356                 mwindow->theme->get_awindow_sizes(gui);
1357                 gui->reposition_objects();
1358                 gui->flush();
1359         }
1360         return 0;
1361 }
1362
1363 int AWindowDivider::button_release_event()
1364 {
1365         if( mwindow->session->current_operation == DRAG_PARTITION ) {
1366                 mwindow->session->current_operation = NO_OPERATION;
1367                 return 1;
1368         }
1369         return 0;
1370 }
1371
1372
1373
1374
1375
1376
1377 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1378  : BC_ListBox(x, y, w, h,
1379                 mwindow->edl->session->folderlist_format == ASSETS_ICONS ?
1380                         LISTBOX_ICONS : LISTBOX_TEXT,
1381                 &gui->folders,    // Each column has an ArrayList of BC_ListBoxItems.
1382                 0,                // Titles for columns.  Set to 0 for no titles
1383                 0,                // width of each column
1384                 1,                // Total columns.
1385                 0,                // Pixel of top of window.
1386                 0,                // If this listbox is a popup window
1387                 LISTBOX_SINGLE,   // Select one item or multiple items
1388                 ICON_TOP,         // Position of icon relative to text of each item
1389                 1)                // Allow drags
1390 {
1391         this->mwindow = mwindow;
1392         this->gui = gui;
1393         set_drag_scroll(0);
1394 }
1395
1396 AWindowFolders::~AWindowFolders()
1397 {
1398 }
1399
1400 int AWindowFolders::selection_changed()
1401 {
1402         AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1403         if( picon ) {
1404                 gui->stop_vicon_drawing();
1405
1406                 if( get_button_down() && get_buttonpress() == 3 ) {
1407                         gui->folderlist_menu->update_titles();
1408                         gui->folderlist_menu->activate_menu();
1409                 }
1410
1411                 mwindow->edl->session->awindow_folder = picon->foldernum;
1412                 gui->asset_list->draw_background();
1413                 gui->async_update_assets();
1414
1415                 gui->start_vicon_drawing();
1416         }
1417         return 1;
1418 }
1419
1420 int AWindowFolders::button_press_event()
1421 {
1422         int result = 0;
1423
1424         result = BC_ListBox::button_press_event();
1425
1426         if( !result ) {
1427                 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1428                         gui->folderlist_menu->update_titles();
1429                         gui->folderlist_menu->activate_menu();
1430                         result = 1;
1431                 }
1432         }
1433
1434
1435         return result;
1436 }
1437
1438
1439
1440
1441
1442
1443
1444 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1445  : BC_ListBox(x, y, w, h,
1446                 (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
1447                         LISTBOX_ICONS : LISTBOX_TEXT,
1448                 &gui->assets,     // Each column has an ArrayList of BC_ListBoxItems.
1449                 gui->asset_titles,// Titles for columns.  Set to 0 for no titles
1450                 mwindow->edl->session->asset_columns, // width of each column
1451                 1,                // Total columns.
1452                 0,                // Pixel of top of window.
1453                 0,                // If this listbox is a popup window
1454                 LISTBOX_MULTIPLE, // Select one item or multiple items
1455                 ICON_TOP,         // Position of icon relative to text of each item
1456                 1)                // Allow drag
1457 {
1458         this->mwindow = mwindow;
1459         this->gui = gui;
1460         set_drag_scroll(0);
1461         set_scroll_stretch(1, 1);
1462 }
1463
1464 AWindowAssets::~AWindowAssets()
1465 {
1466 }
1467
1468 int AWindowAssets::button_press_event()
1469 {
1470         int result = 0;
1471
1472         result = BC_ListBox::button_press_event();
1473
1474         if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1475                 BC_ListBox::deactivate_selection();
1476                 int folder = mwindow->edl->session->awindow_folder;
1477                 switch( folder ) {
1478                 case AW_AEFFECT_FOLDER:
1479                 case AW_VEFFECT_FOLDER:
1480                 case AW_ATRANSITION_FOLDER:
1481                 case AW_VTRANSITION_FOLDER:
1482                         gui->effectlist_menu->update();
1483                         gui->effectlist_menu->activate_menu();
1484                         break;
1485                 case AW_LABEL_FOLDER:
1486                         gui->labellist_menu->update();
1487                         gui->labellist_menu->activate_menu();
1488                         break;
1489                 case AW_CLIP_FOLDER:
1490                         gui->cliplist_menu->update();
1491                         gui->cliplist_menu->activate_menu();
1492                         break;
1493                 case AW_MEDIA_FOLDER:
1494                 case AW_PROXY_FOLDER:
1495                         gui->assetlist_menu->update_titles();
1496                         gui->assetlist_menu->activate_menu();
1497                         break;
1498                 }
1499                 result = 1;
1500         }
1501
1502         return result;
1503 }
1504
1505
1506 int AWindowAssets::handle_event()
1507 {
1508         AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
1509         if( !asset_picon ) return 0;
1510         switch( mwindow->edl->session->awindow_folder ) {
1511         case AW_AEFFECT_FOLDER:
1512         case AW_VEFFECT_FOLDER:
1513         case AW_ATRANSITION_FOLDER:
1514         case AW_VTRANSITION_FOLDER: return 1;
1515         }
1516         VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1517                 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1518         if( !vwindow || !vwindow->is_running() ) return 1;
1519
1520         vwindow->gui->lock_window("AWindowAssets::handle_event");
1521         if( asset_picon->indexable )
1522                 vwindow->change_source(asset_picon->indexable);
1523         else if( asset_picon->edl )
1524                 vwindow->change_source(asset_picon->edl);
1525         vwindow->gui->unlock_window();
1526         return 1;
1527 }
1528
1529 int AWindowAssets::selection_changed()
1530 {
1531 // Show popup window
1532         AssetPicon *item;
1533         if( get_button_down() && get_buttonpress() == 3 &&
1534             (item = (AssetPicon*)get_selection(0, 0)) ) {
1535                 int folder = mwindow->edl->session->awindow_folder;
1536                 switch( folder ) {
1537                 case AW_AEFFECT_FOLDER:
1538                 case AW_VEFFECT_FOLDER:
1539                 case AW_ATRANSITION_FOLDER:
1540                 case AW_VTRANSITION_FOLDER:
1541                         gui->effectlist_menu->update();
1542                         gui->effectlist_menu->activate_menu();
1543                         break;
1544                 case AW_LABEL_FOLDER:
1545                         if( !item->label ) break;
1546                         gui->label_menu->activate_menu();
1547                         break;
1548                 case AW_CLIP_FOLDER:
1549                         if( !item->indexable && !item->edl ) break;
1550                         gui->clip_menu->update();
1551                         gui->clip_menu->activate_menu();
1552                         break;
1553                 default:
1554                         if( !item->indexable && !item->edl ) break;
1555                         gui->asset_menu->update();
1556                         gui->asset_menu->activate_menu();
1557                         break;
1558                 }
1559
1560                 BC_ListBox::deactivate_selection();
1561                 return 1;
1562         }
1563         else if( get_button_down() && get_buttonpress() == 1 &&
1564                  (item = (AssetPicon*)get_selection(0, 0)) ) {
1565                 VIcon *vicon = 0;
1566                 if( !gui->vicon_thread->viewing ) {
1567                         vicon = item->vicon;
1568                 }
1569                 gui->vicon_thread->set_view_popup(vicon);
1570
1571         }
1572         return 0;
1573 }
1574
1575 void AWindowAssets::draw_background()
1576 {
1577         clear_box(0,0,get_w(),get_h(),get_bg_surface());
1578         set_color(BC_WindowBase::get_resources()->audiovideo_color);
1579         set_font(LARGEFONT);
1580         int aw_folder = mwindow->edl->session->awindow_folder;
1581         if( aw_folder < 0 ) return;
1582         const char *aw_name = _(AWindowGUI::folder_names[aw_folder]);
1583         draw_text(get_w() - get_text_width(LARGEFONT, aw_name) - 4, 30,
1584                 aw_name, -1, get_bg_surface());
1585 }
1586
1587 int AWindowAssets::drag_start_event()
1588 {
1589         int collect_pluginservers = 0;
1590         int collect_assets = 0;
1591
1592         if( BC_ListBox::drag_start_event() ) {
1593                 switch( mwindow->edl->session->awindow_folder ) {
1594                 case AW_AEFFECT_FOLDER:
1595                         mwindow->session->current_operation = DRAG_AEFFECT;
1596                         collect_pluginservers = 1;
1597                         break;
1598                 case AW_VEFFECT_FOLDER:
1599                         mwindow->session->current_operation = DRAG_VEFFECT;
1600                         collect_pluginservers = 1;
1601                         break;
1602                 case AW_ATRANSITION_FOLDER:
1603                         mwindow->session->current_operation = DRAG_ATRANSITION;
1604                         collect_pluginservers = 1;
1605                         break;
1606                 case AW_VTRANSITION_FOLDER:
1607                         mwindow->session->current_operation = DRAG_VTRANSITION;
1608                         collect_pluginservers = 1;
1609                         break;
1610                 case AW_LABEL_FOLDER:
1611                         // do nothing!
1612                         break;
1613                 default:
1614                         mwindow->session->current_operation = DRAG_ASSET;
1615                         collect_assets = 1;
1616                         break;
1617                 }
1618
1619                 if( collect_pluginservers ) {
1620                         int i = 0;
1621                         mwindow->session->drag_pluginservers->remove_all();
1622                         while(1)
1623                         {
1624                                 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
1625                                 if( !result ) break;
1626
1627                                 mwindow->session->drag_pluginservers->append(result->plugin);
1628                         }
1629                 }
1630
1631                 if( collect_assets ) {
1632                         gui->collect_assets();
1633                 }
1634
1635                 return 1;
1636         }
1637         return 0;
1638 }
1639
1640 int AWindowAssets::drag_motion_event()
1641 {
1642         BC_ListBox::drag_motion_event();
1643         unlock_window();
1644
1645         mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1646         mwindow->gui->drag_motion();
1647         mwindow->gui->unlock_window();
1648
1649         for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
1650                 VWindow *vwindow = mwindow->vwindows.get(i);
1651                 if( !vwindow->is_running() ) continue;
1652                 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1653                 vwindow->gui->drag_motion();
1654                 vwindow->gui->unlock_window();
1655         }
1656
1657         mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1658         mwindow->cwindow->gui->drag_motion();
1659         mwindow->cwindow->gui->unlock_window();
1660
1661         lock_window("AWindowAssets::drag_motion_event");
1662         return 0;
1663 }
1664
1665 int AWindowAssets::drag_stop_event()
1666 {
1667         int result = 0;
1668
1669         result = gui->drag_stop();
1670
1671         unlock_window();
1672
1673         if( !result ) {
1674                 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1675                 result = mwindow->gui->drag_stop();
1676                 mwindow->gui->unlock_window();
1677         }
1678
1679         if( !result ) {
1680                 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
1681                         VWindow *vwindow = mwindow->vwindows.get(i);
1682                         if( !vwindow ) continue;
1683                         if( !vwindow->is_running() ) continue;
1684                         if( vwindow->gui->is_hidden() ) continue;
1685                         vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1686                         if( vwindow->gui->cursor_above() &&
1687                             vwindow->gui->get_cursor_over_window() ) {
1688                                 result = vwindow->gui->drag_stop();
1689                         }
1690                         vwindow->gui->unlock_window();
1691                 }
1692         }
1693
1694         if( !result ) {
1695                 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1696                 result = mwindow->cwindow->gui->drag_stop();
1697                 mwindow->cwindow->gui->unlock_window();
1698         }
1699
1700         lock_window("AWindowAssets::drag_stop_event");
1701
1702         if( result ) get_drag_popup()->set_animation(0);
1703
1704         BC_ListBox::drag_stop_event();
1705         mwindow->session->current_operation = ::NO_OPERATION; // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
1706         return 0;
1707 }
1708
1709 int AWindowAssets::column_resize_event()
1710 {
1711         mwindow->edl->session->asset_columns[0] = get_column_width(0);
1712         mwindow->edl->session->asset_columns[1] = get_column_width(1);
1713         return 1;
1714 }
1715
1716 int AWindowAssets::focus_in_event()
1717 {
1718         gui->start_vicon_drawing();
1719         return 0;
1720 }
1721
1722 int AWindowAssets::focus_out_event()
1723 {
1724         gui->stop_vicon_drawing();
1725         return BC_ListBox::focus_out_event();
1726 }
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1740  : BC_Button(x, y, mwindow->theme->newbin_data)
1741 {
1742         this->mwindow = mwindow;
1743         this->gui = gui;
1744         set_tooltip(_("New bin"));
1745 }
1746
1747 int AWindowNewFolder::handle_event()
1748 {
1749         gui->newfolder_thread->start_new_folder();
1750         return 1;
1751 }
1752
1753 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1754  : BC_Button(x, y, mwindow->theme->deletebin_data)
1755 {
1756         this->mwindow = mwindow;
1757         this->gui = gui;
1758         set_tooltip(_("Delete bin"));
1759 }
1760
1761 int AWindowDeleteFolder::handle_event()
1762 {
1763         if( gui->folder_list->get_selection(0, 0) ) {
1764                 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
1765                 mwindow->delete_folder(folder->get_text());
1766         }
1767         return 1;
1768 }
1769
1770 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1771  : BC_Button(x, y, mwindow->theme->renamebin_data)
1772 {
1773         this->mwindow = mwindow;
1774         this->gui = gui;
1775         set_tooltip(_("Rename bin"));
1776 }
1777
1778 int AWindowRenameFolder::handle_event()
1779 {
1780         return 1;
1781 }
1782
1783 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1784  : BC_Button(x, y, mwindow->theme->deletedisk_data)
1785 {
1786         this->mwindow = mwindow;
1787         this->gui = gui;
1788         set_tooltip(_("Delete asset from disk"));
1789 }
1790
1791 int AWindowDeleteDisk::handle_event()
1792 {
1793         return 1;
1794 }
1795
1796 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1797  : BC_Button(x, y, mwindow->theme->deleteproject_data)
1798 {
1799         this->mwindow = mwindow;
1800         this->gui = gui;
1801         set_tooltip(_("Delete asset from project"));
1802 }
1803
1804 int AWindowDeleteProject::handle_event()
1805 {
1806         return 1;
1807 }
1808
1809 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1810 //  : BC_Button(x, y, mwindow->theme->infoasset_data)
1811 // {
1812 //      this->mwindow = mwindow;
1813 //      this->gui = gui;
1814 //      set_tooltip(_("Edit information on asset"));
1815 // }
1816 // 
1817 // int AWindowInfo::handle_event()
1818 // {
1819 //      int cur_x, cur_y;
1820 //      gui->get_abs_cursor_xy(cur_x, cur_y, 0);
1821 //      gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
1822 //      return 1;
1823 // }
1824
1825 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1826  : BC_Button(x, y, mwindow->theme->redrawindex_data)
1827 {
1828         this->mwindow = mwindow;
1829         this->gui = gui;
1830         set_tooltip(_("Redraw index"));
1831 }
1832
1833 int AWindowRedrawIndex::handle_event()
1834 {
1835         return 1;
1836 }
1837
1838 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1839  : BC_Button(x, y, mwindow->theme->pasteasset_data)
1840 {
1841         this->mwindow = mwindow;
1842         this->gui = gui;
1843         set_tooltip(_("Paste asset on recordable tracks"));
1844 }
1845
1846 int AWindowPaste::handle_event()
1847 {
1848         return 1;
1849 }
1850
1851 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1852  : BC_Button(x, y, mwindow->theme->appendasset_data)
1853 {
1854         this->mwindow = mwindow;
1855         this->gui = gui;
1856         set_tooltip(_("Append asset in new tracks"));
1857 }
1858
1859 int AWindowAppend::handle_event()
1860 {
1861         return 1;
1862 }
1863
1864 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1865  : BC_Button(x, y, mwindow->theme->viewasset_data)
1866 {
1867         this->mwindow = mwindow;
1868         this->gui = gui;
1869         set_tooltip(_("View asset"));
1870 }
1871
1872 int AWindowView::handle_event()
1873 {
1874         return 1;
1875 }
1876
1877 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
1878  : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
1879 {
1880         this->mwindow = mwindow;
1881         this->gui = gui;
1882 }
1883
1884 void AddTools::create_objects()
1885 {
1886         uint64_t vis = 0;
1887         add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
1888         vis |= 1 << PLUGIN_LADSPA_ID;
1889         add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
1890         vis |= 1 << PLUGIN_FFMPEG_ID;
1891         for( int i=0; i<MWindow::plugindb->size(); ++i ) {
1892                 PluginServer *plugin = MWindow::plugindb->get(i);
1893                 if( !plugin->audio && !plugin->video ) continue;
1894                 int idx = plugin->dir_idx;
1895                 uint32_t msk = 1 << idx;
1896                 if( (msk & vis) != 0 ) continue;
1897                 vis |= msk;
1898                 char parent[BCTEXTLEN];
1899                 strcpy(parent, plugin->path);
1900                 char *bp = strrchr(parent, '/');
1901                 if( bp ) { *bp = 0;  bp = strrchr(parent, '/'); }
1902                 if( !bp ) bp = parent; else ++bp;
1903                 add_item(new AddPluginItem(this, bp, idx));
1904         }
1905 }
1906
1907 #if 0
1908 // plugin_dirs list from toplevel makefile include plugin_defs
1909 N_("ladspa")
1910 N_("ffmpeg")
1911 N_("audio_tools")
1912 N_("audio_transitions")
1913 N_("blending")
1914 N_("colors")
1915 N_("exotic")
1916 N_("transforms")
1917 N_("tv_effects")
1918 N_("video_tools")
1919 N_("video_transitions")
1920 #endif
1921
1922 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
1923  : BC_MenuItem(_(text))
1924 {
1925         this->menu = menu;
1926         this->idx = idx;
1927         uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
1928         int chk = (msk & vis) ? 1 : 0;
1929         set_checked(chk);
1930 }
1931
1932 int AddPluginItem::handle_event()
1933 {
1934         int chk = get_checked() ^ 1;
1935         set_checked(chk);
1936         uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
1937         menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
1938         menu->gui->update_effects();
1939         menu->gui->save_defaults(menu->mwindow->defaults);
1940         menu->gui->async_update_assets();
1941         return 1;
1942 }
1943
1944 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
1945  : BC_Toggle(x, y, images, agui->vicon_drawing)
1946 {
1947         this->agui = agui;
1948         set_tooltip(_("draw vicons"));
1949 }
1950
1951 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
1952 {
1953         int text_line = -1, toggle_x = -1, toggle_y = -1;
1954         int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
1955         BC_Toggle::calculate_extents(agui, images, 1,
1956                 &text_line, ww, hh, &toggle_x, &toggle_y,
1957                 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
1958 }
1959
1960 AVIconDrawing::~AVIconDrawing()
1961 {
1962 }
1963
1964 int AVIconDrawing::handle_event()
1965 {
1966         agui->vicon_drawing = get_value();
1967         if( agui->vicon_drawing )
1968                 agui->start_vicon_drawing();
1969         else
1970                 agui->stop_vicon_drawing();
1971         return 1;
1972 }
1973
1974
1975 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
1976  : BC_MenuItem("")
1977 {
1978         this->mwindow = mwindow;
1979         this->gui = gui;
1980 }
1981
1982 int AWindowListFormat::handle_event()
1983 {
1984         gui->stop_vicon_drawing();
1985
1986         EDLSession *session = mwindow->edl->session;
1987         switch( session->assetlist_format ) {
1988         case ASSETS_TEXT:
1989                 session->assetlist_format = ASSETS_ICONS;
1990                 break;
1991         case ASSETS_ICONS:
1992                 session->assetlist_format = ASSETS_TEXT;
1993                 break;
1994         }
1995
1996         gui->asset_list->update_format(session->assetlist_format, 1);
1997         if( !mwindow->awindow->gui->allow_iconlisting ) {
1998                 mwindow->edl->session->assetlist_format = ASSETS_TEXT;
1999         }
2000
2001         gui->start_vicon_drawing();
2002         return 1;
2003 }
2004
2005 void AWindowListFormat::update()
2006 {
2007         set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
2008                 (char*)_("Display icons") : (char*)_("Display text"));
2009 }
2010
2011 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
2012  : BC_MenuItem(_("Sort items"))
2013 {
2014         this->mwindow = mwindow;
2015         this->gui = gui;
2016 }
2017
2018 int AWindowListSort::handle_event()
2019 {
2020         gui->sort_assets();
2021         return 1;
2022 }
2023