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