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;
401 atransition_icon = 0; atransition_vframe = 0;
402 vtransition_icon = 0; vtransition_vframe = 0;
403 aeffect_icon = 0; aeffect_vframe = 0;
404 ladspa_icon = 0; ladspa_vframe = 0;
405 veffect_icon = 0; veffect_vframe = 0;
406 ff_aud_icon = 0; ff_aud_vframe = 0;
407 ff_vid_icon = 0; ff_vid_vframe = 0;
408 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
409 newfolder_thread = 0;
417 allow_iconlisting = 1;
421 displayed_folder = AW_NO_FOLDER;
424 AWindowGUI::~AWindowGUI()
426 assets.remove_all_objects();
427 folders.remove_all_objects();
428 aeffects.remove_all_objects();
429 veffects.remove_all_objects();
430 atransitions.remove_all_objects();
431 vtransitions.remove_all_objects();
432 labellist.remove_all_objects();
433 displayed_assets[1].remove_all_objects();
442 delete atransition_icon;
443 delete vtransition_icon;
449 delete newfolder_thread;
453 delete effectlist_menu;
454 delete assetlist_menu;
455 delete cliplist_menu;
456 delete labellist_menu;
457 delete folderlist_menu;
459 delete remove_plugin;
462 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
464 return icon == file_icon ||
465 icon == folder_icon ||
466 icon == audio_icon ||
467 icon == video_icon ||
469 icon == label_icon ||
470 icon == vtransition_icon ||
471 icon == atransition_icon ||
472 icon == veffect_icon ||
473 icon == aeffect_icon ||
474 icon == ladspa_icon ||
475 icon == ff_aud_icon ||
476 icon == ff_vid_icon ||
477 icon == aeffect_folder_icon ||
478 icon == veffect_folder_icon ||
479 icon == atransition_folder_icon ||
480 icon == vtransition_folder_icon ||
481 icon == label_folder_icon ||
482 icon == clip_folder_icon ||
483 icon == media_folder_icon ||
484 icon == proxy_folder_icon;
487 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
489 char png_path[BCTEXTLEN];
490 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
491 snprintf(pp, ep-pp, "%s/picon_%s/%s.png",
492 File::get_plugin_path(), plugin_icons, name);
493 return VFramePng::vframe_png(png_path,0,0);
496 VFrame *AWindowGUI::get_picon(const char *name)
498 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
499 if( !vframe ) vframe = get_picon(name, DEFAULT_PICON);
503 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
505 vfrm = get_picon(fn);
506 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
507 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
509 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
511 vfrm = get_picon(fn);
512 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
513 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
515 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
517 vfrm = get_picon(fn);
518 if( !vfrm ) vfrm = new VFramePng(png);
519 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
522 void AWindowGUI::create_objects()
524 lock_window("AWindowGUI::create_objects");
525 asset_titles[0] = _("Title");
526 asset_titles[1] = _("Comments");
528 set_icon(mwindow->theme->get_image("awindow_icon"));
530 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
531 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
532 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
533 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
534 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
536 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
537 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
538 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
539 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
540 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
541 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
542 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
543 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
545 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
546 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
547 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
548 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
549 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
550 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
551 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
552 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
554 theme_icon(clip_vframe, clip_icon, "clip_icon");
555 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
556 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
557 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
558 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
560 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
561 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
562 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
565 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
566 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
567 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
568 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
569 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
570 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
571 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
572 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
574 create_label_folder();
576 mwindow->theme->get_awindow_sizes(this);
577 load_defaults(mwindow->defaults);
579 add_subwindow(asset_list = new AWindowAssets(mwindow,
581 mwindow->theme->alist_x,
582 mwindow->theme->alist_y,
583 mwindow->theme->alist_w,
584 mwindow->theme->alist_h));
586 vicon_thread = new VIconThread(asset_list);
587 vicon_thread->start();
589 add_subwindow(divider = new AWindowDivider(mwindow,
591 mwindow->theme->adivider_x,
592 mwindow->theme->adivider_y,
593 mwindow->theme->adivider_w,
594 mwindow->theme->adivider_h));
596 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
598 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
599 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
600 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
601 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
602 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
603 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
604 add_tools->create_objects();
605 fy += add_tools->get_h(); fh -= add_tools->get_h();
606 add_subwindow(folder_list = new AWindowFolders(mwindow,
607 this, fx, fy, fw, fh));
610 //int x = mwindow->theme->abuttons_x;
611 //int y = mwindow->theme->abuttons_y;
614 newfolder_thread = new NewFolderThread(mwindow, this);
616 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
617 asset_menu->create_objects();
618 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
619 clip_menu->create_objects();
620 add_subwindow(label_menu = new LabelPopup(mwindow, this));
621 label_menu->create_objects();
623 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
624 effectlist_menu->create_objects();
625 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
626 assetlist_menu->create_objects();
627 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
628 cliplist_menu->create_objects();
629 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
630 labellist_menu->create_objects();
632 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
633 folderlist_menu->create_objects();
635 create_custom_xatoms();
639 int AWindowGUI::resize_event(int w, int h)
641 mwindow->session->awindow_x = get_x();
642 mwindow->session->awindow_y = get_y();
643 mwindow->session->awindow_w = w;
644 mwindow->session->awindow_h = h;
646 mwindow->theme->get_awindow_sizes(this);
647 mwindow->theme->draw_awindow_bg(this);
648 reposition_objects();
650 // int x = mwindow->theme->abuttons_x;
651 // int y = mwindow->theme->abuttons_y;
652 // new_bin->reposition_window(x, y);
653 // x += new_bin->get_w();
654 // delete_bin->reposition_window(x, y);
655 // x += delete_bin->get_w();
656 // rename_bin->reposition_window(x, y);
657 // x += rename_bin->get_w();
658 // delete_disk->reposition_window(x, y);
659 // x += delete_disk->get_w();
660 // delete_project->reposition_window(x, y);
661 // x += delete_project->get_w();
662 // info->reposition_window(x, y);
663 // x += info->get_w();
664 // redraw_index->reposition_window(x, y);
665 // x += redraw_index->get_w();
666 // paste->reposition_window(x, y);
667 // x += paste->get_w();
668 // append->reposition_window(x, y);
669 // x += append->get_w();
670 // view->reposition_window(x, y);
672 BC_WindowBase::resize_event(w, h);
676 int AWindowGUI::translation_event()
678 mwindow->session->awindow_x = get_x();
679 mwindow->session->awindow_y = get_y();
683 void AWindowGUI::reposition_objects()
685 asset_list->reposition_window(
686 mwindow->theme->alist_x, mwindow->theme->alist_y,
687 mwindow->theme->alist_w, mwindow->theme->alist_h);
688 divider->reposition_window(
689 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
690 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
691 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
692 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
693 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
694 avicon_drawing->reposition_window(fw-avicon_w, fy);
695 fy += add_tools->get_h(); fh -= add_tools->get_h();
696 folder_list->reposition_window(fx, fy, fw, fh);
699 int AWindowGUI::save_defaults(BC_Hash *defaults)
701 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
702 defaults->update("VICON_DRAWING", vicon_drawing);
706 int AWindowGUI::load_defaults(BC_Hash *defaults)
708 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
709 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
713 int AWindowGUI::close_event()
716 mwindow->session->show_awindow = 0;
719 mwindow->gui->lock_window("AWindowGUI::close_event");
720 mwindow->gui->mainmenu->show_awindow->set_checked(0);
721 mwindow->gui->unlock_window();
723 lock_window("AWindowGUI::close_event");
724 save_defaults(mwindow->defaults);
725 mwindow->save_defaults();
729 void AWindowGUI::start_vicon_drawing()
731 if( !vicon_drawing ) return;
732 if( mwindow->edl->session->awindow_folder != AW_MEDIA_FOLDER ) return;
733 if( mwindow->edl->session->assetlist_format != ASSETS_ICONS ) return;
734 vicon_thread->start_drawing();
737 void AWindowGUI::stop_vicon_drawing()
739 vicon_thread->stop_drawing();
742 AWindowRemovePluginGUI::
743 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
744 int x, int y, PluginServer *plugin)
745 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
747 this->awindow = awindow;
748 this->thread = thread;
749 this->plugin = plugin;
750 VFrame *vframe = plugin->get_picon();
751 icon = vframe ? create_pixmap(vframe) : 0;
752 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
755 AWindowRemovePluginGUI::
756 ~AWindowRemovePluginGUI()
758 if( !awindow->gui->protected_pixmap(icon) )
760 plugin_list.remove_all();
763 void AWindowRemovePluginGUI::create_objects()
765 BC_Button *ok_button = new BC_OKButton(this);
766 add_subwindow(ok_button);
767 BC_Button *cancel_button = new BC_CancelButton(this);
768 add_subwindow(cancel_button);
770 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
771 add_subwindow(title);
772 y += title->get_h() + 5;
773 list = new BC_ListBox(x, y,
774 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
775 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
780 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
783 for( int i=0; i<folder.size(); ) {
784 AssetPicon *picon = (AssetPicon *)folder[i];
785 if( picon->plugin == plugin ) {
786 folder.remove_object_number(i);
795 void AWindowRemovePlugin::handle_close_event(int result)
798 printf(_("remove %s\n"), plugin->path);
799 ArrayList<BC_ListBoxItem*> *folder =
800 plugin->audio ? plugin->transition ?
801 &awindow->gui->atransitions :
802 &awindow->gui->aeffects :
803 plugin->video ? plugin->transition ?
804 &awindow->gui->vtransitions :
805 &awindow->gui->veffects :
807 if( folder ) remove_plugin(plugin, *folder);
808 char plugin_path[BCTEXTLEN];
809 strcpy(plugin_path, plugin->path);
810 MWindow *mwindow = awindow->mwindow;
811 mwindow->plugindb->remove(plugin);
813 char index_path[BCTEXTLEN];
814 snprintf(index_path, sizeof(index_path), "%s/%s",
815 mwindow->preferences->plugin_dir, PLUGIN_FILE);
818 fs.update(File::get_plugin_path());
819 for( int i=0; i<fs.dir_list.total; ++i ) {
820 char *fs_path = fs.dir_list[i]->path;
821 if( !fs.is_dir(fs_path) ) continue;
822 char *cp = strrchr(fs_path,'/');
823 cp = !cp ? fs_path : cp+1;
824 if( strncmp("picon_", cp, 6) ) continue;
825 char png_path[BCTEXTLEN];
826 if( !plugin->get_plugin_png_path(png_path, cp+6) )
829 delete plugin; plugin = 0;
830 awindow->gui->async_update_assets();
834 AWindowRemovePlugin::
835 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
838 this->awindow = awindow;
839 this->plugin = plugin;
842 AWindowRemovePlugin::
843 ~AWindowRemovePlugin()
848 BC_Window* AWindowRemovePlugin::new_gui()
850 int x = awindow->gui->get_abs_cursor_x(0);
851 int y = awindow->gui->get_abs_cursor_y(0);
852 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
853 gui->create_objects();
857 int AWindowGUI::keypress_event()
859 switch( get_keypress() ) {
868 PluginServer* plugin = selected_plugin();
870 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
872 remove_plugin->start();
881 int AWindowGUI::create_custom_xatoms()
883 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
886 int AWindowGUI::recieve_custom_xatoms(xatom_event *event)
888 if( event->message_type == UpdateAssetsXAtom ) {
895 void AWindowGUI::async_update_assets()
898 event.message_type = UpdateAssetsXAtom;
899 send_custom_xatom(&event);
903 void AWindowGUI::update_folder_list()
905 stop_vicon_drawing();
906 for( int i = 0; i < folders.total; i++ ) {
907 AssetPicon *picon = (AssetPicon*)folders.values[i];
911 // Search assets for folders
912 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
913 const char *folder = mwindow->edl->folders.values[i];
916 for( int j = 0; j < folders.total; j++ ) {
917 AssetPicon *picon = (AssetPicon*)folders.values[j];
918 if( !strcasecmp(picon->get_text(), folder) ) {
926 int aw_folder = folder_number(folder);
927 if( aw_folder >= 0 ) {
928 AssetPicon *picon = new AssetPicon(mwindow, this, aw_folder, 1);
929 picon->create_objects();
930 folders.append(picon);
935 // Delete unused non-persistent folders
936 for( int i=folders.total; --i>=0; ) {
937 AssetPicon *picon = (AssetPicon*)folders.values[i];
938 if( !picon->in_use && !picon->persistent ) {
940 folders.remove_number(i);
944 start_vicon_drawing();
947 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
948 int do_audio, int do_video, int is_realtime, int is_transition)
950 ArrayList<PluginServer*> plugin_list;
951 // Get pointers to plugindb entries
952 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
955 for( int i = 0; i < plugin_list.total; i++ ) {
956 PluginServer *server = plugin_list.values[i];
957 int visible = plugin_visibility & (1<<server->dir_idx);
958 if( !visible ) continue;
959 // Create new listitem
960 AssetPicon *picon = new AssetPicon(mwindow, this, server);
961 picon->create_objects();
962 output->append(picon);
966 void AWindowGUI::create_label_folder()
969 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
970 AssetPicon *picon = new AssetPicon(mwindow, this, current);
971 picon->create_objects();
972 labellist.append(picon);
977 void AWindowGUI::update_asset_list()
979 for( int i = 0; i < assets.total; i++ ) {
980 AssetPicon *picon = (AssetPicon*)assets.values[i];
984 // Synchronize EDL clips
985 for( int i = 0; i < mwindow->edl->clips.total; i++ ) {
988 // Look for clip in existing listitems
989 for( int j = 0; j < assets.total && !exists; j++ ) {
990 AssetPicon *picon = (AssetPicon*)assets.values[j];
992 if( picon->id == mwindow->edl->clips.values[i]->id ) {
993 picon->edl = mwindow->edl->clips.values[i];
994 picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title);
1000 // Create new listitem
1002 AssetPicon *picon = new AssetPicon(mwindow,
1003 this, mwindow->edl->clips.values[i]);
1004 picon->create_objects();
1005 assets.append(picon);
1009 // Synchronize EDL assets
1010 for( Asset *current = mwindow->edl->assets->first;
1015 // Look for asset in existing listitems
1016 for( int j = 0; j < assets.total && !exists; j++ ) {
1017 AssetPicon *picon = (AssetPicon*)assets.values[j];
1019 if( picon->id == current->id ) {
1020 picon->indexable = current;
1027 // Create new listitem
1029 AssetPicon *picon = new AssetPicon(mwindow,
1031 picon->create_objects();
1032 assets.append(picon);
1036 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1037 mwindow->gui->default_message();
1038 mwindow->gui->unlock_window();
1040 // Synchronize nested EDLs
1041 for( int i = 0; i < mwindow->edl->nested_edls->size(); i++ ) {
1043 Indexable *indexable = mwindow->edl->nested_edls->get(i);
1045 // Look for asset in existing listitems
1046 for( int j = 0; j < assets.total && !exists; j++ ) {
1047 AssetPicon *picon = (AssetPicon*)assets.values[j];
1049 if( picon->id == indexable->id ) {
1050 picon->indexable = indexable;
1057 // Create new listitem
1059 AssetPicon *picon = new AssetPicon(mwindow,
1061 picon->create_objects();
1062 assets.append(picon);
1066 for( int i = assets.size() - 1; i >= 0; i-- ) {
1067 AssetPicon *picon = (AssetPicon*)assets.get(i);
1068 if( !picon->in_use ) {
1070 assets.remove_number(i);
1075 void AWindowGUI::update_picon(Indexable *indexable)
1078 for( int i = 0; i < assets.total; i++ ) {
1079 AssetPicon *picon = (AssetPicon*)assets.values[i];
1080 if( picon->indexable == indexable ||
1081 picon->edl == (EDL *)indexable ) {
1082 char name[BCTEXTLEN];
1084 fs.extract_name(name, indexable->path);
1085 picon->set_text(name);
1086 vicon = picon->vicon;
1091 stop_vicon_drawing();
1092 vicon->clear_images();
1093 vicon->reset(indexable->get_frame_rate());
1094 start_vicon_drawing();
1098 void AWindowGUI::sort_assets()
1100 switch( mwindow->edl->session->awindow_folder ) {
1101 case AW_AEFFECT_FOLDER:
1102 sort_picons(&aeffects);
1104 case AW_VEFFECT_FOLDER:
1105 sort_picons(&veffects);
1107 case AW_ATRANSITION_FOLDER:
1108 sort_picons(&atransitions);
1110 case AW_VTRANSITION_FOLDER:
1111 sort_picons(&vtransitions);
1113 case AW_LABEL_FOLDER:
1114 sort_picons(&labellist);
1117 sort_picons(&assets);
1123 void AWindowGUI::sort_folders()
1125 sort_picons(&folders);
1129 void AWindowGUI::collect_assets()
1132 mwindow->session->drag_assets->remove_all();
1133 mwindow->session->drag_clips->remove_all();
1136 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
1137 if( !result ) break;
1139 if( result->indexable ) mwindow->session->drag_assets->append(result->indexable);
1140 if( result->edl ) mwindow->session->drag_clips->append(result->edl);
1144 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
1145 ArrayList<BC_ListBoxItem*> *src, int folder)
1147 // Remove current pointers
1148 dst[0].remove_all();
1149 dst[1].remove_all_objects();
1151 // Create new pointers
1152 for( int i = 0; i < src->total; i++ ) {
1153 AssetPicon *picon = (AssetPicon*)src->values[i];
1155 (picon->indexable && picon->indexable->awindow_folder == folder) ||
1156 (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
1157 BC_ListBoxItem *item2, *item1;
1158 dst[0].append(item1 = picon);
1160 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1162 if( picon->label && picon->label->textstr )
1163 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1165 dst[1].append(item2 = new BC_ListBoxItem(""));
1166 item1->set_autoplace_text(1);
1167 item2->set_autoplace_text(1);
1172 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
1178 for( int i = 0; i < src->total - 1; i++ ) {
1179 BC_ListBoxItem *item1 = src->values[i];
1180 BC_ListBoxItem *item2 = src->values[i + 1];
1181 item1->set_autoplace_icon(1);
1182 item2->set_autoplace_icon(1);
1183 item1->set_autoplace_text(1);
1184 item2->set_autoplace_text(1);
1185 if( strcmp(item1->get_text(), item2->get_text()) > 0 ) {
1186 src->values[i + 1] = item1;
1187 src->values[i] = item2;
1195 void AWindowGUI::filter_displayed_assets()
1197 //allow_iconlisting = 1;
1198 asset_titles[0] = _("Title");
1199 asset_titles[1] = _("Comments");
1201 switch( mwindow->edl->session->awindow_folder ) {
1202 case AW_AEFFECT_FOLDER:
1203 copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
1205 case AW_VEFFECT_FOLDER:
1206 copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
1208 case AW_ATRANSITION_FOLDER:
1209 copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
1211 case AW_VTRANSITION_FOLDER:
1212 copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
1214 case AW_LABEL_FOLDER:
1215 copy_picons(displayed_assets, &labellist, AW_NO_FOLDER);
1216 asset_titles[0] = _("Time Stamps");
1217 asset_titles[1] = _("Title");
1218 //allow_iconlisting = 0;
1221 copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
1225 // Ensure the current folder icon is highlighted
1226 int selected_folder = mwindow->edl->session->awindow_folder;
1227 for( int i = 0; i < folders.total; i++ ) {
1228 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
1229 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
1230 folder_item->set_selected(selected);
1235 void AWindowGUI::update_assets()
1237 update_folder_list();
1238 update_asset_list();
1239 labellist.remove_all_objects();
1240 create_label_folder();
1241 filter_displayed_assets();
1243 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
1244 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1246 int folder_xposition = folder_list->get_xposition();
1247 int folder_yposition = folder_list->get_yposition();
1248 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
1250 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
1251 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1253 int asset_xposition = asset_list->get_xposition();
1254 int asset_yposition = asset_list->get_yposition();
1255 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
1256 displayed_folder = mwindow->edl->session->awindow_folder;
1257 asset_xposition = asset_yposition = 0;
1259 asset_list->update(displayed_assets, asset_titles,
1260 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
1261 asset_xposition, asset_yposition, -1, 0);
1262 asset_list->center_selection();
1268 void AWindowGUI::update_effects()
1270 aeffects.remove_all_objects();
1271 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1272 veffects.remove_all_objects();
1273 create_persistent_folder(&veffects, 0, 1, 1, 0);
1274 atransitions.remove_all_objects();
1275 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1276 vtransitions.remove_all_objects();
1277 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1280 int AWindowGUI::folder_number(const char *name)
1282 for( int i = 0; i < AWINDOW_FOLDERS; i++ ) {
1283 if( !strcasecmp(name, folder_names[i]) ) return i;
1285 return AW_NO_FOLDER;
1288 int AWindowGUI::drag_motion()
1290 if( get_hidden() ) return 0;
1296 int AWindowGUI::drag_stop()
1298 if( get_hidden() ) return 0;
1303 Indexable* AWindowGUI::selected_asset()
1305 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1306 return picon ? picon->indexable : 0;
1309 PluginServer* AWindowGUI::selected_plugin()
1311 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1312 return picon ? picon->plugin : 0;
1315 AssetPicon* AWindowGUI::selected_folder()
1317 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1328 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1329 : BC_SubWindow(x, y, w, h)
1331 this->mwindow = mwindow;
1334 AWindowDivider::~AWindowDivider()
1338 int AWindowDivider::button_press_event()
1340 if( is_event_win() && cursor_inside() ) {
1341 mwindow->session->current_operation = DRAG_PARTITION;
1347 int AWindowDivider::cursor_motion_event()
1349 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1351 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
1352 int fw = gui->get_relative_cursor_x();
1353 if( fw > wmax ) fw = wmax;
1354 if( fw < wmin ) fw = wmin;
1355 mwindow->session->afolders_w = fw;
1356 mwindow->theme->get_awindow_sizes(gui);
1357 gui->reposition_objects();
1363 int AWindowDivider::button_release_event()
1365 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1366 mwindow->session->current_operation = NO_OPERATION;
1377 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1378 : BC_ListBox(x, y, w, h,
1379 mwindow->edl->session->folderlist_format == ASSETS_ICONS ?
1380 LISTBOX_ICONS : LISTBOX_TEXT,
1381 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
1382 0, // Titles for columns. Set to 0 for no titles
1383 0, // width of each column
1384 1, // Total columns.
1385 0, // Pixel of top of window.
1386 0, // If this listbox is a popup window
1387 LISTBOX_SINGLE, // Select one item or multiple items
1388 ICON_TOP, // Position of icon relative to text of each item
1391 this->mwindow = mwindow;
1396 AWindowFolders::~AWindowFolders()
1400 int AWindowFolders::selection_changed()
1402 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1404 gui->stop_vicon_drawing();
1406 if( get_button_down() && get_buttonpress() == 3 ) {
1407 gui->folderlist_menu->update_titles();
1408 gui->folderlist_menu->activate_menu();
1411 mwindow->edl->session->awindow_folder = picon->foldernum;
1412 gui->asset_list->draw_background();
1413 gui->async_update_assets();
1415 gui->start_vicon_drawing();
1420 int AWindowFolders::button_press_event()
1424 result = BC_ListBox::button_press_event();
1427 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1428 gui->folderlist_menu->update_titles();
1429 gui->folderlist_menu->activate_menu();
1444 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1445 : BC_ListBox(x, y, w, h,
1446 (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
1447 LISTBOX_ICONS : LISTBOX_TEXT,
1448 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
1449 gui->asset_titles,// Titles for columns. Set to 0 for no titles
1450 mwindow->edl->session->asset_columns, // width of each column
1451 1, // Total columns.
1452 0, // Pixel of top of window.
1453 0, // If this listbox is a popup window
1454 LISTBOX_MULTIPLE, // Select one item or multiple items
1455 ICON_TOP, // Position of icon relative to text of each item
1456 -1) // Allow drags, require shift for scrolling
1458 this->mwindow = mwindow;
1461 set_scroll_stretch(1, 1);
1464 AWindowAssets::~AWindowAssets()
1468 int AWindowAssets::button_press_event()
1472 result = BC_ListBox::button_press_event();
1474 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1475 BC_ListBox::deactivate_selection();
1476 int folder = mwindow->edl->session->awindow_folder;
1478 case AW_AEFFECT_FOLDER:
1479 case AW_VEFFECT_FOLDER:
1480 case AW_ATRANSITION_FOLDER:
1481 case AW_VTRANSITION_FOLDER:
1482 gui->effectlist_menu->update();
1483 gui->effectlist_menu->activate_menu();
1485 case AW_LABEL_FOLDER:
1486 gui->labellist_menu->update();
1487 gui->labellist_menu->activate_menu();
1489 case AW_CLIP_FOLDER:
1490 gui->cliplist_menu->update();
1491 gui->cliplist_menu->activate_menu();
1493 case AW_MEDIA_FOLDER:
1494 case AW_PROXY_FOLDER:
1495 gui->assetlist_menu->update_titles();
1496 gui->assetlist_menu->activate_menu();
1506 int AWindowAssets::handle_event()
1508 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
1509 if( !asset_picon ) return 0;
1510 switch( mwindow->edl->session->awindow_folder ) {
1511 case AW_AEFFECT_FOLDER:
1512 case AW_VEFFECT_FOLDER:
1513 case AW_ATRANSITION_FOLDER:
1514 case AW_VTRANSITION_FOLDER: return 1;
1516 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1517 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1518 if( !vwindow || !vwindow->is_running() ) return 1;
1520 vwindow->gui->lock_window("AWindowAssets::handle_event");
1521 if( asset_picon->indexable )
1522 vwindow->change_source(asset_picon->indexable);
1523 else if( asset_picon->edl )
1524 vwindow->change_source(asset_picon->edl);
1525 vwindow->gui->unlock_window();
1529 int AWindowAssets::selection_changed()
1531 // Show popup window
1533 if( get_button_down() && get_buttonpress() == 3 &&
1534 (item = (AssetPicon*)get_selection(0, 0)) ) {
1535 int folder = mwindow->edl->session->awindow_folder;
1537 case AW_AEFFECT_FOLDER:
1538 case AW_VEFFECT_FOLDER:
1539 case AW_ATRANSITION_FOLDER:
1540 case AW_VTRANSITION_FOLDER:
1541 gui->effectlist_menu->update();
1542 gui->effectlist_menu->activate_menu();
1544 case AW_LABEL_FOLDER:
1545 if( !item->label ) break;
1546 gui->label_menu->activate_menu();
1548 case AW_CLIP_FOLDER:
1549 if( !item->indexable && !item->edl ) break;
1550 gui->clip_menu->update();
1551 gui->clip_menu->activate_menu();
1554 if( !item->indexable && !item->edl ) break;
1555 gui->asset_menu->update();
1556 gui->asset_menu->activate_menu();
1560 BC_ListBox::deactivate_selection();
1563 else if( get_button_down() && get_buttonpress() == 1 &&
1564 (item = (AssetPicon*)get_selection(0, 0)) ) {
1566 if( !gui->vicon_thread->viewing ) {
1567 vicon = item->vicon;
1569 gui->vicon_thread->set_view_popup(vicon);
1575 void AWindowAssets::draw_background()
1577 clear_box(0,0,get_w(),get_h(),get_bg_surface());
1578 set_color(BC_WindowBase::get_resources()->audiovideo_color);
1579 set_font(LARGEFONT);
1580 int aw_folder = mwindow->edl->session->awindow_folder;
1581 if( aw_folder < 0 ) return;
1582 const char *aw_name = _(AWindowGUI::folder_names[aw_folder]);
1583 draw_text(get_w() - get_text_width(LARGEFONT, aw_name) - 4, 30,
1584 aw_name, -1, get_bg_surface());
1587 int AWindowAssets::drag_start_event()
1589 int collect_pluginservers = 0;
1590 int collect_assets = 0;
1592 if( BC_ListBox::drag_start_event() ) {
1593 switch( mwindow->edl->session->awindow_folder ) {
1594 case AW_AEFFECT_FOLDER:
1595 mwindow->session->current_operation = DRAG_AEFFECT;
1596 collect_pluginservers = 1;
1598 case AW_VEFFECT_FOLDER:
1599 mwindow->session->current_operation = DRAG_VEFFECT;
1600 collect_pluginservers = 1;
1602 case AW_ATRANSITION_FOLDER:
1603 mwindow->session->current_operation = DRAG_ATRANSITION;
1604 collect_pluginservers = 1;
1606 case AW_VTRANSITION_FOLDER:
1607 mwindow->session->current_operation = DRAG_VTRANSITION;
1608 collect_pluginservers = 1;
1610 case AW_LABEL_FOLDER:
1614 mwindow->session->current_operation = DRAG_ASSET;
1619 if( collect_pluginservers ) {
1621 mwindow->session->drag_pluginservers->remove_all();
1624 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
1625 if( !result ) break;
1627 mwindow->session->drag_pluginservers->append(result->plugin);
1631 if( collect_assets ) {
1632 gui->collect_assets();
1640 int AWindowAssets::drag_motion_event()
1642 BC_ListBox::drag_motion_event();
1645 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1646 mwindow->gui->drag_motion();
1647 mwindow->gui->unlock_window();
1649 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
1650 VWindow *vwindow = mwindow->vwindows.get(i);
1651 if( !vwindow->is_running() ) continue;
1652 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1653 vwindow->gui->drag_motion();
1654 vwindow->gui->unlock_window();
1657 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1658 mwindow->cwindow->gui->drag_motion();
1659 mwindow->cwindow->gui->unlock_window();
1661 lock_window("AWindowAssets::drag_motion_event");
1665 int AWindowAssets::drag_stop_event()
1669 result = gui->drag_stop();
1674 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1675 result = mwindow->gui->drag_stop();
1676 mwindow->gui->unlock_window();
1680 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
1681 VWindow *vwindow = mwindow->vwindows.get(i);
1682 if( !vwindow ) continue;
1683 if( !vwindow->is_running() ) continue;
1684 if( vwindow->gui->is_hidden() ) continue;
1685 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1686 if( vwindow->gui->cursor_above() &&
1687 vwindow->gui->get_cursor_over_window() ) {
1688 result = vwindow->gui->drag_stop();
1690 vwindow->gui->unlock_window();
1695 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1696 result = mwindow->cwindow->gui->drag_stop();
1697 mwindow->cwindow->gui->unlock_window();
1700 lock_window("AWindowAssets::drag_stop_event");
1702 if( result ) get_drag_popup()->set_animation(0);
1704 BC_ListBox::drag_stop_event();
1705 mwindow->session->current_operation = ::NO_OPERATION; // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
1709 int AWindowAssets::column_resize_event()
1711 mwindow->edl->session->asset_columns[0] = get_column_width(0);
1712 mwindow->edl->session->asset_columns[1] = get_column_width(1);
1716 int AWindowAssets::focus_in_event()
1718 gui->start_vicon_drawing();
1722 int AWindowAssets::focus_out_event()
1724 gui->stop_vicon_drawing();
1725 return BC_ListBox::focus_out_event();
1739 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1740 : BC_Button(x, y, mwindow->theme->newbin_data)
1742 this->mwindow = mwindow;
1744 set_tooltip(_("New bin"));
1747 int AWindowNewFolder::handle_event()
1749 gui->newfolder_thread->start_new_folder();
1753 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1754 : BC_Button(x, y, mwindow->theme->deletebin_data)
1756 this->mwindow = mwindow;
1758 set_tooltip(_("Delete bin"));
1761 int AWindowDeleteFolder::handle_event()
1763 if( gui->folder_list->get_selection(0, 0) ) {
1764 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
1765 mwindow->delete_folder(folder->get_text());
1770 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1771 : BC_Button(x, y, mwindow->theme->renamebin_data)
1773 this->mwindow = mwindow;
1775 set_tooltip(_("Rename bin"));
1778 int AWindowRenameFolder::handle_event()
1783 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1784 : BC_Button(x, y, mwindow->theme->deletedisk_data)
1786 this->mwindow = mwindow;
1788 set_tooltip(_("Delete asset from disk"));
1791 int AWindowDeleteDisk::handle_event()
1796 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1797 : BC_Button(x, y, mwindow->theme->deleteproject_data)
1799 this->mwindow = mwindow;
1801 set_tooltip(_("Delete asset from project"));
1804 int AWindowDeleteProject::handle_event()
1809 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1810 // : BC_Button(x, y, mwindow->theme->infoasset_data)
1812 // this->mwindow = mwindow;
1814 // set_tooltip(_("Edit information on asset"));
1817 // int AWindowInfo::handle_event()
1819 // int cur_x, cur_y;
1820 // gui->get_abs_cursor_xy(cur_x, cur_y, 0);
1821 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
1825 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1826 : BC_Button(x, y, mwindow->theme->redrawindex_data)
1828 this->mwindow = mwindow;
1830 set_tooltip(_("Redraw index"));
1833 int AWindowRedrawIndex::handle_event()
1838 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1839 : BC_Button(x, y, mwindow->theme->pasteasset_data)
1841 this->mwindow = mwindow;
1843 set_tooltip(_("Paste asset on recordable tracks"));
1846 int AWindowPaste::handle_event()
1851 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1852 : BC_Button(x, y, mwindow->theme->appendasset_data)
1854 this->mwindow = mwindow;
1856 set_tooltip(_("Append asset in new tracks"));
1859 int AWindowAppend::handle_event()
1864 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1865 : BC_Button(x, y, mwindow->theme->viewasset_data)
1867 this->mwindow = mwindow;
1869 set_tooltip(_("View asset"));
1872 int AWindowView::handle_event()
1877 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
1878 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
1880 this->mwindow = mwindow;
1884 void AddTools::create_objects()
1887 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
1888 vis |= 1 << PLUGIN_LADSPA_ID;
1889 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
1890 vis |= 1 << PLUGIN_FFMPEG_ID;
1891 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
1892 PluginServer *plugin = MWindow::plugindb->get(i);
1893 if( !plugin->audio && !plugin->video ) continue;
1894 int idx = plugin->dir_idx;
1895 uint32_t msk = 1 << idx;
1896 if( (msk & vis) != 0 ) continue;
1898 char parent[BCTEXTLEN];
1899 strcpy(parent, plugin->path);
1900 char *bp = strrchr(parent, '/');
1901 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
1902 if( !bp ) bp = parent; else ++bp;
1903 add_item(new AddPluginItem(this, bp, idx));
1908 // plugin_dirs list from toplevel makefile include plugin_defs
1912 N_("audio_transitions")
1919 N_("video_transitions")
1922 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
1923 : BC_MenuItem(_(text))
1927 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
1928 int chk = (msk & vis) ? 1 : 0;
1932 int AddPluginItem::handle_event()
1934 int chk = get_checked() ^ 1;
1936 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
1937 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
1938 menu->gui->update_effects();
1939 menu->gui->save_defaults(menu->mwindow->defaults);
1940 menu->gui->async_update_assets();
1944 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
1945 : BC_Toggle(x, y, images, agui->vicon_drawing)
1948 set_tooltip(_("draw vicons"));
1951 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
1953 int text_line = -1, toggle_x = -1, toggle_y = -1;
1954 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
1955 BC_Toggle::calculate_extents(agui, images, 1,
1956 &text_line, ww, hh, &toggle_x, &toggle_y,
1957 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
1960 AVIconDrawing::~AVIconDrawing()
1964 int AVIconDrawing::handle_event()
1966 agui->vicon_drawing = get_value();
1967 if( agui->vicon_drawing )
1968 agui->start_vicon_drawing();
1970 agui->stop_vicon_drawing();
1975 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
1978 this->mwindow = mwindow;
1982 int AWindowListFormat::handle_event()
1984 gui->stop_vicon_drawing();
1986 EDLSession *session = mwindow->edl->session;
1987 switch( session->assetlist_format ) {
1989 session->assetlist_format = ASSETS_ICONS;
1992 session->assetlist_format = ASSETS_TEXT;
1996 gui->asset_list->update_format(session->assetlist_format, 1);
1997 if( !mwindow->awindow->gui->allow_iconlisting ) {
1998 mwindow->edl->session->assetlist_format = ASSETS_TEXT;
2001 gui->start_vicon_drawing();
2005 void AWindowListFormat::update()
2007 set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
2008 (char*)_("Display icons") : (char*)_("Display text"));
2011 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
2012 : BC_MenuItem(_("Sort items"))
2014 this->mwindow = mwindow;
2018 int AWindowListSort::handle_event()