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