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