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