4 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
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.
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.
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
23 #include "assetedit.h"
24 #include "assetpopup.h"
26 #include "awindowgui.h"
28 #include "bcsignals.h"
31 #include "bccmodels.h"
32 #include "clippopup.h"
34 #include "cwindowgui.h"
37 #include "edlsession.h"
38 #include "effectlist.h"
40 #include "filesystem.h"
41 #include "folderlistmenu.h"
42 #include "indexable.h"
46 #include "labelpopup.h"
47 #include "localsession.h"
49 #include "mainsession.h"
50 #include "mwindowgui.h"
52 #include "nestededls.h"
53 #include "newfolder.h"
54 #include "preferences.h"
58 #include "vwindowgui.h"
61 #include "data/lad_picon_png.h"
62 #include "data/ff_audio_png.h"
63 #include "data/ff_video_png.h"
70 const char *AWindowGUI::folder_names[] =
74 N_("Audio Transitions"),
75 N_("Video Transitions"),
83 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
84 : VIcon(w, h, framerate)
87 this->length = length;
91 AssetVIcon::~AssetVIcon()
96 VFrame *AssetVIcon::frame()
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;
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() ) {
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);
117 mwindow->video_cache->check_in(asset);
119 return *images[seq_no];
122 int64_t AssetVIcon::set_seq_no(int64_t no)
124 if( no >= length ) no = 0;
128 int AssetVIcon::get_vx()
130 BC_ListBox *lbox = picon->gui->asset_list;
131 return lbox->get_item_x(picon);
133 int AssetVIcon::get_vy()
135 BC_ListBox *lbox = picon->gui->asset_list;
136 return lbox->get_item_y(picon) + lbox->get_title_h();
140 AssetPicon::AssetPicon(MWindow *mwindow,
141 AWindowGUI *gui, Indexable *indexable)
145 this->mwindow = mwindow;
147 this->indexable = indexable;
148 indexable->add_user();
149 this->id = indexable->id;
152 AssetPicon::AssetPicon(MWindow *mwindow,
153 AWindowGUI *gui, EDL *edl)
157 this->mwindow = mwindow;
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)
172 this->mwindow = mwindow;
174 persistent = persist;
177 AssetPicon::AssetPicon(MWindow *mwindow,
178 AWindowGUI *gui, PluginServer *plugin)
182 this->mwindow = mwindow;
184 this->plugin = plugin;
187 AssetPicon::AssetPicon(MWindow *mwindow,
188 AWindowGUI *gui, Label *label)
192 this->mwindow = mwindow;
200 AssetPicon::~AssetPicon()
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) ) {
208 if( !plugin ) delete icon_vframe;
212 void AssetPicon::reset()
218 foldernum = AW_NO_FOLDER;
227 void AssetPicon::create_objects()
230 char name[BCTEXTLEN];
231 int pixmap_w, pixmap_h;
233 pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
236 fs.extract_name(name, indexable->path);
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,
250 int height = asset->height > 0 ? asset->height : 1;
251 pixmap_w = pixmap_h * asset->width / height;
254 file->set_video_position(0, 0);
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;
263 if( !gui->temp_picon ) {
264 gui->temp_picon = new VFrame(0, -1,
265 asset->width, asset->height,
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);
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 ) {
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);
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];
303 icon = gui->video_icon;
304 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
308 if( asset->audio_data ) {
309 icon = gui->audio_icon;
310 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND];
315 if( indexable && !indexable->is_asset ) {
316 icon = gui->video_icon;
317 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
321 set_text(strcpy(name, edl->local_session->clip_title));
322 icon = gui->clip_icon;
323 icon_vframe = mwindow->theme->get_image("clip_icon");
327 strcpy(name, plugin->title);
329 icon_vframe = plugin->get_picon();
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;
337 else if( plugin->is_ffmpeg() ) {
338 icon = gui->ff_aud_icon;
339 icon_vframe = gui->ff_aud_vframe;
341 else if( plugin->is_ladspa() ) {
342 icon = gui->ladspa_icon;
343 icon_vframe = gui->ladspa_vframe;
346 icon = gui->aeffect_icon;
347 icon_vframe = gui->aeffect_vframe;
350 else if( plugin->video ) {
351 if( plugin->transition ) {
352 icon = gui->vtransition_icon;
353 icon_vframe = gui->vtransition_vframe;
355 else if( plugin->is_ffmpeg() ) {
356 icon = gui->ff_vid_icon;
357 icon_vframe = gui->ff_vid_vframe;
360 icon = gui->veffect_icon;
361 icon_vframe = gui->veffect_vframe;
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);
374 icon = gui->label_icon;
375 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_LABEL];
377 set_icon_vframe(icon_vframe);
380 icon = gui->file_icon;
381 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
384 set_icon_vframe(icon_vframe);
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,
393 this->mwindow = mwindow;
394 this->awindow = awindow;
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;
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;
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;
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;
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;
429 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
430 newfolder_thread = 0;
438 allow_iconlisting = 1;
442 displayed_folder = AW_NO_FOLDER;
445 AWindowGUI::~AWindowGUI()
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();
457 delete newfolder_thread;
462 delete effectlist_menu;
463 delete assetlist_menu;
464 delete cliplist_menu;
465 delete labellist_menu;
466 delete folderlist_menu;
468 delete remove_plugin;
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;
493 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
495 return icon == file_icon ||
496 icon == folder_icon ||
497 icon == audio_icon ||
498 icon == video_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;
518 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
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);
527 VFrame *AWindowGUI::get_picon(const char *name)
529 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
530 if( !vframe ) vframe = get_picon(name, DEFAULT_PICON);
534 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
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);
540 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
542 vfrm = get_picon(fn);
543 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
544 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
546 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
548 vfrm = get_picon(fn);
549 if( !vfrm ) vfrm = new VFramePng(png);
550 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
553 void AWindowGUI::create_objects()
555 lock_window("AWindowGUI::create_objects");
556 asset_titles[0] = _("Title");
557 asset_titles[1] = _("Comments");
559 set_icon(mwindow->theme->get_image("awindow_icon"));
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);
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");
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;
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");
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);
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));
605 create_label_folder();
607 mwindow->theme->get_awindow_sizes(this);
608 load_defaults(mwindow->defaults);
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));
614 vicon_thread = new VIconThread(asset_list);
615 vicon_thread->start();
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));
621 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
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));
635 //int x = mwindow->theme->abuttons_x;
636 //int y = mwindow->theme->abuttons_y;
639 newfolder_thread = new NewFolderThread(mwindow, this);
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();
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();
657 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
658 folderlist_menu->create_objects();
660 create_custom_xatoms();
664 int AWindowGUI::resize_event(int w, int h)
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;
671 mwindow->theme->get_awindow_sizes(this);
672 mwindow->theme->draw_awindow_bg(this);
673 reposition_objects();
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);
697 BC_WindowBase::resize_event(w, h);
701 int AWindowGUI::translation_event()
703 mwindow->session->awindow_x = get_x();
704 mwindow->session->awindow_y = get_y();
708 void AWindowGUI::reposition_objects()
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);
724 int AWindowGUI::save_defaults(BC_Hash *defaults)
726 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
727 defaults->update("VICON_DRAWING", vicon_drawing);
731 int AWindowGUI::load_defaults(BC_Hash *defaults)
733 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
734 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
738 int AWindowGUI::close_event()
741 mwindow->session->show_awindow = 0;
744 mwindow->gui->lock_window("AWindowGUI::close_event");
745 mwindow->gui->mainmenu->show_awindow->set_checked(0);
746 mwindow->gui->unlock_window();
748 lock_window("AWindowGUI::close_event");
749 save_defaults(mwindow->defaults);
750 mwindow->save_defaults();
754 void AWindowGUI::start_vicon_drawing()
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();
762 void AWindowGUI::stop_vicon_drawing()
764 vicon_thread->stop_drawing();
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)
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));
780 AWindowRemovePluginGUI::
781 ~AWindowRemovePluginGUI()
783 if( !awindow->gui->protected_pixmap(icon) )
785 plugin_list.remove_all();
788 void AWindowRemovePluginGUI::create_objects()
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);
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);
805 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
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);
820 void AWindowRemovePlugin::handle_close_event(int 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 :
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);
838 char index_path[BCTEXTLEN];
839 snprintf(index_path, sizeof(index_path), "%s/%s",
840 mwindow->preferences->plugin_dir, PLUGIN_FILE);
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) )
854 delete plugin; plugin = 0;
855 awindow->gui->async_update_assets();
859 AWindowRemovePlugin::
860 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
863 this->awindow = awindow;
864 this->plugin = plugin;
867 AWindowRemovePlugin::
868 ~AWindowRemovePlugin()
873 BC_Window* AWindowRemovePlugin::new_gui()
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();
882 int AWindowGUI::keypress_event()
884 switch( get_keypress() ) {
893 PluginServer* plugin = selected_plugin();
895 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
897 remove_plugin->start();
906 int AWindowGUI::create_custom_xatoms()
908 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
911 int AWindowGUI::recieve_custom_xatoms(xatom_event *event)
913 if( event->message_type == UpdateAssetsXAtom ) {
920 void AWindowGUI::async_update_assets()
923 event.message_type = UpdateAssetsXAtom;
924 send_custom_xatom(&event);
928 void AWindowGUI::update_folder_list()
930 stop_vicon_drawing();
931 for( int i = 0; i < folders.total; i++ ) {
932 AssetPicon *picon = (AssetPicon*)folders.values[i];
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];
941 for( int j = 0; j < folders.total; j++ ) {
942 AssetPicon *picon = (AssetPicon*)folders.values[j];
943 if( !strcasecmp(picon->get_text(), folder) ) {
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);
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 ) {
965 folders.remove_number(i);
969 start_vicon_drawing();
972 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
973 int do_audio, int do_video, int is_realtime, int is_transition)
975 ArrayList<PluginServer*> plugin_list;
976 // Get pointers to plugindb entries
977 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
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);
991 void AWindowGUI::create_label_folder()
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);
1002 void AWindowGUI::update_asset_list()
1004 for( int i = 0; i < assets.total; i++ ) {
1005 AssetPicon *picon = (AssetPicon*)assets.values[i];
1009 // Synchronize EDL clips
1010 for( int i = 0; i < mwindow->edl->clips.total; i++ ) {
1013 // Look for clip in existing listitems
1014 for( int j = 0; j < assets.total && !exists; j++ ) {
1015 AssetPicon *picon = (AssetPicon*)assets.values[j];
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);
1025 // Create new listitem
1027 AssetPicon *picon = new AssetPicon(mwindow,
1028 this, mwindow->edl->clips.values[i]);
1029 picon->create_objects();
1030 assets.append(picon);
1034 // Synchronize EDL assets
1035 for( Asset *current = mwindow->edl->assets->first;
1040 // Look for asset in existing listitems
1041 for( int j = 0; j < assets.total && !exists; j++ ) {
1042 AssetPicon *picon = (AssetPicon*)assets.values[j];
1044 if( picon->id == current->id ) {
1045 picon->indexable = current;
1052 // Create new listitem
1054 AssetPicon *picon = new AssetPicon(mwindow,
1056 picon->create_objects();
1057 assets.append(picon);
1061 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1062 mwindow->gui->default_message();
1063 mwindow->gui->unlock_window();
1065 // Synchronize nested EDLs
1066 for( int i = 0; i < mwindow->edl->nested_edls->size(); i++ ) {
1068 Indexable *indexable = mwindow->edl->nested_edls->get(i);
1070 // Look for asset in existing listitems
1071 for( int j = 0; j < assets.total && !exists; j++ ) {
1072 AssetPicon *picon = (AssetPicon*)assets.values[j];
1074 if( picon->id == indexable->id ) {
1075 picon->indexable = indexable;
1082 // Create new listitem
1084 AssetPicon *picon = new AssetPicon(mwindow,
1086 picon->create_objects();
1087 assets.append(picon);
1091 for( int i = assets.size() - 1; i >= 0; i-- ) {
1092 AssetPicon *picon = (AssetPicon*)assets.get(i);
1093 if( !picon->in_use ) {
1095 assets.remove_number(i);
1100 void AWindowGUI::update_picon(Indexable *indexable)
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];
1109 fs.extract_name(name, indexable->path);
1110 picon->set_text(name);
1111 vicon = picon->vicon;
1116 stop_vicon_drawing();
1117 vicon->clear_images();
1118 vicon->reset(indexable->get_frame_rate());
1119 start_vicon_drawing();
1123 void AWindowGUI::sort_assets()
1125 switch( mwindow->edl->session->awindow_folder ) {
1126 case AW_AEFFECT_FOLDER:
1127 sort_picons(&aeffects);
1129 case AW_VEFFECT_FOLDER:
1130 sort_picons(&veffects);
1132 case AW_ATRANSITION_FOLDER:
1133 sort_picons(&atransitions);
1135 case AW_VTRANSITION_FOLDER:
1136 sort_picons(&vtransitions);
1138 case AW_LABEL_FOLDER:
1139 sort_picons(&labellist);
1142 sort_picons(&assets);
1145 asset_list->update_format(asset_list->get_format(), 0);
1149 void AWindowGUI::sort_folders()
1151 sort_picons(&folders);
1152 folder_list->update_format(folder_list->get_format(), 0);
1156 void AWindowGUI::collect_assets()
1159 mwindow->session->drag_assets->remove_all();
1160 mwindow->session->drag_clips->remove_all();
1163 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
1164 if( !result ) break;
1166 if( result->indexable ) mwindow->session->drag_assets->append(result->indexable);
1167 if( result->edl ) mwindow->session->drag_clips->append(result->edl);
1171 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
1172 ArrayList<BC_ListBoxItem*> *src, int folder)
1174 // Remove current pointers
1175 dst[0].remove_all();
1176 dst[1].remove_all_objects();
1178 // Create new pointers
1179 for( int i = 0; i < src->total; i++ ) {
1180 AssetPicon *picon = (AssetPicon*)src->values[i];
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);
1187 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1189 if( picon->label && picon->label->textstr )
1190 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1192 dst[1].append(item2 = new BC_ListBoxItem(""));
1193 item1->set_autoplace_text(1);
1194 item2->set_autoplace_text(1);
1199 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
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;
1222 void AWindowGUI::filter_displayed_assets()
1224 //allow_iconlisting = 1;
1225 asset_titles[0] = _("Title");
1226 asset_titles[1] = _("Comments");
1228 switch( mwindow->edl->session->awindow_folder ) {
1229 case AW_AEFFECT_FOLDER:
1230 copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
1232 case AW_VEFFECT_FOLDER:
1233 copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
1235 case AW_ATRANSITION_FOLDER:
1236 copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
1238 case AW_VTRANSITION_FOLDER:
1239 copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
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;
1248 copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
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);
1262 void AWindowGUI::update_assets()
1264 update_folder_list();
1265 update_asset_list();
1266 labellist.remove_all_objects();
1267 create_label_folder();
1268 filter_displayed_assets();
1270 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
1271 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
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);
1277 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
1278 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
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;
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();
1295 void AWindowGUI::update_effects()
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);
1307 int AWindowGUI::folder_number(const char *name)
1309 for( int i = 0; i < AWINDOW_FOLDERS; i++ ) {
1310 if( !strcasecmp(name, folder_names[i]) ) return i;
1312 return AW_NO_FOLDER;
1315 int AWindowGUI::drag_motion()
1317 if( get_hidden() ) return 0;
1323 int AWindowGUI::drag_stop()
1325 if( get_hidden() ) return 0;
1330 Indexable* AWindowGUI::selected_asset()
1332 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1333 return picon ? picon->indexable : 0;
1336 PluginServer* AWindowGUI::selected_plugin()
1338 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1339 return picon ? picon->plugin : 0;
1342 AssetPicon* AWindowGUI::selected_folder()
1344 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1355 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1356 : BC_SubWindow(x, y, w, h)
1358 this->mwindow = mwindow;
1361 AWindowDivider::~AWindowDivider()
1365 int AWindowDivider::button_press_event()
1367 if( is_event_win() && cursor_inside() ) {
1368 mwindow->session->current_operation = DRAG_PARTITION;
1374 int AWindowDivider::cursor_motion_event()
1376 if( mwindow->session->current_operation == DRAG_PARTITION ) {
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();
1390 int AWindowDivider::button_release_event()
1392 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1393 mwindow->session->current_operation = NO_OPERATION;
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
1418 this->mwindow = mwindow;
1423 AWindowFolders::~AWindowFolders()
1427 int AWindowFolders::selection_changed()
1429 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1431 gui->stop_vicon_drawing();
1433 if( get_button_down() && get_buttonpress() == 3 ) {
1434 gui->folderlist_menu->update_titles();
1435 gui->folderlist_menu->activate_menu();
1438 mwindow->edl->session->awindow_folder = picon->foldernum;
1439 gui->asset_list->draw_background();
1440 gui->async_update_assets();
1442 gui->start_vicon_drawing();
1447 int AWindowFolders::button_press_event()
1451 result = BC_ListBox::button_press_event();
1454 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1455 gui->folderlist_menu->update_titles();
1456 gui->folderlist_menu->activate_menu();
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
1485 this->mwindow = mwindow;
1488 set_scroll_stretch(1, 1);
1491 AWindowAssets::~AWindowAssets()
1495 int AWindowAssets::button_press_event()
1499 result = BC_ListBox::button_press_event();
1501 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1502 BC_ListBox::deactivate_selection();
1503 int folder = mwindow->edl->session->awindow_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();
1512 case AW_LABEL_FOLDER:
1513 gui->labellist_menu->update();
1514 gui->labellist_menu->activate_menu();
1516 case AW_CLIP_FOLDER:
1517 gui->cliplist_menu->update();
1518 gui->cliplist_menu->activate_menu();
1520 case AW_MEDIA_FOLDER:
1521 case AW_PROXY_FOLDER:
1522 gui->assetlist_menu->update_titles();
1523 gui->assetlist_menu->activate_menu();
1533 int AWindowAssets::handle_event()
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;
1543 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1544 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1545 if( !vwindow || !vwindow->is_running() ) return 1;
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();
1556 int AWindowAssets::selection_changed()
1558 // Show popup window
1560 if( get_button_down() && get_buttonpress() == 3 &&
1561 (item = (AssetPicon*)get_selection(0, 0)) ) {
1562 int folder = mwindow->edl->session->awindow_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();
1571 case AW_LABEL_FOLDER:
1572 if( !item->label ) break;
1573 gui->label_menu->activate_menu();
1575 case AW_CLIP_FOLDER:
1576 if( !item->indexable && !item->edl ) break;
1577 gui->clip_menu->update();
1578 gui->clip_menu->activate_menu();
1581 if( !item->indexable && !item->edl ) break;
1582 gui->asset_menu->update();
1583 gui->asset_menu->activate_menu();
1587 BC_ListBox::deactivate_selection();
1590 else if( get_button_down() && get_buttonpress() == 1 &&
1591 (item = (AssetPicon*)get_selection(0, 0)) ) {
1593 if( !gui->vicon_thread->viewing ) {
1594 vicon = item->vicon;
1596 gui->vicon_thread->set_view_popup(vicon);
1602 void AWindowAssets::draw_background()
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());
1614 int AWindowAssets::drag_start_event()
1616 int collect_pluginservers = 0;
1617 int collect_assets = 0;
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;
1625 case AW_VEFFECT_FOLDER:
1626 mwindow->session->current_operation = DRAG_VEFFECT;
1627 collect_pluginservers = 1;
1629 case AW_ATRANSITION_FOLDER:
1630 mwindow->session->current_operation = DRAG_ATRANSITION;
1631 collect_pluginservers = 1;
1633 case AW_VTRANSITION_FOLDER:
1634 mwindow->session->current_operation = DRAG_VTRANSITION;
1635 collect_pluginservers = 1;
1637 case AW_LABEL_FOLDER:
1641 mwindow->session->current_operation = DRAG_ASSET;
1646 if( collect_pluginservers ) {
1648 mwindow->session->drag_pluginservers->remove_all();
1651 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
1652 if( !result ) break;
1654 mwindow->session->drag_pluginservers->append(result->plugin);
1658 if( collect_assets ) {
1659 gui->collect_assets();
1667 int AWindowAssets::drag_motion_event()
1669 BC_ListBox::drag_motion_event();
1672 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1673 mwindow->gui->drag_motion();
1674 mwindow->gui->unlock_window();
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();
1684 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1685 mwindow->cwindow->gui->drag_motion();
1686 mwindow->cwindow->gui->unlock_window();
1688 lock_window("AWindowAssets::drag_motion_event");
1692 int AWindowAssets::drag_stop_event()
1696 result = gui->drag_stop();
1701 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1702 result = mwindow->gui->drag_stop();
1703 mwindow->gui->unlock_window();
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();
1717 vwindow->gui->unlock_window();
1722 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1723 result = mwindow->cwindow->gui->drag_stop();
1724 mwindow->cwindow->gui->unlock_window();
1727 lock_window("AWindowAssets::drag_stop_event");
1729 if( result ) get_drag_popup()->set_animation(0);
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...
1736 int AWindowAssets::column_resize_event()
1738 mwindow->edl->session->asset_columns[0] = get_column_width(0);
1739 mwindow->edl->session->asset_columns[1] = get_column_width(1);
1743 int AWindowAssets::focus_in_event()
1745 gui->start_vicon_drawing();
1749 int AWindowAssets::focus_out_event()
1751 gui->stop_vicon_drawing();
1752 return BC_ListBox::focus_out_event();
1766 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1767 : BC_Button(x, y, mwindow->theme->newbin_data)
1769 this->mwindow = mwindow;
1771 set_tooltip(_("New bin"));
1774 int AWindowNewFolder::handle_event()
1776 gui->newfolder_thread->start_new_folder();
1780 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1781 : BC_Button(x, y, mwindow->theme->deletebin_data)
1783 this->mwindow = mwindow;
1785 set_tooltip(_("Delete bin"));
1788 int AWindowDeleteFolder::handle_event()
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());
1797 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1798 : BC_Button(x, y, mwindow->theme->renamebin_data)
1800 this->mwindow = mwindow;
1802 set_tooltip(_("Rename bin"));
1805 int AWindowRenameFolder::handle_event()
1810 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1811 : BC_Button(x, y, mwindow->theme->deletedisk_data)
1813 this->mwindow = mwindow;
1815 set_tooltip(_("Delete asset from disk"));
1818 int AWindowDeleteDisk::handle_event()
1823 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1824 : BC_Button(x, y, mwindow->theme->deleteproject_data)
1826 this->mwindow = mwindow;
1828 set_tooltip(_("Delete asset from project"));
1831 int AWindowDeleteProject::handle_event()
1836 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1837 // : BC_Button(x, y, mwindow->theme->infoasset_data)
1839 // this->mwindow = mwindow;
1841 // set_tooltip(_("Edit information on asset"));
1844 // int AWindowInfo::handle_event()
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);
1852 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1853 : BC_Button(x, y, mwindow->theme->redrawindex_data)
1855 this->mwindow = mwindow;
1857 set_tooltip(_("Redraw index"));
1860 int AWindowRedrawIndex::handle_event()
1865 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1866 : BC_Button(x, y, mwindow->theme->pasteasset_data)
1868 this->mwindow = mwindow;
1870 set_tooltip(_("Paste asset on recordable tracks"));
1873 int AWindowPaste::handle_event()
1878 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1879 : BC_Button(x, y, mwindow->theme->appendasset_data)
1881 this->mwindow = mwindow;
1883 set_tooltip(_("Append asset in new tracks"));
1886 int AWindowAppend::handle_event()
1891 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1892 : BC_Button(x, y, mwindow->theme->viewasset_data)
1894 this->mwindow = mwindow;
1896 set_tooltip(_("View asset"));
1899 int AWindowView::handle_event()
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)
1907 this->mwindow = mwindow;
1911 void AddTools::create_objects()
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;
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));
1935 // plugin_dirs list from toplevel makefile include plugin_defs
1939 N_("audio_transitions")
1946 N_("video_transitions")
1949 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
1950 : BC_MenuItem(_(text))
1954 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
1955 int chk = (msk & vis) ? 1 : 0;
1959 int AddPluginItem::handle_event()
1961 int chk = get_checked() ^ 1;
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();
1971 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
1972 : BC_Toggle(x, y, images, agui->vicon_drawing)
1975 set_tooltip(_("draw vicons"));
1978 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
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);
1987 AVIconDrawing::~AVIconDrawing()
1991 int AVIconDrawing::handle_event()
1993 agui->vicon_drawing = get_value();
1994 if( agui->vicon_drawing )
1995 agui->start_vicon_drawing();
1997 agui->stop_vicon_drawing();
2002 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
2005 this->mwindow = mwindow;
2009 int AWindowListFormat::handle_event()
2011 gui->stop_vicon_drawing();
2013 EDLSession *session = mwindow->edl->session;
2014 switch( session->assetlist_format ) {
2016 session->assetlist_format = ASSETS_ICONS;
2019 session->assetlist_format = ASSETS_TEXT;
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;
2028 gui->start_vicon_drawing();
2032 void AWindowListFormat::update()
2034 set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
2035 (char*)_("Display icons") : (char*)_("Display text"));
2038 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
2039 : BC_MenuItem(_("Sort items"))
2041 this->mwindow = mwindow;
2045 int AWindowListSort::handle_event()