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"
27 #include "awindowgui.inc"
29 #include "awindowmenu.h"
30 #include "bcsignals.h"
32 #include "colormodels.h"
34 #include "cwindowgui.h"
37 #include "edlsession.h"
39 #include "filesystem.h"
40 #include "indexable.h"
43 #include "localsession.h"
45 #include "mainsession.h"
46 #include "mwindowgui.h"
48 #include "nestededls.h"
49 #include "newfolder.h"
50 #include "preferences.h"
53 #include "vwindowgui.h"
56 #include "data/lad_picon_png.h"
62 AssetPicon::AssetPicon(MWindow *mwindow,
68 this->mwindow = mwindow;
70 this->indexable = indexable;
71 indexable->add_user();
72 this->id = indexable->id;
75 AssetPicon::AssetPicon(MWindow *mwindow,
81 this->mwindow = mwindow;
88 AssetPicon::AssetPicon(MWindow *mwindow,
91 : BC_ListBoxItem(folder, gui->folder_icon)
94 this->mwindow = mwindow;
98 AssetPicon::AssetPicon(MWindow *mwindow,
100 PluginServer *plugin)
104 this->mwindow = mwindow;
106 this->plugin = plugin;
110 AssetPicon::~AssetPicon()
112 if(indexable) indexable->remove_user();
113 if(edl) edl->remove_user();
114 if( icon && !gui->protected_pixmap(icon) ) {
119 void AssetPicon::reset()
131 void AssetPicon::create_objects()
134 char name[BCTEXTLEN];
135 int pixmap_w, pixmap_h;
140 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
143 fs.extract_name(name, indexable->path);
147 if(indexable && indexable->is_asset)
149 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
150 Asset *asset = (Asset*)indexable;
151 if(asset->video_data)
153 if(mwindow->preferences->use_thumbnails)
155 gui->unlock_window();
156 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
157 File *file = mwindow->video_cache->check_out(asset,
160 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
164 int height = asset->height > 0 ? asset->height : 1;
165 pixmap_w = pixmap_h * asset->width / height;
168 file->set_video_position(0, 0);
170 if(gui->temp_picon &&
171 (gui->temp_picon->get_w() != asset->width ||
172 gui->temp_picon->get_h() != asset->height))
174 delete gui->temp_picon;
180 gui->temp_picon = new VFrame(0, -1,
181 asset->width, asset->height,
185 file->read_frame(gui->temp_picon);
186 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
187 mwindow->video_cache->check_in(asset);
189 gui->lock_window("AssetPicon::create_objects 1");
190 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
191 icon->draw_vframe(gui->temp_picon,
192 0, 0, pixmap_w, pixmap_h, 0, 0);
193 //printf("%d %d\n", gui->temp_picon->get_w(), gui->temp_picon->get_h());
194 icon_vframe = new VFrame(0,
195 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
196 BC_CModels::transfer(
197 icon_vframe->get_rows(),
198 gui->temp_picon->get_rows(),
199 0, 0, 0, 0, 0, 0, 0, 0,
200 gui->temp_picon->get_w(),
201 gui->temp_picon->get_h(),
202 0, 0, pixmap_w, pixmap_h,
203 BC_RGB888, BC_RGB888,
206 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
211 gui->lock_window("AssetPicon::create_objects 2");
212 icon = gui->video_icon;
213 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
218 icon = gui->video_icon;
219 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
223 if(asset->audio_data)
225 icon = gui->audio_icon;
226 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND];
228 //printf("AssetPicon::create_objects 2\n");
230 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
233 if(indexable && !indexable->is_asset)
235 icon = gui->video_icon;
236 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
241 //printf("AssetPicon::create_objects 4 %s\n", edl->local_session->clip_title);
242 set_text(strcpy(name, edl->local_session->clip_title));
243 icon = gui->clip_icon;
244 icon_vframe = mwindow->theme->get_image("clip_icon");
249 strcpy(name, _(plugin->title));
251 icon_vframe = plugin->get_picon();
253 icon = gui->create_pixmap(icon_vframe);
254 else if( plugin->audio ) {
255 if( plugin->transition ) {
256 icon = gui->atransition_icon;
257 icon_vframe = gui->atransition_vframe;
259 else if( !plugin->is_ladspa() ) {
260 icon = gui->aeffect_icon;
261 icon_vframe = gui->aeffect_vframe;
264 icon = gui->ladspa_icon;
265 icon_vframe = gui->ladspa_vframe;
268 else if( plugin->video ) {
269 if( plugin->transition ) {
270 icon = gui->vtransition_icon;
271 icon_vframe = gui->vtransition_vframe;
274 icon = gui->veffect_icon;
275 icon_vframe = gui->veffect_vframe;
280 icon = gui->file_icon;
281 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
284 set_icon_vframe(icon_vframe);
286 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
294 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
295 : BC_Window(PROGRAM_NAME ": Resources",
296 mwindow->session->awindow_x,
297 mwindow->session->awindow_y,
298 mwindow->session->awindow_w,
299 mwindow->session->awindow_h,
306 // printf("AWindowGUI::AWindowGUI %d %d %d %d\n",
307 // mwindow->session->awindow_x,
308 // mwindow->session->awindow_y,
309 // mwindow->session->awindow_w,
310 // mwindow->session->awindow_h);
311 this->mwindow = mwindow;
312 this->awindow = awindow;
318 atransition_icon = 0; atransition_vframe = 0;
319 vtransition_icon = 0; vtransition_vframe = 0;
320 aeffect_icon = 0; aeffect_vframe = 0;
321 ladspa_icon = 0; ladspa_vframe = 0;
322 veffect_icon = 0; veffect_vframe = 0;
323 newfolder_thread = 0;
329 plugin_visibility = ~0;
332 AWindowGUI::~AWindowGUI()
334 assets.remove_all_objects();
335 folders.remove_all_objects();
336 aeffects.remove_all_objects();
337 veffects.remove_all_objects();
338 atransitions.remove_all_objects();
339 vtransitions.remove_all_objects();
340 displayed_assets[1].remove_all_objects();
346 delete atransition_icon;
347 delete vtransition_icon;
350 delete ladspa_vframe;
352 delete newfolder_thread;
354 delete assetlist_menu;
355 delete folderlist_menu;
356 if(temp_picon) delete temp_picon;
357 delete remove_plugin;
360 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
362 return icon == file_icon ||
363 icon == audio_icon ||
364 icon == folder_icon ||
366 icon == video_icon ||
367 icon == veffect_icon ||
368 icon == vtransition_icon ||
369 icon == aeffect_icon ||
370 icon == ladspa_icon ||
371 icon == atransition_icon;
374 void AWindowGUI::create_objects()
378 lock_window("AWindowGUI::create_objects");
380 //printf("AWindowGUI::create_objects 1\n");
381 asset_titles[0] = _("Title");
382 asset_titles[1] = _("Comments");
386 set_icon(mwindow->theme->get_image("awindow_icon"));
387 file_icon = new BC_Pixmap(this,
388 BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN],
391 folder_icon = new BC_Pixmap(this,
392 BC_WindowBase::get_resources()->type_to_icon[ICON_FOLDER],
395 audio_icon = new BC_Pixmap(this,
396 BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND],
399 video_icon = new BC_Pixmap(this,
400 BC_WindowBase::get_resources()->type_to_icon[ICON_FILM],
405 clip_vframe = mwindow->theme->get_image("clip_icon");
406 clip_icon = new BC_Pixmap(this, clip_vframe, PIXMAP_ALPHA);
407 atransition_vframe = mwindow->theme->get_image("atransition_icon");
408 atransition_icon = new BC_Pixmap(this, atransition_vframe, PIXMAP_ALPHA);
409 vtransition_vframe = mwindow->theme->get_image("vtransition_icon");
410 vtransition_icon = new BC_Pixmap(this, vtransition_vframe, PIXMAP_ALPHA);
411 aeffect_vframe = mwindow->theme->get_image("aeffect_icon");
412 aeffect_icon = new BC_Pixmap(this, aeffect_vframe, PIXMAP_ALPHA);
413 ladspa_vframe = new VFrame(lad_picon_png);
414 ladspa_icon = new BC_Pixmap(this, ladspa_vframe, PIXMAP_ALPHA);
415 veffect_vframe = mwindow->theme->get_image("veffect_icon");
416 veffect_icon = new BC_Pixmap(this, veffect_vframe, PIXMAP_ALPHA);
421 folders.append(picon = new AssetPicon(mwindow,
424 picon->persistent = 1;
425 folders.append(picon = new AssetPicon(mwindow,
428 picon->persistent = 1;
429 folders.append(picon = new AssetPicon(mwindow,
431 ATRANSITION_FOLDER));
432 picon->persistent = 1;
433 folders.append(picon = new AssetPicon(mwindow,
435 VTRANSITION_FOLDER));
436 picon->persistent = 1;
439 mwindow->theme->get_awindow_sizes(this);
442 add_subwindow(asset_list = new AWindowAssets(mwindow,
444 mwindow->theme->alist_x,
445 mwindow->theme->alist_y,
446 mwindow->theme->alist_w,
447 mwindow->theme->alist_h));
450 add_subwindow(divider = new AWindowDivider(mwindow,
452 mwindow->theme->adivider_x,
453 mwindow->theme->adivider_y,
454 mwindow->theme->adivider_w,
455 mwindow->theme->adivider_h));
458 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
461 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
462 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
463 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, fw));
464 add_tools->create_objects();
465 fy += add_tools->get_h(); fh -= add_tools->get_h();
467 add_subwindow(folder_list = new AWindowFolders(mwindow,
468 this, fx, fy, fw, fh));
473 //int x = mwindow->theme->abuttons_x;
474 //int y = mwindow->theme->abuttons_y;
478 newfolder_thread = new NewFolderThread(mwindow, this);
480 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
481 asset_menu->create_objects();
485 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
488 assetlist_menu->create_objects();
492 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
493 folderlist_menu->create_objects();
494 //printf("AWindowGUI::create_objects 2\n");
500 int AWindowGUI::resize_event(int w, int h)
502 mwindow->session->awindow_x = get_x();
503 mwindow->session->awindow_y = get_y();
504 mwindow->session->awindow_w = w;
505 mwindow->session->awindow_h = h;
507 mwindow->theme->get_awindow_sizes(this);
508 mwindow->theme->draw_awindow_bg(this);
510 asset_list->reposition_window(mwindow->theme->alist_x,
511 mwindow->theme->alist_y,
512 mwindow->theme->alist_w,
513 mwindow->theme->alist_h);
514 divider->reposition_window(mwindow->theme->adivider_x,
515 mwindow->theme->adivider_y,
516 mwindow->theme->adivider_w,
517 mwindow->theme->adivider_h);
519 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
520 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
521 add_tools->reposition_window(fx, fy, fw, add_tools->get_h());
522 fy += add_tools->get_h(); fh -= add_tools->get_h();
523 folder_list->reposition_window(fx, fy, fw, fh);
525 // int x = mwindow->theme->abuttons_x;
526 // int y = mwindow->theme->abuttons_y;
527 // new_bin->reposition_window(x, y);
528 // x += new_bin->get_w();
529 // delete_bin->reposition_window(x, y);
530 // x += delete_bin->get_w();
531 // rename_bin->reposition_window(x, y);
532 // x += rename_bin->get_w();
533 // delete_disk->reposition_window(x, y);
534 // x += delete_disk->get_w();
535 // delete_project->reposition_window(x, y);
536 // x += delete_project->get_w();
537 // info->reposition_window(x, y);
538 // x += info->get_w();
539 // redraw_index->reposition_window(x, y);
540 // x += redraw_index->get_w();
541 // paste->reposition_window(x, y);
542 // x += paste->get_w();
543 // append->reposition_window(x, y);
544 // x += append->get_w();
545 // view->reposition_window(x, y);
547 BC_WindowBase::resize_event(w, h);
551 int AWindowGUI::translation_event()
553 mwindow->session->awindow_x = get_x();
554 mwindow->session->awindow_y = get_y();
558 void AWindowGUI::reposition_objects()
560 mwindow->theme->get_awindow_sizes(this);
561 asset_list->reposition_window(mwindow->theme->alist_x,
562 mwindow->theme->alist_y,
563 mwindow->theme->alist_w,
564 mwindow->theme->alist_h);
565 divider->reposition_window(mwindow->theme->adivider_x,
566 mwindow->theme->adivider_y,
567 mwindow->theme->adivider_w,
568 mwindow->theme->adivider_h);
569 folder_list->reposition_window(mwindow->theme->afolders_x,
570 mwindow->theme->afolders_y,
571 mwindow->theme->afolders_w,
572 mwindow->theme->afolders_h);
576 int AWindowGUI::close_event()
579 mwindow->session->show_awindow = 0;
582 mwindow->gui->lock_window("AWindowGUI::close_event");
583 mwindow->gui->mainmenu->show_awindow->set_checked(0);
584 mwindow->gui->unlock_window();
586 lock_window("AWindowGUI::close_event");
587 mwindow->save_defaults();
591 AWindowRemovePluginGUI::
592 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
593 int x, int y, PluginServer *plugin)
594 : BC_Window(PROGRAM_NAME ": Remove plugin", x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
596 this->awindow = awindow;
597 this->thread = thread;
598 this->plugin = plugin;
599 VFrame *vframe = plugin->get_picon();
600 icon = vframe ? create_pixmap(vframe) : 0;
601 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
604 AWindowRemovePluginGUI::
605 ~AWindowRemovePluginGUI()
607 if( !awindow->gui->protected_pixmap(icon) )
609 plugin_list.remove_all();
612 void AWindowRemovePluginGUI::create_objects()
614 BC_Button *ok_button = new BC_OKButton(this);
615 add_subwindow(ok_button);
616 BC_Button *cancel_button = new BC_CancelButton(this);
617 add_subwindow(cancel_button);
619 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
620 add_subwindow(title);
621 y += title->get_h() + 5;
622 list = new BC_ListBox(x, y,
623 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
624 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
629 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
632 for( int i=0; i<folder.size(); ) {
633 AssetPicon *picon = (AssetPicon *)folder[i];
634 if( picon->plugin == plugin ) {
635 folder.remove_object_number(i);
644 void AWindowRemovePlugin::handle_close_event(int result)
647 printf("remove %s\n", plugin->path);
648 ArrayList<BC_ListBoxItem*> *folder =
649 plugin->audio ? plugin->transition ?
650 &awindow->gui->atransitions :
651 &awindow->gui->aeffects :
652 plugin->video ? plugin->transition ?
653 &awindow->gui->vtransitions :
654 &awindow->gui->veffects :
656 if( folder ) remove_plugin(plugin, *folder);
657 awindow->gui->update_assets();
658 char png_path[BCTEXTLEN], plugin_path[BCTEXTLEN], index_path[BCTEXTLEN];
659 strcpy(plugin_path, plugin->path);
660 if( !plugin->get_plugin_png_path(png_path) ) png_path[0] = 0;
661 MWindow *mwindow = awindow->mwindow;
662 sprintf(index_path, "%s/%s", mwindow->preferences->plugin_dir, PLUGIN_FILE);
663 mwindow->plugindb->remove(plugin);
664 plugin->delete_this();
666 if( png_path[0] ) remove(png_path);
671 AWindowRemovePlugin::
672 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
675 this->awindow = awindow;
676 this->plugin = plugin;
679 AWindowRemovePlugin::
680 ~AWindowRemovePlugin()
684 BC_Window* AWindowRemovePlugin::new_gui()
686 int x = awindow->gui->get_abs_cursor_x(0);
687 int y = awindow->gui->get_abs_cursor_y(0);
688 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
689 gui->create_objects();
693 int AWindowGUI::keypress_event()
695 switch(get_keypress()) {
704 PluginServer* plugin = selected_plugin();
706 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
708 remove_plugin->start();
715 void AWindowGUI::update_folder_list()
717 //printf("AWindowGUI::update_folder_list 1\n");
718 for(int i = 0; i < folders.total; i++)
720 AssetPicon *picon = (AssetPicon*)folders.values[i];
723 //printf("AWindowGUI::update_folder_list 1\n");
725 // Search assets for folders
726 for(int i = 0; i < mwindow->edl->folders.total; i++)
728 char *folder = mwindow->edl->folders.values[i];
730 //printf("AWindowGUI::update_folder_list 1.1\n");
732 for(int j = 0; j < folders.total; j++)
734 AssetPicon *picon = (AssetPicon*)folders.values[j];
735 if(!strcasecmp(picon->get_text(), folder))
745 AssetPicon *picon = new AssetPicon(mwindow, this, folder);
746 picon->create_objects();
747 folders.append(picon);
749 //printf("AWindowGUI::update_folder_list 1.3\n");
751 //printf("AWindowGUI::update_folder_list 1\n");
752 //for(int i = 0; i < folders.total; i++)
753 // printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
756 for(int i = folders.total - 1; i >= 0; i--)
758 AssetPicon *picon = (AssetPicon*)folders.values[i];
759 if(!picon->in_use && !picon->persistent)
762 folders.remove_number(i);
765 //for(int i = 0; i < folders.total; i++)
766 // printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
767 //printf("AWindowGUI::update_folder_list 2\n");
770 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
771 int do_audio, int do_video, int is_realtime, int is_transition)
773 ArrayList<PluginServer*> plugin_list;
774 // Get pointers to plugindb entries
775 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
778 for(int i = 0; i < plugin_list.total; i++) {
779 PluginServer *server = plugin_list.values[i];
780 int visible = plugin_visibility & (1<<server->dir_idx);
781 if(!visible) continue;
782 // Create new listitem
783 AssetPicon *picon = new AssetPicon(mwindow, this, server);
784 picon->create_objects();
785 output->append(picon);
789 void AWindowGUI::update_asset_list()
791 //printf("AWindowGUI::update_asset_list 1\n");
792 for(int i = 0; i < assets.total; i++)
794 AssetPicon *picon = (AssetPicon*)assets.values[i];
802 //printf("AWindowGUI::update_asset_list 2\n");
805 // Synchronize EDL clips
806 for(int i = 0; i < mwindow->edl->clips.total; i++)
810 // Look for clip in existing listitems
811 for(int j = 0; j < assets.total && !exists; j++)
813 AssetPicon *picon = (AssetPicon*)assets.values[j];
815 if(picon->id == mwindow->edl->clips.values[i]->id)
817 picon->edl = mwindow->edl->clips.values[i];
818 picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title);
824 // Create new listitem
827 AssetPicon *picon = new AssetPicon(mwindow,
829 mwindow->edl->clips.values[i]);
830 picon->create_objects();
831 assets.append(picon);
839 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
842 // Synchronize EDL assets
843 for(Asset *current = mwindow->edl->assets->first;
849 // Look for asset in existing listitems
850 for(int j = 0; j < assets.total && !exists; j++)
852 AssetPicon *picon = (AssetPicon*)assets.values[j];
854 if(picon->id == current->id)
856 picon->indexable = current;
863 // Create new listitem
866 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
867 AssetPicon *picon = new AssetPicon(mwindow, this, current);
868 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
869 picon->create_objects();
870 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
871 assets.append(picon);
877 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
880 // Synchronize nested EDLs
881 for(int i = 0; i < mwindow->edl->nested_edls->size(); i++)
884 Indexable *indexable = mwindow->edl->nested_edls->get(i);
886 // Look for asset in existing listitems
887 for(int j = 0; j < assets.total && !exists; j++)
889 AssetPicon *picon = (AssetPicon*)assets.values[j];
891 if(picon->id == indexable->id)
893 picon->indexable = indexable;
900 // Create new listitem
903 AssetPicon *picon = new AssetPicon(mwindow,
906 picon->create_objects();
907 assets.append(picon);
919 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
920 for(int i = assets.size() - 1; i >= 0; i--)
922 AssetPicon *picon = (AssetPicon*)assets.get(i);
923 //printf("AWindowGUI::update_asset_list %s %d\n", picon->asset->path, picon->in_use);
927 assets.remove_number(i);
930 //printf("AWindowGUI::update_asset_list 7 %d\n", assets.total);
937 void AWindowGUI::sort_assets()
939 //printf("AWindowGUI::sort_assets 1 %s\n", mwindow->edl->session->current_folder);
940 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
941 sort_picons(&aeffects,
944 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
945 sort_picons(&veffects,
948 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
949 sort_picons(&atransitions,
952 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
953 sort_picons(&vtransitions,
957 mwindow->edl->session->current_folder);
972 void AWindowGUI::collect_assets()
975 mwindow->session->drag_assets->remove_all();
976 mwindow->session->drag_clips->remove_all();
979 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
982 if(result->indexable) mwindow->session->drag_assets->append(result->indexable);
983 if(result->edl) mwindow->session->drag_clips->append(result->edl);
987 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
988 ArrayList<BC_ListBoxItem*> *src,
991 // Remove current pointers
993 dst[1].remove_all_objects();
995 // Create new pointers
996 //if(folder) printf("AWindowGUI::copy_picons 1 %s\n", folder);
997 for(int i = 0; i < src->total; i++)
999 AssetPicon *picon = (AssetPicon*)src->values[i];
1000 //printf("AWindowGUI::copy_picons 2 %s\n", picon->asset->folder);
1002 (folder && picon->indexable && !strcasecmp(picon->indexable->folder, folder)) ||
1003 (folder && picon->edl && !strcasecmp(picon->edl->local_session->folder, folder)))
1005 BC_ListBoxItem *item2, *item1;
1006 dst[0].append(item1 = picon);
1008 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1010 dst[1].append(item2 = new BC_ListBoxItem(""));
1011 item1->set_autoplace_text(1);
1012 item2->set_autoplace_text(1);
1013 //printf("AWindowGUI::copy_picons 3 %s\n", picon->get_text());
1018 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src,
1021 //printf("AWindowGUI::sort_picons 1\n")
1026 for(int i = 0; i < src->total - 1; i++)
1028 BC_ListBoxItem *item1 = src->values[i];
1029 BC_ListBoxItem *item2 = src->values[i + 1];
1030 item1->set_autoplace_icon(1);
1031 item2->set_autoplace_icon(1);
1032 item1->set_autoplace_text(1);
1033 item2->set_autoplace_text(1);
1034 if(strcmp(item1->get_text(), item2->get_text()) > 0)
1036 src->values[i + 1] = item1;
1037 src->values[i] = item2;
1045 void AWindowGUI::filter_displayed_assets()
1047 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1048 copy_picons(displayed_assets,
1052 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1053 copy_picons(displayed_assets,
1057 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1058 copy_picons(displayed_assets,
1062 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1063 copy_picons(displayed_assets,
1067 copy_picons(displayed_assets,
1069 mwindow->edl->session->current_folder);
1073 void AWindowGUI::update_assets()
1075 //printf("AWindowGUI::update_assets 1\n");
1076 update_folder_list();
1077 //printf("AWindowGUI::update_assets 2\n");
1078 update_asset_list();
1079 //printf("AWindowGUI::update_assets 3\n");
1080 filter_displayed_assets();
1082 //for(int i = 0; i < folders.total; i++)
1083 //printf("AWindowGUI::update_assets 4\n");
1084 // printf("AWindowGUI::update_assets %s\n", folders.values[i]->get_text());
1085 if(mwindow->edl->session->folderlist_format != folder_list->get_format())
1086 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1087 folder_list->update(&folders,
1091 folder_list->get_xposition(),
1092 folder_list->get_yposition(),
1094 //printf("AWindowGUI::update_assets 5\n");
1096 if(mwindow->edl->session->assetlist_format != asset_list->get_format())
1097 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1100 //printf("AWindowGUI::update_assets 6 %d\n", displayed_assets[0].total);
1101 asset_list->update(displayed_assets,
1103 mwindow->edl->session->asset_columns,
1105 asset_list->get_xposition(),
1106 asset_list->get_yposition(),
1109 //printf("AWindowGUI::update_assets 7\n");
1112 //printf("AWindowGUI::update_assets 8\n");
1116 void AWindowGUI::update_effects()
1118 aeffects.remove_all_objects();
1119 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1120 veffects.remove_all_objects();
1121 create_persistent_folder(&veffects, 0, 1, 1, 0);
1122 atransitions.remove_all_objects();
1123 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1124 vtransitions.remove_all_objects();
1125 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1128 int AWindowGUI::current_folder_number()
1131 for(int i = 0; i < folders.total; i++)
1133 if(!strcasecmp(folders.values[i]->get_text(), mwindow->edl->session->current_folder))
1142 int AWindowGUI::drag_motion()
1144 if(get_hidden()) return 0;
1150 int AWindowGUI::drag_stop()
1152 if(get_hidden()) return 0;
1157 Indexable* AWindowGUI::selected_asset()
1159 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1160 return picon ? picon->indexable : 0;
1163 PluginServer* AWindowGUI::selected_plugin()
1165 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1166 return picon ? picon->plugin : 0;
1169 AssetPicon* AWindowGUI::selected_folder()
1171 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1184 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1185 : BC_SubWindow(x, y, w, h)
1187 this->mwindow = mwindow;
1190 AWindowDivider::~AWindowDivider()
1194 int AWindowDivider::button_press_event()
1196 if(is_event_win() && cursor_inside())
1198 mwindow->session->current_operation = DRAG_PARTITION;
1204 int AWindowDivider::cursor_motion_event()
1206 if(mwindow->session->current_operation == DRAG_PARTITION)
1208 mwindow->session->afolders_w = gui->get_relative_cursor_x();
1209 gui->reposition_objects();
1214 int AWindowDivider::button_release_event()
1216 if(mwindow->session->current_operation == DRAG_PARTITION)
1218 mwindow->session->current_operation = NO_OPERATION;
1229 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1234 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
1235 LISTBOX_ICONS : LISTBOX_TEXT,
1236 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
1237 0, // Titles for columns. Set to 0 for no titles
1238 0, // width of each column
1239 1, // Total columns.
1240 0, // Pixel of top of window.
1241 0, // If this listbox is a popup window
1242 LISTBOX_SINGLE, // Select one item or multiple items
1243 ICON_TOP, // Position of icon relative to text of each item
1246 this->mwindow = mwindow;
1251 AWindowFolders::~AWindowFolders()
1255 int AWindowFolders::selection_changed()
1257 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1260 if(get_button_down() && get_buttonpress() == 3)
1262 gui->folderlist_menu->update_titles();
1263 gui->folderlist_menu->activate_menu();
1266 strcpy(mwindow->edl->session->current_folder, picon->get_text());
1267 //printf("AWindowFolders::selection_changed 1\n");
1268 gui->asset_list->draw_background();
1269 gui->update_assets();
1274 int AWindowFolders::button_press_event()
1278 result = BC_ListBox::button_press_event();
1282 if(get_buttonpress() == 3 && is_event_win() && cursor_inside())
1284 gui->folderlist_menu->update_titles();
1285 gui->folderlist_menu->activate_menu();
1300 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1305 mwindow->edl->session->assetlist_format == ASSETS_ICONS ?
1306 LISTBOX_ICONS : LISTBOX_TEXT,
1307 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
1308 gui->asset_titles, // Titles for columns. Set to 0 for no titles
1309 mwindow->edl->session->asset_columns, // width of each column
1310 1, // Total columns.
1311 0, // Pixel of top of window.
1312 0, // If this listbox is a popup window
1313 LISTBOX_MULTIPLE, // Select one item or multiple items
1314 ICON_TOP, // Position of icon relative to text of each item
1317 this->mwindow = mwindow;
1322 AWindowAssets::~AWindowAssets()
1326 int AWindowAssets::button_press_event()
1330 result = BC_ListBox::button_press_event();
1332 if(!result && get_buttonpress() == 3 && is_event_win() && cursor_inside())
1334 BC_ListBox::deactivate_selection();
1335 gui->assetlist_menu->update_titles();
1336 gui->assetlist_menu->activate_menu();
1345 int AWindowAssets::handle_event()
1347 //printf("AWindowAssets::handle_event 1 %d %d\n", get_buttonpress(), get_selection(0, 0));
1348 if(get_selection(0, 0))
1350 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1354 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1358 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1362 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1366 if(mwindow->vwindows.size())
1368 //printf("AWindowAssets::handle_event 2 %d %d\n", get_buttonpress(), get_selection(0, 0));
1369 mwindow->vwindows.get(DEFAULT_VWINDOW)->gui->lock_window("AWindowAssets::handle_event");
1371 if(((AssetPicon*)get_selection(0, 0))->indexable)
1372 mwindow->vwindows.get(DEFAULT_VWINDOW)->change_source(((AssetPicon*)get_selection(0, 0))->indexable);
1374 if(((AssetPicon*)get_selection(0, 0))->edl)
1375 mwindow->vwindows.get(DEFAULT_VWINDOW)->change_source(((AssetPicon*)get_selection(0, 0))->edl);
1377 mwindow->vwindows.get(DEFAULT_VWINDOW)->gui->unlock_window();
1385 int AWindowAssets::selection_changed()
1387 // Show popup window
1388 if(get_button_down() && get_buttonpress() == 3 && get_selection(0, 0))
1390 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER) ||
1391 !strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER) ||
1392 !strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER) ||
1393 !strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1395 gui->assetlist_menu->update_titles();
1396 gui->assetlist_menu->activate_menu();
1400 if(((AssetPicon*)get_selection(0, 0))->indexable)
1401 gui->asset_menu->update();
1403 if(((AssetPicon*)get_selection(0, 0))->edl)
1404 gui->asset_menu->update();
1408 gui->asset_menu->activate_menu();
1411 BC_ListBox::deactivate_selection();
1417 void AWindowAssets::draw_background()
1419 clear_box(0,0,get_w(),get_h(),get_bg_surface());
1421 set_font(LARGEFONT);
1423 get_text_width(LARGEFONT, mwindow->edl->session->current_folder) - 4,
1425 mwindow->edl->session->current_folder,
1430 int AWindowAssets::drag_start_event()
1432 int collect_pluginservers = 0;
1433 int collect_assets = 0;
1435 if(BC_ListBox::drag_start_event())
1437 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1439 mwindow->session->current_operation = DRAG_AEFFECT;
1440 collect_pluginservers = 1;
1443 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1445 mwindow->session->current_operation = DRAG_VEFFECT;
1446 collect_pluginservers = 1;
1449 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1451 mwindow->session->current_operation = DRAG_ATRANSITION;
1452 collect_pluginservers = 1;
1455 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1457 mwindow->session->current_operation = DRAG_VTRANSITION;
1458 collect_pluginservers = 1;
1462 mwindow->session->current_operation = DRAG_ASSET;
1467 if(collect_pluginservers)
1470 mwindow->session->drag_pluginservers->remove_all();
1473 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
1476 mwindow->session->drag_pluginservers->append(result->plugin);
1482 gui->collect_assets();
1490 int AWindowAssets::drag_motion_event()
1492 BC_ListBox::drag_motion_event();
1495 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1496 mwindow->gui->drag_motion();
1497 mwindow->gui->unlock_window();
1499 for(int i = 0; i < mwindow->vwindows.size(); i++)
1501 VWindow *vwindow = mwindow->vwindows.get(i);
1502 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1503 vwindow->gui->drag_motion();
1504 vwindow->gui->unlock_window();
1507 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1508 mwindow->cwindow->gui->drag_motion();
1509 mwindow->cwindow->gui->unlock_window();
1511 lock_window("AWindowAssets::drag_motion_event");
1515 int AWindowAssets::drag_stop_event()
1519 result = gui->drag_stop();
1525 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1526 result = mwindow->gui->drag_stop();
1527 mwindow->gui->unlock_window();
1532 for(int i = 0; i < mwindow->vwindows.size(); i++)
1534 VWindow *vwindow = mwindow->vwindows.get(i);
1535 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1536 result = vwindow->gui->drag_stop();
1537 vwindow->gui->unlock_window();
1543 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1544 result = mwindow->cwindow->gui->drag_stop();
1545 mwindow->cwindow->gui->unlock_window();
1548 lock_window("AWindowAssets::drag_stop_event");
1550 if(result) get_drag_popup()->set_animation(0);
1552 BC_ListBox::drag_stop_event();
1553 mwindow->session->current_operation = ::NO_OPERATION; // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
1557 int AWindowAssets::column_resize_event()
1559 mwindow->edl->session->asset_columns[0] = get_column_width(0);
1560 mwindow->edl->session->asset_columns[1] = get_column_width(1);
1575 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1576 : BC_Button(x, y, mwindow->theme->newbin_data)
1578 this->mwindow = mwindow;
1580 set_tooltip(_("New bin"));
1583 int AWindowNewFolder::handle_event()
1585 gui->newfolder_thread->start_new_folder();
1589 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1590 : BC_Button(x, y, mwindow->theme->deletebin_data)
1592 this->mwindow = mwindow;
1594 set_tooltip(_("Delete bin"));
1597 int AWindowDeleteFolder::handle_event()
1599 if(gui->folder_list->get_selection(0, 0))
1601 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
1602 mwindow->delete_folder(folder->get_text());
1607 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1608 : BC_Button(x, y, mwindow->theme->renamebin_data)
1610 this->mwindow = mwindow;
1612 set_tooltip(_("Rename bin"));
1615 int AWindowRenameFolder::handle_event()
1620 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1621 : BC_Button(x, y, mwindow->theme->deletedisk_data)
1623 this->mwindow = mwindow;
1625 set_tooltip(_("Delete asset from disk"));
1628 int AWindowDeleteDisk::handle_event()
1633 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1634 : BC_Button(x, y, mwindow->theme->deleteproject_data)
1636 this->mwindow = mwindow;
1638 set_tooltip(_("Delete asset from project"));
1641 int AWindowDeleteProject::handle_event()
1646 AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1647 : BC_Button(x, y, mwindow->theme->infoasset_data)
1649 this->mwindow = mwindow;
1651 set_tooltip(_("Edit information on asset"));
1654 int AWindowInfo::handle_event()
1656 gui->awindow->asset_edit->edit_asset(gui->selected_asset());
1660 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1661 : BC_Button(x, y, mwindow->theme->redrawindex_data)
1663 this->mwindow = mwindow;
1665 set_tooltip(_("Redraw index"));
1668 int AWindowRedrawIndex::handle_event()
1673 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1674 : BC_Button(x, y, mwindow->theme->pasteasset_data)
1676 this->mwindow = mwindow;
1678 set_tooltip(_("Paste asset on recordable tracks"));
1681 int AWindowPaste::handle_event()
1686 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1687 : BC_Button(x, y, mwindow->theme->appendasset_data)
1689 this->mwindow = mwindow;
1691 set_tooltip(_("Append asset in new tracks"));
1694 int AWindowAppend::handle_event()
1699 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1700 : BC_Button(x, y, mwindow->theme->viewasset_data)
1702 this->mwindow = mwindow;
1704 set_tooltip(_("View asset"));
1707 int AWindowView::handle_event()
1712 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w)
1713 : BC_MenuBar(x, y, w)
1715 this->mwindow = mwindow;
1719 void AddTools::create_objects()
1721 add_menu(add_plugins = new AddPluginsMenu(mwindow, gui));
1722 add_plugins->create_objects();
1725 AddPluginsMenu::AddPluginsMenu(MWindow *mwindow, AWindowGUI *gui)
1726 : BC_Menu("Add Tools")
1728 this->mwindow = mwindow;
1732 void AddPluginsMenu::create_objects()
1735 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
1736 PluginServer *plugin = MWindow::plugindb->get(i);
1737 if( !plugin->audio && !plugin->video ) continue;
1738 int idx = plugin->dir_idx;
1739 uint32_t msk = 1 << idx;
1740 if( (msk & vis) != 0 ) continue;
1742 char parent[BCTEXTLEN];
1743 strcpy(parent, plugin->path);
1744 char *cp = strrchr(parent, '/');
1747 char *bp = strrchr(parent, '/');
1748 if( !bp ) bp = parent; else ++bp;
1749 if( !strcmp(bp, "ladspa") )
1750 gui->plugin_visibility &= ~(1 << idx);
1751 add_item(new AddPluginItem(this, bp, idx));
1756 AddPluginItem::AddPluginItem(AddPluginsMenu *menu, char const *text, int idx)
1761 uint32_t msk = 1 << idx, vis = menu->gui->plugin_visibility;
1762 int chk = (msk & vis) ? 1 : 0;
1766 int AddPluginItem::handle_event()
1768 int chk = get_checked() ^ 1;
1770 uint32_t msk = 1 << idx, vis = menu->gui->plugin_visibility;
1771 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
1772 menu->gui->update_effects();
1773 menu->gui->update_assets();