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