xlat changes, layout changes
[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         if(get_selection(0, 0))
1590         {
1591                 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER)) {}
1592                 else if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER)) {}
1593                 else if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER)) {}
1594                 else if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER)) {}
1595                 else if(mwindow->vwindows.size()) {
1596 //printf("AWindowAssets::handle_event 2 %d %d\n", get_buttonpress(), get_selection(0, 0));
1597                         mwindow->vwindows.get(DEFAULT_VWINDOW)->gui->lock_window("AWindowAssets::handle_event");
1598
1599                         if(((AssetPicon*)get_selection(0, 0))->indexable)
1600                                 mwindow->vwindows.get(DEFAULT_VWINDOW)->change_source(((AssetPicon*)get_selection(0, 0))->indexable);
1601                         else
1602                         if(((AssetPicon*)get_selection(0, 0))->edl)
1603                                 mwindow->vwindows.get(DEFAULT_VWINDOW)->change_source(((AssetPicon*)get_selection(0, 0))->edl);
1604
1605                         mwindow->vwindows.get(DEFAULT_VWINDOW)->gui->unlock_window();
1606                 }
1607                 return 1;
1608         }
1609
1610         return 0;
1611 }
1612
1613 int AWindowAssets::selection_changed()
1614 {
1615 // Show popup window
1616         if(get_button_down() && get_buttonpress() == 3 && get_selection(0, 0))
1617         {
1618                 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER) ||
1619                         !strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER) ||
1620                         !strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER) ||
1621                         !strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1622                 {
1623                         gui->assetlist_menu->update_titles();
1624                         gui->assetlist_menu->activate_menu();
1625                 }
1626                 else
1627                 if (!strcasecmp(mwindow->edl->session->current_folder, LABEL_FOLDER))
1628                 {
1629                         if(((AssetPicon*)get_selection(0, 0))->label)
1630                                 gui->label_menu->activate_menu();
1631                 }
1632
1633                 BC_ListBox::deactivate_selection();
1634                 return 1;
1635         }
1636         else if( get_button_down() && get_buttonpress() == 1 && get_selection(0, 0) ) {
1637                 VIcon *vicon = 0;
1638                 if( !gui->vicon_thread->viewing ) {
1639                         AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1640                         vicon = picon->vicon;
1641                 }
1642                 gui->vicon_thread->set_view_popup(vicon);
1643
1644         }
1645         return 0;
1646 }
1647
1648 void AWindowAssets::draw_background()
1649 {
1650         clear_box(0,0,get_w(),get_h(),get_bg_surface());
1651         set_color(BC_WindowBase::get_resources()->audiovideo_color);
1652         set_font(LARGEFONT);
1653         draw_text(get_w() -
1654                         get_text_width(LARGEFONT, mwindow->edl->session->current_folder) - 4,
1655                 30,
1656                 mwindow->edl->session->current_folder,
1657                 -1,
1658                 get_bg_surface());
1659 }
1660
1661 int AWindowAssets::drag_start_event()
1662 {
1663         int collect_pluginservers = 0;
1664         int collect_assets = 0;
1665
1666         if(BC_ListBox::drag_start_event())
1667         {
1668                 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1669                 {
1670                         mwindow->session->current_operation = DRAG_AEFFECT;
1671                         collect_pluginservers = 1;
1672                 }
1673                 else
1674                 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1675                 {
1676                         mwindow->session->current_operation = DRAG_VEFFECT;
1677                         collect_pluginservers = 1;
1678                 }
1679                 else
1680                 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1681                 {
1682                         mwindow->session->current_operation = DRAG_ATRANSITION;
1683                         collect_pluginservers = 1;
1684                 }
1685                 else
1686                 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1687                 {
1688                         mwindow->session->current_operation = DRAG_VTRANSITION;
1689                         collect_pluginservers = 1;
1690                 }
1691                 else
1692                 if(!strcasecmp(mwindow->edl->session->current_folder, LABEL_FOLDER))
1693                 {
1694                         // do nothing!
1695                 }
1696                 else
1697                 {
1698                         mwindow->session->current_operation = DRAG_ASSET;
1699                         collect_assets = 1;
1700                 }
1701
1702
1703                 if(collect_pluginservers)
1704                 {
1705                         int i = 0;
1706                         mwindow->session->drag_pluginservers->remove_all();
1707                         while(1)
1708                         {
1709                                 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
1710                                 if(!result) break;
1711
1712                                 mwindow->session->drag_pluginservers->append(result->plugin);
1713                         }
1714                 }
1715
1716                 if(collect_assets)
1717                 {
1718                         gui->collect_assets();
1719                 }
1720
1721                 return 1;
1722         }
1723         return 0;
1724 }
1725
1726 int AWindowAssets::drag_motion_event()
1727 {
1728         BC_ListBox::drag_motion_event();
1729         unlock_window();
1730
1731         mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1732         mwindow->gui->drag_motion();
1733         mwindow->gui->unlock_window();
1734
1735         for(int i = 0; i < mwindow->vwindows.size(); i++)
1736         {
1737                 VWindow *vwindow = mwindow->vwindows.get(i);
1738                 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1739                 vwindow->gui->drag_motion();
1740                 vwindow->gui->unlock_window();
1741         }
1742
1743         mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1744         mwindow->cwindow->gui->drag_motion();
1745         mwindow->cwindow->gui->unlock_window();
1746
1747         lock_window("AWindowAssets::drag_motion_event");
1748         return 0;
1749 }
1750
1751 int AWindowAssets::drag_stop_event()
1752 {
1753         int result = 0;
1754
1755         result = gui->drag_stop();
1756
1757         unlock_window();
1758
1759         if(!result)
1760         {
1761                 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1762                 result = mwindow->gui->drag_stop();
1763                 mwindow->gui->unlock_window();
1764         }
1765
1766         if(!result)
1767         {
1768                 for(int i = 0; i < mwindow->vwindows.size(); i++)
1769                 {
1770                         VWindow *vwindow = mwindow->vwindows.get(i);
1771                         vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1772                         result = vwindow->gui->drag_stop();
1773                         vwindow->gui->unlock_window();
1774                 }
1775         }
1776
1777         if(!result)
1778         {
1779                 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1780                 result = mwindow->cwindow->gui->drag_stop();
1781                 mwindow->cwindow->gui->unlock_window();
1782         }
1783
1784         lock_window("AWindowAssets::drag_stop_event");
1785
1786         if(result) get_drag_popup()->set_animation(0);
1787
1788         BC_ListBox::drag_stop_event();
1789         mwindow->session->current_operation = ::NO_OPERATION; // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
1790         return 0;
1791 }
1792
1793 int AWindowAssets::column_resize_event()
1794 {
1795         mwindow->edl->session->asset_columns[0] = get_column_width(0);
1796         mwindow->edl->session->asset_columns[1] = get_column_width(1);
1797         return 1;
1798 }
1799
1800 int AWindowAssets::focus_in_event()
1801 {
1802         gui->start_vicon_drawing();
1803         return 0;
1804 }
1805
1806 int AWindowAssets::focus_out_event()
1807 {
1808         gui->stop_vicon_drawing();
1809         return BC_ListBox::focus_out_event();
1810 }
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1824  : BC_Button(x, y, mwindow->theme->newbin_data)
1825 {
1826         this->mwindow = mwindow;
1827         this->gui = gui;
1828         set_tooltip(_("New bin"));
1829 }
1830
1831 int AWindowNewFolder::handle_event()
1832 {
1833         gui->newfolder_thread->start_new_folder();
1834         return 1;
1835 }
1836
1837 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1838  : BC_Button(x, y, mwindow->theme->deletebin_data)
1839 {
1840         this->mwindow = mwindow;
1841         this->gui = gui;
1842         set_tooltip(_("Delete bin"));
1843 }
1844
1845 int AWindowDeleteFolder::handle_event()
1846 {
1847         if(gui->folder_list->get_selection(0, 0))
1848         {
1849                 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
1850                 mwindow->delete_folder(folder->get_text());
1851         }
1852         return 1;
1853 }
1854
1855 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1856  : BC_Button(x, y, mwindow->theme->renamebin_data)
1857 {
1858         this->mwindow = mwindow;
1859         this->gui = gui;
1860         set_tooltip(_("Rename bin"));
1861 }
1862
1863 int AWindowRenameFolder::handle_event()
1864 {
1865         return 1;
1866 }
1867
1868 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1869  : BC_Button(x, y, mwindow->theme->deletedisk_data)
1870 {
1871         this->mwindow = mwindow;
1872         this->gui = gui;
1873         set_tooltip(_("Delete asset from disk"));
1874 }
1875
1876 int AWindowDeleteDisk::handle_event()
1877 {
1878         return 1;
1879 }
1880
1881 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1882  : BC_Button(x, y, mwindow->theme->deleteproject_data)
1883 {
1884         this->mwindow = mwindow;
1885         this->gui = gui;
1886         set_tooltip(_("Delete asset from project"));
1887 }
1888
1889 int AWindowDeleteProject::handle_event()
1890 {
1891         return 1;
1892 }
1893
1894 AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1895  : BC_Button(x, y, mwindow->theme->infoasset_data)
1896 {
1897         this->mwindow = mwindow;
1898         this->gui = gui;
1899         set_tooltip(_("Edit information on asset"));
1900 }
1901
1902 int AWindowInfo::handle_event()
1903 {
1904         gui->awindow->asset_edit->edit_asset(gui->selected_asset());
1905         return 1;
1906 }
1907
1908 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1909  : BC_Button(x, y, mwindow->theme->redrawindex_data)
1910 {
1911         this->mwindow = mwindow;
1912         this->gui = gui;
1913         set_tooltip(_("Redraw index"));
1914 }
1915
1916 int AWindowRedrawIndex::handle_event()
1917 {
1918         return 1;
1919 }
1920
1921 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1922  : BC_Button(x, y, mwindow->theme->pasteasset_data)
1923 {
1924         this->mwindow = mwindow;
1925         this->gui = gui;
1926         set_tooltip(_("Paste asset on recordable tracks"));
1927 }
1928
1929 int AWindowPaste::handle_event()
1930 {
1931         return 1;
1932 }
1933
1934 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1935  : BC_Button(x, y, mwindow->theme->appendasset_data)
1936 {
1937         this->mwindow = mwindow;
1938         this->gui = gui;
1939         set_tooltip(_("Append asset in new tracks"));
1940 }
1941
1942 int AWindowAppend::handle_event()
1943 {
1944         return 1;
1945 }
1946
1947 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1948  : BC_Button(x, y, mwindow->theme->viewasset_data)
1949 {
1950         this->mwindow = mwindow;
1951         this->gui = gui;
1952         set_tooltip(_("View asset"));
1953 }
1954
1955 int AWindowView::handle_event()
1956 {
1957         return 1;
1958 }
1959
1960
1961 LabelPopup::LabelPopup(MWindow *mwindow, AWindowGUI *gui)
1962  : BC_PopupMenu(0,
1963                 0,
1964                 0,
1965                 "",
1966                 0)
1967 {
1968         this->mwindow = mwindow;
1969         this->gui = gui;
1970 }
1971
1972 LabelPopup::~LabelPopup()
1973 {
1974 }
1975
1976 void LabelPopup::create_objects()
1977 {
1978         add_item(editlabel = new LabelPopupEdit(mwindow, this));
1979 }
1980
1981 int LabelPopup::update()
1982 {
1983         gui->collect_assets();
1984         return 0;
1985 }
1986
1987
1988
1989 LabelPopupEdit::LabelPopupEdit(MWindow *mwindow, LabelPopup *popup)
1990  : BC_MenuItem(_("Edit..."))
1991 {
1992         this->mwindow = mwindow;
1993         this->popup = popup;
1994 }
1995
1996 LabelPopupEdit::~LabelPopupEdit()
1997 {
1998 }
1999
2000 int LabelPopupEdit::handle_event()
2001 {
2002         int i = 0;
2003         while(1)
2004         {
2005                 AssetPicon *result = (AssetPicon*)mwindow->awindow->gui->asset_list->get_selection(0, i++);
2006                 if(!result) break;
2007
2008                 if(result->label) {
2009                         mwindow->awindow->gui->awindow->label_edit->edit_label(result->label);
2010                         break;
2011                 }
2012         }
2013
2014         return 1;
2015 }
2016
2017 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
2018  : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
2019 {
2020         this->mwindow = mwindow;
2021         this->gui = gui;
2022 }
2023
2024 void AddTools::create_objects()
2025 {
2026         uint64_t vis = 0;
2027         add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
2028         vis |= 1 << PLUGIN_LADSPA_ID;
2029         add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
2030         vis |= 1 << PLUGIN_FFMPEG_ID;
2031         for( int i=0; i<MWindow::plugindb->size(); ++i ) {
2032                 PluginServer *plugin = MWindow::plugindb->get(i);
2033                 if( !plugin->audio && !plugin->video ) continue;
2034                 int idx = plugin->dir_idx;
2035                 uint32_t msk = 1 << idx;
2036                 if( (msk & vis) != 0 ) continue;
2037                 vis |= msk;
2038                 char parent[BCTEXTLEN];
2039                 strcpy(parent, plugin->path);
2040                 char *bp = strrchr(parent, '/');
2041                 if( bp ) { *bp = 0;  bp = strrchr(parent, '/'); }
2042                 if( !bp ) bp = parent; else ++bp;
2043                 add_item(new AddPluginItem(this, bp, idx));
2044         }
2045 }
2046
2047 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
2048  : BC_MenuItem(text)
2049 {
2050         this->menu = menu;
2051         this->idx = idx;
2052         uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2053         int chk = (msk & vis) ? 1 : 0;
2054         set_checked(chk);
2055 }
2056
2057 int AddPluginItem::handle_event()
2058 {
2059         int chk = get_checked() ^ 1;
2060         set_checked(chk);
2061         uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2062         menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
2063         menu->gui->update_effects();
2064         menu->gui->save_defaults(menu->mwindow->defaults);
2065         menu->gui->async_update_assets();
2066         return 1;
2067 }
2068
2069 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
2070  : BC_Toggle(x, y, images, agui->vicon_drawing)
2071 {
2072         this->agui = agui;
2073         set_tooltip(_("draw vicons"));
2074 }
2075
2076 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
2077 {
2078         int text_line = -1, toggle_x = -1, toggle_y = -1;
2079         int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
2080         BC_Toggle::calculate_extents(agui, images, 1,
2081                 &text_line, ww, hh, &toggle_x, &toggle_y,
2082                 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
2083 }
2084
2085 AVIconDrawing::~AVIconDrawing()
2086 {
2087 }
2088
2089 int AVIconDrawing::handle_event()
2090 {
2091         agui->vicon_drawing = get_value();
2092         if( agui->vicon_drawing )
2093                 agui->start_vicon_drawing();
2094         else
2095                 agui->stop_vicon_drawing();
2096         return 1;
2097 }
2098