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