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