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