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