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 if( access(png_path, R_OK) ) return 0;
525 return VFramePng::vframe_png(png_path,0,0);
528 VFrame *AWindowGUI::get_picon(const char *name)
530 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
532 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
533 snprintf(pp, ep-pp, "%s.png", name);
534 unsigned char *data = mwindow->theme->get_image_data(png_name);
535 if( data ) vframe = new VFramePng(data, 0.);
540 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
542 vfrm = get_picon(fn);
543 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
544 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
546 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
548 vfrm = get_picon(fn);
549 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
550 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
552 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
554 vfrm = get_picon(fn);
555 if( !vfrm ) vfrm = new VFramePng(png);
556 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
559 void AWindowGUI::create_objects()
561 lock_window("AWindowGUI::create_objects");
562 asset_titles[0] = C_("Title");
563 asset_titles[1] = _("Comments");
565 set_icon(mwindow->theme->get_image("awindow_icon"));
567 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
568 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
569 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
570 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
571 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
573 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
574 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
575 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
576 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
577 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
578 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
579 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
580 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
582 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
583 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
584 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
585 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
586 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
587 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
588 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
589 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
591 theme_icon(clip_vframe, clip_icon, "clip_icon");
592 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
593 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
594 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
595 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
597 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
598 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
599 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
602 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
603 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
604 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
605 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
606 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
607 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
608 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
609 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
611 create_label_folder();
613 mwindow->theme->get_awindow_sizes(this);
614 load_defaults(mwindow->defaults);
616 add_subwindow(asset_list = new AWindowAssets(mwindow, this,
617 mwindow->theme->alist_x, mwindow->theme->alist_y,
618 mwindow->theme->alist_w, mwindow->theme->alist_h));
620 vicon_thread = new VIconThread(asset_list);
621 vicon_thread->start();
623 add_subwindow(divider = new AWindowDivider(mwindow, this,
624 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
625 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
627 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
629 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
630 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
631 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
632 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
633 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
634 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
635 add_tools->create_objects();
636 fy += add_tools->get_h(); fh -= add_tools->get_h();
637 add_subwindow(folder_list = new AWindowFolders(mwindow,
638 this, fx, fy, fw, fh));
641 //int x = mwindow->theme->abuttons_x;
642 //int y = mwindow->theme->abuttons_y;
645 newfolder_thread = new NewFolderThread(mwindow, this);
647 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
648 asset_menu->create_objects();
649 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
650 clip_menu->create_objects();
651 add_subwindow(label_menu = new LabelPopup(mwindow, this));
652 label_menu->create_objects();
654 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
655 effectlist_menu->create_objects();
656 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
657 assetlist_menu->create_objects();
658 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
659 cliplist_menu->create_objects();
660 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
661 labellist_menu->create_objects();
663 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
664 folderlist_menu->create_objects();
666 create_custom_xatoms();
670 int AWindowGUI::resize_event(int w, int h)
672 mwindow->session->awindow_x = get_x();
673 mwindow->session->awindow_y = get_y();
674 mwindow->session->awindow_w = w;
675 mwindow->session->awindow_h = h;
677 mwindow->theme->get_awindow_sizes(this);
678 mwindow->theme->draw_awindow_bg(this);
679 reposition_objects();
681 // int x = mwindow->theme->abuttons_x;
682 // int y = mwindow->theme->abuttons_y;
683 // new_bin->reposition_window(x, y);
684 // x += new_bin->get_w();
685 // delete_bin->reposition_window(x, y);
686 // x += delete_bin->get_w();
687 // rename_bin->reposition_window(x, y);
688 // x += rename_bin->get_w();
689 // delete_disk->reposition_window(x, y);
690 // x += delete_disk->get_w();
691 // delete_project->reposition_window(x, y);
692 // x += delete_project->get_w();
693 // info->reposition_window(x, y);
694 // x += info->get_w();
695 // redraw_index->reposition_window(x, y);
696 // x += redraw_index->get_w();
697 // paste->reposition_window(x, y);
698 // x += paste->get_w();
699 // append->reposition_window(x, y);
700 // x += append->get_w();
701 // view->reposition_window(x, y);
703 BC_WindowBase::resize_event(w, h);
707 int AWindowGUI::translation_event()
709 mwindow->session->awindow_x = get_x();
710 mwindow->session->awindow_y = get_y();
714 void AWindowGUI::reposition_objects()
716 asset_list->reposition_window(
717 mwindow->theme->alist_x, mwindow->theme->alist_y,
718 mwindow->theme->alist_w, mwindow->theme->alist_h);
719 divider->reposition_window(
720 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
721 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
722 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
723 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
724 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
725 avicon_drawing->reposition_window(fw-avicon_w, fy);
726 fy += add_tools->get_h(); fh -= add_tools->get_h();
727 folder_list->reposition_window(fx, fy, fw, fh);
730 int AWindowGUI::save_defaults(BC_Hash *defaults)
732 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
733 defaults->update("VICON_DRAWING", vicon_drawing);
737 int AWindowGUI::load_defaults(BC_Hash *defaults)
739 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
740 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
744 int AWindowGUI::close_event()
747 mwindow->session->show_awindow = 0;
750 mwindow->gui->lock_window("AWindowGUI::close_event");
751 mwindow->gui->mainmenu->show_awindow->set_checked(0);
752 mwindow->gui->unlock_window();
754 lock_window("AWindowGUI::close_event");
755 save_defaults(mwindow->defaults);
756 mwindow->save_defaults();
760 void AWindowGUI::start_vicon_drawing()
762 if( !vicon_drawing ) return;
763 if( mwindow->edl->session->awindow_folder != AW_MEDIA_FOLDER ) return;
764 if( mwindow->edl->session->assetlist_format != ASSETS_ICONS ) return;
765 vicon_thread->start_drawing();
768 void AWindowGUI::stop_vicon_drawing()
770 vicon_thread->stop_drawing();
773 AWindowRemovePluginGUI::
774 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
775 int x, int y, PluginServer *plugin)
776 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
778 this->awindow = awindow;
779 this->thread = thread;
780 this->plugin = plugin;
781 VFrame *vframe = plugin->get_picon();
782 icon = vframe ? create_pixmap(vframe) : 0;
783 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
786 AWindowRemovePluginGUI::
787 ~AWindowRemovePluginGUI()
789 if( !awindow->gui->protected_pixmap(icon) )
791 plugin_list.remove_all();
794 void AWindowRemovePluginGUI::create_objects()
796 BC_Button *ok_button = new BC_OKButton(this);
797 add_subwindow(ok_button);
798 BC_Button *cancel_button = new BC_CancelButton(this);
799 add_subwindow(cancel_button);
801 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
802 add_subwindow(title);
803 y += title->get_h() + 5;
804 list = new BC_ListBox(x, y,
805 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
806 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
811 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
814 for( int i=0; i<folder.size(); ) {
815 AssetPicon *picon = (AssetPicon *)folder[i];
816 if( picon->plugin == plugin ) {
817 folder.remove_object_number(i);
826 void AWindowRemovePlugin::handle_close_event(int result)
829 printf(_("remove %s\n"), plugin->path);
830 ArrayList<BC_ListBoxItem*> *folder =
831 plugin->audio ? plugin->transition ?
832 &awindow->gui->atransitions :
833 &awindow->gui->aeffects :
834 plugin->video ? plugin->transition ?
835 &awindow->gui->vtransitions :
836 &awindow->gui->veffects :
838 if( folder ) remove_plugin(plugin, *folder);
839 char plugin_path[BCTEXTLEN];
840 strcpy(plugin_path, plugin->path);
841 MWindow *mwindow = awindow->mwindow;
842 mwindow->plugindb->remove(plugin);
844 char index_path[BCTEXTLEN];
845 snprintf(index_path, sizeof(index_path), "%s/%s",
846 mwindow->preferences->plugin_dir, PLUGIN_FILE);
848 char picon_path[BCTEXTLEN];
850 snprintf(picon_path, sizeof(picon_path), "%s/picon",
851 File::get_plugin_path());
852 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
853 plugin->get_plugin_png_name(png_name);
854 fs.update(picon_path);
855 for( int i=0; i<fs.dir_list.total; ++i ) {
856 char *fs_path = fs.dir_list[i]->path;
857 if( !fs.is_dir(fs_path) ) continue;
858 snprintf(png_path, sizeof(picon_path), "%s/%s",
862 delete plugin; plugin = 0;
863 awindow->gui->async_update_assets();
867 AWindowRemovePlugin::
868 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
871 this->awindow = awindow;
872 this->plugin = plugin;
875 AWindowRemovePlugin::
876 ~AWindowRemovePlugin()
881 BC_Window* AWindowRemovePlugin::new_gui()
883 int x = awindow->gui->get_abs_cursor_x(0);
884 int y = awindow->gui->get_abs_cursor_y(0);
885 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
886 gui->create_objects();
890 int AWindowGUI::keypress_event()
892 switch( get_keypress() ) {
901 PluginServer* plugin = selected_plugin();
903 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
905 remove_plugin->start();
914 int AWindowGUI::create_custom_xatoms()
916 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
919 int AWindowGUI::recieve_custom_xatoms(xatom_event *event)
921 if( event->message_type == UpdateAssetsXAtom ) {
928 void AWindowGUI::async_update_assets()
931 event.message_type = UpdateAssetsXAtom;
932 send_custom_xatom(&event);
936 void AWindowGUI::update_folder_list()
938 stop_vicon_drawing();
939 for( int i = 0; i < folders.total; i++ ) {
940 AssetPicon *picon = (AssetPicon*)folders.values[i];
944 // Search assets for folders
945 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
946 const char *folder = mwindow->edl->folders.values[i];
949 for( int j = 0; j < folders.total; j++ ) {
950 AssetPicon *picon = (AssetPicon*)folders.values[j];
951 if( !strcasecmp(picon->get_text(), folder) ) {
959 int aw_folder = folder_number(folder);
960 if( aw_folder >= 0 ) {
961 AssetPicon *picon = new AssetPicon(mwindow, this, aw_folder, 1);
962 picon->create_objects();
963 folders.append(picon);
968 // Delete unused non-persistent folders
969 for( int i=folders.total; --i>=0; ) {
970 AssetPicon *picon = (AssetPicon*)folders.values[i];
971 if( !picon->in_use && !picon->persistent ) {
973 folders.remove_number(i);
977 start_vicon_drawing();
980 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
981 int do_audio, int do_video, int is_realtime, int is_transition)
983 ArrayList<PluginServer*> plugin_list;
984 // Get pointers to plugindb entries
985 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
988 for( int i = 0; i < plugin_list.total; i++ ) {
989 PluginServer *server = plugin_list.values[i];
990 int visible = plugin_visibility & (1<<server->dir_idx);
991 if( !visible ) continue;
992 // Create new listitem
993 AssetPicon *picon = new AssetPicon(mwindow, this, server);
994 picon->create_objects();
995 output->append(picon);
999 void AWindowGUI::create_label_folder()
1002 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1003 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1004 picon->create_objects();
1005 labellist.append(picon);
1010 void AWindowGUI::update_asset_list()
1012 for( int i = 0; i < assets.total; i++ ) {
1013 AssetPicon *picon = (AssetPicon*)assets.values[i];
1017 // Synchronize EDL clips
1018 for( int i = 0; i < mwindow->edl->clips.total; i++ ) {
1021 // Look for clip in existing listitems
1022 for( int j = 0; j < assets.total && !exists; j++ ) {
1023 AssetPicon *picon = (AssetPicon*)assets.values[j];
1025 if( picon->id == mwindow->edl->clips.values[i]->id ) {
1026 picon->edl = mwindow->edl->clips.values[i];
1027 picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title);
1033 // Create new listitem
1035 AssetPicon *picon = new AssetPicon(mwindow,
1036 this, mwindow->edl->clips.values[i]);
1037 picon->create_objects();
1038 assets.append(picon);
1042 // Synchronize EDL assets
1043 for( Asset *current = mwindow->edl->assets->first;
1048 // Look for asset in existing listitems
1049 for( int j = 0; j < assets.total && !exists; j++ ) {
1050 AssetPicon *picon = (AssetPicon*)assets.values[j];
1052 if( picon->id == current->id ) {
1053 picon->indexable = current;
1060 // Create new listitem
1062 AssetPicon *picon = new AssetPicon(mwindow,
1064 picon->create_objects();
1065 assets.append(picon);
1069 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1070 mwindow->gui->default_message();
1071 mwindow->gui->unlock_window();
1073 // Synchronize nested EDLs
1074 for( int i = 0; i < mwindow->edl->nested_edls->size(); i++ ) {
1076 Indexable *indexable = mwindow->edl->nested_edls->get(i);
1078 // Look for asset in existing listitems
1079 for( int j = 0; j < assets.total && !exists; j++ ) {
1080 AssetPicon *picon = (AssetPicon*)assets.values[j];
1082 if( picon->id == indexable->id ) {
1083 picon->indexable = indexable;
1090 // Create new listitem
1092 AssetPicon *picon = new AssetPicon(mwindow,
1094 picon->create_objects();
1095 assets.append(picon);
1099 for( int i = assets.size() - 1; i >= 0; i-- ) {
1100 AssetPicon *picon = (AssetPicon*)assets.get(i);
1101 if( !picon->in_use ) {
1103 assets.remove_number(i);
1108 void AWindowGUI::update_picon(Indexable *indexable)
1111 for( int i = 0; i < assets.total; i++ ) {
1112 AssetPicon *picon = (AssetPicon*)assets.values[i];
1113 if( picon->indexable == indexable ||
1114 picon->edl == (EDL *)indexable ) {
1115 char name[BCTEXTLEN];
1117 fs.extract_name(name, indexable->path);
1118 picon->set_text(name);
1119 vicon = picon->vicon;
1124 stop_vicon_drawing();
1125 vicon->clear_images();
1126 vicon->reset(indexable->get_frame_rate());
1127 start_vicon_drawing();
1131 void AWindowGUI::sort_assets()
1133 switch( mwindow->edl->session->awindow_folder ) {
1134 case AW_AEFFECT_FOLDER:
1135 sort_picons(&aeffects);
1137 case AW_VEFFECT_FOLDER:
1138 sort_picons(&veffects);
1140 case AW_ATRANSITION_FOLDER:
1141 sort_picons(&atransitions);
1143 case AW_VTRANSITION_FOLDER:
1144 sort_picons(&vtransitions);
1146 case AW_LABEL_FOLDER:
1147 sort_picons(&labellist);
1150 sort_picons(&assets);
1153 asset_list->update_format(asset_list->get_format(), 0);
1157 void AWindowGUI::sort_folders()
1159 sort_picons(&folders);
1160 folder_list->update_format(folder_list->get_format(), 0);
1164 void AWindowGUI::collect_assets()
1167 mwindow->session->drag_assets->remove_all();
1168 mwindow->session->drag_clips->remove_all();
1171 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
1172 if( !result ) break;
1174 if( result->indexable ) mwindow->session->drag_assets->append(result->indexable);
1175 if( result->edl ) mwindow->session->drag_clips->append(result->edl);
1179 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
1180 ArrayList<BC_ListBoxItem*> *src, int folder)
1182 // Remove current pointers
1183 dst[0].remove_all();
1184 dst[1].remove_all_objects();
1186 // Create new pointers
1187 for( int i = 0; i < src->total; i++ ) {
1188 AssetPicon *picon = (AssetPicon*)src->values[i];
1190 (picon->indexable && picon->indexable->awindow_folder == folder) ||
1191 (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
1192 BC_ListBoxItem *item2, *item1;
1193 dst[0].append(item1 = picon);
1195 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1197 if( picon->label && picon->label->textstr )
1198 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1200 dst[1].append(item2 = new BC_ListBoxItem(""));
1201 item1->set_autoplace_text(1);
1202 item2->set_autoplace_text(1);
1207 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
1213 for( int i = 0; i < src->total - 1; i++ ) {
1214 BC_ListBoxItem *item1 = src->values[i];
1215 BC_ListBoxItem *item2 = src->values[i + 1];
1216 item1->set_autoplace_icon(1);
1217 item2->set_autoplace_icon(1);
1218 item1->set_autoplace_text(1);
1219 item2->set_autoplace_text(1);
1220 if( strcmp(item1->get_text(), item2->get_text()) > 0 ) {
1221 src->values[i + 1] = item1;
1222 src->values[i] = item2;
1230 void AWindowGUI::filter_displayed_assets()
1232 //allow_iconlisting = 1;
1233 asset_titles[0] = C_("Title");
1234 asset_titles[1] = _("Comments");
1236 switch( mwindow->edl->session->awindow_folder ) {
1237 case AW_AEFFECT_FOLDER:
1238 copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
1240 case AW_VEFFECT_FOLDER:
1241 copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
1243 case AW_ATRANSITION_FOLDER:
1244 copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
1246 case AW_VTRANSITION_FOLDER:
1247 copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
1249 case AW_LABEL_FOLDER:
1250 copy_picons(displayed_assets, &labellist, AW_NO_FOLDER);
1251 asset_titles[0] = _("Time Stamps");
1252 asset_titles[1] = C_("Title");
1253 //allow_iconlisting = 0;
1256 copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
1260 // Ensure the current folder icon is highlighted
1261 int selected_folder = mwindow->edl->session->awindow_folder;
1262 for( int i = 0; i < folders.total; i++ ) {
1263 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
1264 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
1265 folder_item->set_selected(selected);
1270 void AWindowGUI::update_assets()
1272 update_folder_list();
1273 update_asset_list();
1274 labellist.remove_all_objects();
1275 create_label_folder();
1276 filter_displayed_assets();
1278 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
1279 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1281 int folder_xposition = folder_list->get_xposition();
1282 int folder_yposition = folder_list->get_yposition();
1283 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
1285 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
1286 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1288 int asset_xposition = asset_list->get_xposition();
1289 int asset_yposition = asset_list->get_yposition();
1290 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
1291 displayed_folder = mwindow->edl->session->awindow_folder;
1292 asset_xposition = asset_yposition = 0;
1294 asset_list->update(displayed_assets, asset_titles,
1295 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
1296 asset_xposition, asset_yposition, -1, 0);
1297 asset_list->center_selection();
1303 void AWindowGUI::update_effects()
1305 aeffects.remove_all_objects();
1306 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1307 veffects.remove_all_objects();
1308 create_persistent_folder(&veffects, 0, 1, 1, 0);
1309 atransitions.remove_all_objects();
1310 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1311 vtransitions.remove_all_objects();
1312 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1315 int AWindowGUI::folder_number(const char *name)
1317 for( int i = 0; i < AWINDOW_FOLDERS; i++ ) {
1318 if( !strcasecmp(name, folder_names[i]) ) return i;
1320 return AW_NO_FOLDER;
1323 int AWindowGUI::drag_motion()
1325 if( get_hidden() ) return 0;
1331 int AWindowGUI::drag_stop()
1333 if( get_hidden() ) return 0;
1338 Indexable* AWindowGUI::selected_asset()
1340 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1341 return picon ? picon->indexable : 0;
1344 PluginServer* AWindowGUI::selected_plugin()
1346 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1347 return picon ? picon->plugin : 0;
1350 AssetPicon* AWindowGUI::selected_folder()
1352 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1363 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1364 : BC_SubWindow(x, y, w, h)
1366 this->mwindow = mwindow;
1369 AWindowDivider::~AWindowDivider()
1373 int AWindowDivider::button_press_event()
1375 if( is_event_win() && cursor_inside() ) {
1376 mwindow->session->current_operation = DRAG_PARTITION;
1382 int AWindowDivider::cursor_motion_event()
1384 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1386 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
1387 int fw = gui->get_relative_cursor_x();
1388 if( fw > wmax ) fw = wmax;
1389 if( fw < wmin ) fw = wmin;
1390 mwindow->session->afolders_w = fw;
1391 mwindow->theme->get_awindow_sizes(gui);
1392 gui->reposition_objects();
1398 int AWindowDivider::button_release_event()
1400 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1401 mwindow->session->current_operation = NO_OPERATION;
1412 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1413 : BC_ListBox(x, y, w, h,
1414 mwindow->edl->session->folderlist_format == ASSETS_ICONS ?
1415 LISTBOX_ICONS : LISTBOX_TEXT,
1416 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
1417 0, // Titles for columns. Set to 0 for no titles
1418 0, // width of each column
1419 1, // Total columns.
1420 0, // Pixel of top of window.
1421 0, // If this listbox is a popup window
1422 LISTBOX_SINGLE, // Select one item or multiple items
1423 ICON_TOP, // Position of icon relative to text of each item
1426 this->mwindow = mwindow;
1431 AWindowFolders::~AWindowFolders()
1435 int AWindowFolders::selection_changed()
1437 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1439 gui->stop_vicon_drawing();
1441 if( get_button_down() && get_buttonpress() == 3 ) {
1442 gui->folderlist_menu->update_titles();
1443 gui->folderlist_menu->activate_menu();
1446 mwindow->edl->session->awindow_folder = picon->foldernum;
1447 gui->asset_list->draw_background();
1448 gui->async_update_assets();
1450 gui->start_vicon_drawing();
1455 int AWindowFolders::button_press_event()
1459 result = BC_ListBox::button_press_event();
1462 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1463 gui->folderlist_menu->update_titles();
1464 gui->folderlist_menu->activate_menu();
1479 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1480 : BC_ListBox(x, y, w, h,
1481 (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
1482 LISTBOX_ICONS : LISTBOX_TEXT,
1483 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
1484 gui->asset_titles,// Titles for columns. Set to 0 for no titles
1485 mwindow->edl->session->asset_columns, // width of each column
1486 1, // Total columns.
1487 0, // Pixel of top of window.
1488 0, // If this listbox is a popup window
1489 LISTBOX_MULTIPLE, // Select one item or multiple items
1490 ICON_TOP, // Position of icon relative to text of each item
1491 -1) // Allow drags, require shift for scrolling
1493 this->mwindow = mwindow;
1496 set_scroll_stretch(1, 1);
1499 AWindowAssets::~AWindowAssets()
1503 int AWindowAssets::button_press_event()
1507 result = BC_ListBox::button_press_event();
1509 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1510 BC_ListBox::deactivate_selection();
1511 int folder = mwindow->edl->session->awindow_folder;
1513 case AW_AEFFECT_FOLDER:
1514 case AW_VEFFECT_FOLDER:
1515 case AW_ATRANSITION_FOLDER:
1516 case AW_VTRANSITION_FOLDER:
1517 gui->effectlist_menu->update();
1518 gui->effectlist_menu->activate_menu();
1520 case AW_LABEL_FOLDER:
1521 gui->labellist_menu->update();
1522 gui->labellist_menu->activate_menu();
1524 case AW_CLIP_FOLDER:
1525 gui->cliplist_menu->update();
1526 gui->cliplist_menu->activate_menu();
1528 case AW_MEDIA_FOLDER:
1529 case AW_PROXY_FOLDER:
1530 gui->assetlist_menu->update_titles();
1531 gui->assetlist_menu->activate_menu();
1541 int AWindowAssets::handle_event()
1543 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
1544 if( !asset_picon ) return 0;
1545 switch( mwindow->edl->session->awindow_folder ) {
1546 case AW_AEFFECT_FOLDER:
1547 case AW_VEFFECT_FOLDER:
1548 case AW_ATRANSITION_FOLDER:
1549 case AW_VTRANSITION_FOLDER: return 1;
1551 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1552 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1553 if( !vwindow || !vwindow->is_running() ) return 1;
1555 vwindow->gui->lock_window("AWindowAssets::handle_event");
1556 if( asset_picon->indexable )
1557 vwindow->change_source(asset_picon->indexable);
1558 else if( asset_picon->edl )
1559 vwindow->change_source(asset_picon->edl);
1560 vwindow->gui->unlock_window();
1564 int AWindowAssets::selection_changed()
1566 // Show popup window
1568 if( get_button_down() && get_buttonpress() == 3 &&
1569 (item = (AssetPicon*)get_selection(0, 0)) ) {
1570 int folder = mwindow->edl->session->awindow_folder;
1572 case AW_AEFFECT_FOLDER:
1573 case AW_VEFFECT_FOLDER:
1574 case AW_ATRANSITION_FOLDER:
1575 case AW_VTRANSITION_FOLDER:
1576 gui->effectlist_menu->update();
1577 gui->effectlist_menu->activate_menu();
1579 case AW_LABEL_FOLDER:
1580 if( !item->label ) break;
1581 gui->label_menu->activate_menu();
1583 case AW_CLIP_FOLDER:
1584 if( !item->indexable && !item->edl ) break;
1585 gui->clip_menu->update();
1586 gui->clip_menu->activate_menu();
1589 if( !item->indexable && !item->edl ) break;
1590 gui->asset_menu->update();
1591 gui->asset_menu->activate_menu();
1595 BC_ListBox::deactivate_selection();
1598 else if( get_button_down() && get_buttonpress() == 1 &&
1599 (item = (AssetPicon*)get_selection(0, 0)) ) {
1601 if( !gui->vicon_thread->viewing ) {
1602 vicon = item->vicon;
1604 gui->vicon_thread->set_view_popup(vicon);
1610 void AWindowAssets::draw_background()
1612 clear_box(0,0,get_w(),get_h(),get_bg_surface());
1613 set_color(BC_WindowBase::get_resources()->audiovideo_color);
1614 set_font(LARGEFONT);
1615 int aw_folder = mwindow->edl->session->awindow_folder;
1616 if( aw_folder < 0 ) return;
1617 const char *aw_name = _(AWindowGUI::folder_names[aw_folder]);
1618 draw_text(get_w() - get_text_width(LARGEFONT, aw_name) - 4, 30,
1619 aw_name, -1, get_bg_surface());
1622 int AWindowAssets::drag_start_event()
1624 int collect_pluginservers = 0;
1625 int collect_assets = 0;
1627 if( BC_ListBox::drag_start_event() ) {
1628 switch( mwindow->edl->session->awindow_folder ) {
1629 case AW_AEFFECT_FOLDER:
1630 mwindow->session->current_operation = DRAG_AEFFECT;
1631 collect_pluginservers = 1;
1633 case AW_VEFFECT_FOLDER:
1634 mwindow->session->current_operation = DRAG_VEFFECT;
1635 collect_pluginservers = 1;
1637 case AW_ATRANSITION_FOLDER:
1638 mwindow->session->current_operation = DRAG_ATRANSITION;
1639 collect_pluginservers = 1;
1641 case AW_VTRANSITION_FOLDER:
1642 mwindow->session->current_operation = DRAG_VTRANSITION;
1643 collect_pluginservers = 1;
1645 case AW_LABEL_FOLDER:
1649 mwindow->session->current_operation = DRAG_ASSET;
1654 if( collect_pluginservers ) {
1656 mwindow->session->drag_pluginservers->remove_all();
1659 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
1660 if( !result ) break;
1662 mwindow->session->drag_pluginservers->append(result->plugin);
1666 if( collect_assets ) {
1667 gui->collect_assets();
1675 int AWindowAssets::drag_motion_event()
1677 BC_ListBox::drag_motion_event();
1680 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1681 mwindow->gui->drag_motion();
1682 mwindow->gui->unlock_window();
1684 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
1685 VWindow *vwindow = mwindow->vwindows.get(i);
1686 if( !vwindow->is_running() ) continue;
1687 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1688 vwindow->gui->drag_motion();
1689 vwindow->gui->unlock_window();
1692 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1693 mwindow->cwindow->gui->drag_motion();
1694 mwindow->cwindow->gui->unlock_window();
1696 lock_window("AWindowAssets::drag_motion_event");
1700 int AWindowAssets::drag_stop_event()
1704 result = gui->drag_stop();
1709 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1710 result = mwindow->gui->drag_stop();
1711 mwindow->gui->unlock_window();
1715 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
1716 VWindow *vwindow = mwindow->vwindows.get(i);
1717 if( !vwindow ) continue;
1718 if( !vwindow->is_running() ) continue;
1719 if( vwindow->gui->is_hidden() ) continue;
1720 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1721 if( vwindow->gui->cursor_above() &&
1722 vwindow->gui->get_cursor_over_window() ) {
1723 result = vwindow->gui->drag_stop();
1725 vwindow->gui->unlock_window();
1730 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1731 result = mwindow->cwindow->gui->drag_stop();
1732 mwindow->cwindow->gui->unlock_window();
1735 lock_window("AWindowAssets::drag_stop_event");
1737 if( result ) get_drag_popup()->set_animation(0);
1739 BC_ListBox::drag_stop_event();
1740 mwindow->session->current_operation = ::NO_OPERATION; // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
1744 int AWindowAssets::column_resize_event()
1746 mwindow->edl->session->asset_columns[0] = get_column_width(0);
1747 mwindow->edl->session->asset_columns[1] = get_column_width(1);
1751 int AWindowAssets::focus_in_event()
1753 gui->start_vicon_drawing();
1757 int AWindowAssets::focus_out_event()
1759 gui->stop_vicon_drawing();
1760 return BC_ListBox::focus_out_event();
1774 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1775 : BC_Button(x, y, mwindow->theme->newbin_data)
1777 this->mwindow = mwindow;
1779 set_tooltip(_("New bin"));
1782 int AWindowNewFolder::handle_event()
1784 gui->newfolder_thread->start_new_folder();
1788 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1789 : BC_Button(x, y, mwindow->theme->deletebin_data)
1791 this->mwindow = mwindow;
1793 set_tooltip(_("Delete bin"));
1796 int AWindowDeleteFolder::handle_event()
1798 if( gui->folder_list->get_selection(0, 0) ) {
1799 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
1800 mwindow->delete_folder(folder->get_text());
1805 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1806 : BC_Button(x, y, mwindow->theme->renamebin_data)
1808 this->mwindow = mwindow;
1810 set_tooltip(_("Rename bin"));
1813 int AWindowRenameFolder::handle_event()
1818 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1819 : BC_Button(x, y, mwindow->theme->deletedisk_data)
1821 this->mwindow = mwindow;
1823 set_tooltip(_("Delete asset from disk"));
1826 int AWindowDeleteDisk::handle_event()
1831 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1832 : BC_Button(x, y, mwindow->theme->deleteproject_data)
1834 this->mwindow = mwindow;
1836 set_tooltip(_("Delete asset from project"));
1839 int AWindowDeleteProject::handle_event()
1844 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1845 // : BC_Button(x, y, mwindow->theme->infoasset_data)
1847 // this->mwindow = mwindow;
1849 // set_tooltip(_("Edit information on asset"));
1852 // int AWindowInfo::handle_event()
1854 // int cur_x, cur_y;
1855 // gui->get_abs_cursor(cur_x, cur_y, 0);
1856 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
1860 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1861 : BC_Button(x, y, mwindow->theme->redrawindex_data)
1863 this->mwindow = mwindow;
1865 set_tooltip(_("Redraw index"));
1868 int AWindowRedrawIndex::handle_event()
1873 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1874 : BC_Button(x, y, mwindow->theme->pasteasset_data)
1876 this->mwindow = mwindow;
1878 set_tooltip(_("Paste asset on recordable tracks"));
1881 int AWindowPaste::handle_event()
1886 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1887 : BC_Button(x, y, mwindow->theme->appendasset_data)
1889 this->mwindow = mwindow;
1891 set_tooltip(_("Append asset in new tracks"));
1894 int AWindowAppend::handle_event()
1899 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1900 : BC_Button(x, y, mwindow->theme->viewasset_data)
1902 this->mwindow = mwindow;
1904 set_tooltip(_("View asset"));
1907 int AWindowView::handle_event()
1912 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
1913 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
1915 this->mwindow = mwindow;
1919 void AddTools::create_objects()
1922 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
1923 vis |= 1 << PLUGIN_LADSPA_ID;
1924 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
1925 vis |= 1 << PLUGIN_FFMPEG_ID;
1926 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
1927 PluginServer *plugin = MWindow::plugindb->get(i);
1928 if( !plugin->audio && !plugin->video ) continue;
1929 int idx = plugin->dir_idx;
1930 uint32_t msk = 1 << idx;
1931 if( (msk & vis) != 0 ) continue;
1933 char parent[BCTEXTLEN];
1934 strcpy(parent, plugin->path);
1935 char *bp = strrchr(parent, '/');
1936 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
1937 if( !bp ) bp = parent; else ++bp;
1938 add_item(new AddPluginItem(this, bp, idx));
1943 // plugin_dirs list from toplevel makefile include plugin_defs
1947 N_("audio_transitions")
1954 N_("video_transitions")
1957 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
1958 : BC_MenuItem(_(text))
1962 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
1963 int chk = (msk & vis) ? 1 : 0;
1967 int AddPluginItem::handle_event()
1969 int chk = get_checked() ^ 1;
1971 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
1972 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
1973 menu->gui->update_effects();
1974 menu->gui->save_defaults(menu->mwindow->defaults);
1975 menu->gui->async_update_assets();
1979 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
1980 : BC_Toggle(x, y, images, agui->vicon_drawing)
1983 set_tooltip(_("draw vicons"));
1986 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
1988 int text_line = -1, toggle_x = -1, toggle_y = -1;
1989 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
1990 BC_Toggle::calculate_extents(agui, images, 1,
1991 &text_line, ww, hh, &toggle_x, &toggle_y,
1992 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
1995 AVIconDrawing::~AVIconDrawing()
1999 int AVIconDrawing::handle_event()
2001 agui->vicon_drawing = get_value();
2002 if( agui->vicon_drawing )
2003 agui->start_vicon_drawing();
2005 agui->stop_vicon_drawing();
2010 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
2013 this->mwindow = mwindow;
2017 int AWindowListFormat::handle_event()
2019 gui->stop_vicon_drawing();
2021 EDLSession *session = mwindow->edl->session;
2022 switch( session->assetlist_format ) {
2024 session->assetlist_format = ASSETS_ICONS;
2027 session->assetlist_format = ASSETS_TEXT;
2031 gui->asset_list->update_format(session->assetlist_format, 1);
2032 if( !mwindow->awindow->gui->allow_iconlisting ) {
2033 mwindow->edl->session->assetlist_format = ASSETS_TEXT;
2036 gui->start_vicon_drawing();
2040 void AWindowListFormat::update()
2042 set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
2043 (char*)_("Display icons") : (char*)_("Display text"));
2046 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
2047 : BC_MenuItem(_("Sort items"))
2049 this->mwindow = mwindow;
2053 int AWindowListSort::handle_event()