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