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()
685 BC_Window* AWindowRemovePlugin::new_gui()
687 int x = awindow->gui->get_abs_cursor_x(0);
688 int y = awindow->gui->get_abs_cursor_y(0);
689 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
690 gui->create_objects();
694 int AWindowGUI::keypress_event()
696 switch(get_keypress()) {
705 PluginServer* plugin = selected_plugin();
707 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
709 remove_plugin->start();
716 void AWindowGUI::update_folder_list()
718 //printf("AWindowGUI::update_folder_list 1\n");
719 for(int i = 0; i < folders.total; i++)
721 AssetPicon *picon = (AssetPicon*)folders.values[i];
724 //printf("AWindowGUI::update_folder_list 1\n");
726 // Search assets for folders
727 for(int i = 0; i < mwindow->edl->folders.total; i++)
729 char *folder = mwindow->edl->folders.values[i];
731 //printf("AWindowGUI::update_folder_list 1.1\n");
733 for(int j = 0; j < folders.total; j++)
735 AssetPicon *picon = (AssetPicon*)folders.values[j];
736 if(!strcasecmp(picon->get_text(), folder))
746 AssetPicon *picon = new AssetPicon(mwindow, this, folder);
747 picon->create_objects();
748 folders.append(picon);
750 //printf("AWindowGUI::update_folder_list 1.3\n");
752 //printf("AWindowGUI::update_folder_list 1\n");
753 //for(int i = 0; i < folders.total; i++)
754 // printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
757 for(int i = folders.total - 1; i >= 0; i--)
759 AssetPicon *picon = (AssetPicon*)folders.values[i];
760 if(!picon->in_use && !picon->persistent)
763 folders.remove_number(i);
766 //for(int i = 0; i < folders.total; i++)
767 // printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
768 //printf("AWindowGUI::update_folder_list 2\n");
771 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
772 int do_audio, int do_video, int is_realtime, int is_transition)
774 ArrayList<PluginServer*> plugin_list;
775 // Get pointers to plugindb entries
776 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
779 for(int i = 0; i < plugin_list.total; i++) {
780 PluginServer *server = plugin_list.values[i];
781 int visible = plugin_visibility & (1<<server->dir_idx);
782 if(!visible) continue;
783 // Create new listitem
784 AssetPicon *picon = new AssetPicon(mwindow, this, server);
785 picon->create_objects();
786 output->append(picon);
790 void AWindowGUI::update_asset_list()
792 //printf("AWindowGUI::update_asset_list 1\n");
793 for(int i = 0; i < assets.total; i++)
795 AssetPicon *picon = (AssetPicon*)assets.values[i];
803 //printf("AWindowGUI::update_asset_list 2\n");
806 // Synchronize EDL clips
807 for(int i = 0; i < mwindow->edl->clips.total; i++)
811 // Look for clip in existing listitems
812 for(int j = 0; j < assets.total && !exists; j++)
814 AssetPicon *picon = (AssetPicon*)assets.values[j];
816 if(picon->id == mwindow->edl->clips.values[i]->id)
818 picon->edl = mwindow->edl->clips.values[i];
819 picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title);
825 // Create new listitem
828 AssetPicon *picon = new AssetPicon(mwindow,
830 mwindow->edl->clips.values[i]);
831 picon->create_objects();
832 assets.append(picon);
840 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
843 // Synchronize EDL assets
844 for(Asset *current = mwindow->edl->assets->first;
850 // Look for asset in existing listitems
851 for(int j = 0; j < assets.total && !exists; j++)
853 AssetPicon *picon = (AssetPicon*)assets.values[j];
855 if(picon->id == current->id)
857 picon->indexable = current;
864 // Create new listitem
867 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
868 AssetPicon *picon = new AssetPicon(mwindow, this, current);
869 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
870 picon->create_objects();
871 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
872 assets.append(picon);
878 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
881 // Synchronize nested EDLs
882 for(int i = 0; i < mwindow->edl->nested_edls->size(); i++)
885 Indexable *indexable = mwindow->edl->nested_edls->get(i);
887 // Look for asset in existing listitems
888 for(int j = 0; j < assets.total && !exists; j++)
890 AssetPicon *picon = (AssetPicon*)assets.values[j];
892 if(picon->id == indexable->id)
894 picon->indexable = indexable;
901 // Create new listitem
904 AssetPicon *picon = new AssetPicon(mwindow,
907 picon->create_objects();
908 assets.append(picon);
920 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
921 for(int i = assets.size() - 1; i >= 0; i--)
923 AssetPicon *picon = (AssetPicon*)assets.get(i);
924 //printf("AWindowGUI::update_asset_list %s %d\n", picon->asset->path, picon->in_use);
928 assets.remove_number(i);
931 //printf("AWindowGUI::update_asset_list 7 %d\n", assets.total);
938 void AWindowGUI::sort_assets()
940 //printf("AWindowGUI::sort_assets 1 %s\n", mwindow->edl->session->current_folder);
941 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
942 sort_picons(&aeffects,
945 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
946 sort_picons(&veffects,
949 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
950 sort_picons(&atransitions,
953 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
954 sort_picons(&vtransitions,
958 mwindow->edl->session->current_folder);
973 void AWindowGUI::collect_assets()
976 mwindow->session->drag_assets->remove_all();
977 mwindow->session->drag_clips->remove_all();
980 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
983 if(result->indexable) mwindow->session->drag_assets->append(result->indexable);
984 if(result->edl) mwindow->session->drag_clips->append(result->edl);
988 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
989 ArrayList<BC_ListBoxItem*> *src,
992 // Remove current pointers
994 dst[1].remove_all_objects();
996 // Create new pointers
997 //if(folder) printf("AWindowGUI::copy_picons 1 %s\n", folder);
998 for(int i = 0; i < src->total; i++)
1000 AssetPicon *picon = (AssetPicon*)src->values[i];
1001 //printf("AWindowGUI::copy_picons 2 %s\n", picon->asset->folder);
1003 (folder && picon->indexable && !strcasecmp(picon->indexable->folder, folder)) ||
1004 (folder && picon->edl && !strcasecmp(picon->edl->local_session->folder, folder)))
1006 BC_ListBoxItem *item2, *item1;
1007 dst[0].append(item1 = picon);
1009 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1011 dst[1].append(item2 = new BC_ListBoxItem(""));
1012 item1->set_autoplace_text(1);
1013 item2->set_autoplace_text(1);
1014 //printf("AWindowGUI::copy_picons 3 %s\n", picon->get_text());
1019 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src,
1022 //printf("AWindowGUI::sort_picons 1\n")
1027 for(int i = 0; i < src->total - 1; i++)
1029 BC_ListBoxItem *item1 = src->values[i];
1030 BC_ListBoxItem *item2 = src->values[i + 1];
1031 item1->set_autoplace_icon(1);
1032 item2->set_autoplace_icon(1);
1033 item1->set_autoplace_text(1);
1034 item2->set_autoplace_text(1);
1035 if(strcmp(item1->get_text(), item2->get_text()) > 0)
1037 src->values[i + 1] = item1;
1038 src->values[i] = item2;
1046 void AWindowGUI::filter_displayed_assets()
1048 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1049 copy_picons(displayed_assets,
1053 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1054 copy_picons(displayed_assets,
1058 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1059 copy_picons(displayed_assets,
1063 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1064 copy_picons(displayed_assets,
1068 copy_picons(displayed_assets,
1070 mwindow->edl->session->current_folder);
1074 void AWindowGUI::update_assets()
1076 //printf("AWindowGUI::update_assets 1\n");
1077 update_folder_list();
1078 //printf("AWindowGUI::update_assets 2\n");
1079 update_asset_list();
1080 //printf("AWindowGUI::update_assets 3\n");
1081 filter_displayed_assets();
1083 //for(int i = 0; i < folders.total; i++)
1084 //printf("AWindowGUI::update_assets 4\n");
1085 // printf("AWindowGUI::update_assets %s\n", folders.values[i]->get_text());
1086 if(mwindow->edl->session->folderlist_format != folder_list->get_format())
1087 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1088 folder_list->update(&folders,
1092 folder_list->get_xposition(),
1093 folder_list->get_yposition(),
1095 //printf("AWindowGUI::update_assets 5\n");
1097 if(mwindow->edl->session->assetlist_format != asset_list->get_format())
1098 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1101 //printf("AWindowGUI::update_assets 6 %d\n", displayed_assets[0].total);
1102 asset_list->update(displayed_assets,
1104 mwindow->edl->session->asset_columns,
1106 asset_list->get_xposition(),
1107 asset_list->get_yposition(),
1110 //printf("AWindowGUI::update_assets 7\n");
1113 //printf("AWindowGUI::update_assets 8\n");
1117 void AWindowGUI::update_effects()
1119 aeffects.remove_all_objects();
1120 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1121 veffects.remove_all_objects();
1122 create_persistent_folder(&veffects, 0, 1, 1, 0);
1123 atransitions.remove_all_objects();
1124 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1125 vtransitions.remove_all_objects();
1126 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1129 int AWindowGUI::current_folder_number()
1132 for(int i = 0; i < folders.total; i++)
1134 if(!strcasecmp(folders.values[i]->get_text(), mwindow->edl->session->current_folder))
1143 int AWindowGUI::drag_motion()
1145 if(get_hidden()) return 0;
1151 int AWindowGUI::drag_stop()
1153 if(get_hidden()) return 0;
1158 Indexable* AWindowGUI::selected_asset()
1160 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1161 return picon ? picon->indexable : 0;
1164 PluginServer* AWindowGUI::selected_plugin()
1166 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1167 return picon ? picon->plugin : 0;
1170 AssetPicon* AWindowGUI::selected_folder()
1172 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1185 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1186 : BC_SubWindow(x, y, w, h)
1188 this->mwindow = mwindow;
1191 AWindowDivider::~AWindowDivider()
1195 int AWindowDivider::button_press_event()
1197 if(is_event_win() && cursor_inside())
1199 mwindow->session->current_operation = DRAG_PARTITION;
1205 int AWindowDivider::cursor_motion_event()
1207 if(mwindow->session->current_operation == DRAG_PARTITION)
1209 mwindow->session->afolders_w = gui->get_relative_cursor_x();
1210 gui->reposition_objects();
1215 int AWindowDivider::button_release_event()
1217 if(mwindow->session->current_operation == DRAG_PARTITION)
1219 mwindow->session->current_operation = NO_OPERATION;
1230 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1235 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
1236 LISTBOX_ICONS : LISTBOX_TEXT,
1237 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
1238 0, // Titles for columns. Set to 0 for no titles
1239 0, // width of each column
1240 1, // Total columns.
1241 0, // Pixel of top of window.
1242 0, // If this listbox is a popup window
1243 LISTBOX_SINGLE, // Select one item or multiple items
1244 ICON_TOP, // Position of icon relative to text of each item
1247 this->mwindow = mwindow;
1252 AWindowFolders::~AWindowFolders()
1256 int AWindowFolders::selection_changed()
1258 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1261 if(get_button_down() && get_buttonpress() == 3)
1263 gui->folderlist_menu->update_titles();
1264 gui->folderlist_menu->activate_menu();
1267 strcpy(mwindow->edl->session->current_folder, picon->get_text());
1268 //printf("AWindowFolders::selection_changed 1\n");
1269 gui->asset_list->draw_background();
1270 gui->update_assets();
1275 int AWindowFolders::button_press_event()
1279 result = BC_ListBox::button_press_event();
1283 if(get_buttonpress() == 3 && is_event_win() && cursor_inside())
1285 gui->folderlist_menu->update_titles();
1286 gui->folderlist_menu->activate_menu();
1301 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1306 mwindow->edl->session->assetlist_format == ASSETS_ICONS ?
1307 LISTBOX_ICONS : LISTBOX_TEXT,
1308 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
1309 gui->asset_titles, // Titles for columns. Set to 0 for no titles
1310 mwindow->edl->session->asset_columns, // width of each column
1311 1, // Total columns.
1312 0, // Pixel of top of window.
1313 0, // If this listbox is a popup window
1314 LISTBOX_MULTIPLE, // Select one item or multiple items
1315 ICON_TOP, // Position of icon relative to text of each item
1318 this->mwindow = mwindow;
1323 AWindowAssets::~AWindowAssets()
1327 int AWindowAssets::button_press_event()
1331 result = BC_ListBox::button_press_event();
1333 if(!result && get_buttonpress() == 3 && is_event_win() && cursor_inside())
1335 BC_ListBox::deactivate_selection();
1336 gui->assetlist_menu->update_titles();
1337 gui->assetlist_menu->activate_menu();
1346 int AWindowAssets::handle_event()
1348 //printf("AWindowAssets::handle_event 1 %d %d\n", get_buttonpress(), get_selection(0, 0));
1349 if(get_selection(0, 0))
1351 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1355 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1359 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1363 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1367 if(mwindow->vwindows.size())
1369 //printf("AWindowAssets::handle_event 2 %d %d\n", get_buttonpress(), get_selection(0, 0));
1370 mwindow->vwindows.get(DEFAULT_VWINDOW)->gui->lock_window("AWindowAssets::handle_event");
1372 if(((AssetPicon*)get_selection(0, 0))->indexable)
1373 mwindow->vwindows.get(DEFAULT_VWINDOW)->change_source(((AssetPicon*)get_selection(0, 0))->indexable);
1375 if(((AssetPicon*)get_selection(0, 0))->edl)
1376 mwindow->vwindows.get(DEFAULT_VWINDOW)->change_source(((AssetPicon*)get_selection(0, 0))->edl);
1378 mwindow->vwindows.get(DEFAULT_VWINDOW)->gui->unlock_window();
1386 int AWindowAssets::selection_changed()
1388 // Show popup window
1389 if(get_button_down() && get_buttonpress() == 3 && get_selection(0, 0))
1391 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER) ||
1392 !strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER) ||
1393 !strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER) ||
1394 !strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1396 gui->assetlist_menu->update_titles();
1397 gui->assetlist_menu->activate_menu();
1401 if(((AssetPicon*)get_selection(0, 0))->indexable)
1402 gui->asset_menu->update();
1404 if(((AssetPicon*)get_selection(0, 0))->edl)
1405 gui->asset_menu->update();
1409 gui->asset_menu->activate_menu();
1412 BC_ListBox::deactivate_selection();
1418 void AWindowAssets::draw_background()
1420 clear_box(0,0,get_w(),get_h(),get_bg_surface());
1422 set_font(LARGEFONT);
1424 get_text_width(LARGEFONT, mwindow->edl->session->current_folder) - 4,
1426 mwindow->edl->session->current_folder,
1431 int AWindowAssets::drag_start_event()
1433 int collect_pluginservers = 0;
1434 int collect_assets = 0;
1436 if(BC_ListBox::drag_start_event())
1438 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1440 mwindow->session->current_operation = DRAG_AEFFECT;
1441 collect_pluginservers = 1;
1444 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1446 mwindow->session->current_operation = DRAG_VEFFECT;
1447 collect_pluginservers = 1;
1450 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1452 mwindow->session->current_operation = DRAG_ATRANSITION;
1453 collect_pluginservers = 1;
1456 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1458 mwindow->session->current_operation = DRAG_VTRANSITION;
1459 collect_pluginservers = 1;
1463 mwindow->session->current_operation = DRAG_ASSET;
1468 if(collect_pluginservers)
1471 mwindow->session->drag_pluginservers->remove_all();
1474 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
1477 mwindow->session->drag_pluginservers->append(result->plugin);
1483 gui->collect_assets();
1491 int AWindowAssets::drag_motion_event()
1493 BC_ListBox::drag_motion_event();
1496 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1497 mwindow->gui->drag_motion();
1498 mwindow->gui->unlock_window();
1500 for(int i = 0; i < mwindow->vwindows.size(); i++)
1502 VWindow *vwindow = mwindow->vwindows.get(i);
1503 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1504 vwindow->gui->drag_motion();
1505 vwindow->gui->unlock_window();
1508 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1509 mwindow->cwindow->gui->drag_motion();
1510 mwindow->cwindow->gui->unlock_window();
1512 lock_window("AWindowAssets::drag_motion_event");
1516 int AWindowAssets::drag_stop_event()
1520 result = gui->drag_stop();
1526 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1527 result = mwindow->gui->drag_stop();
1528 mwindow->gui->unlock_window();
1533 for(int i = 0; i < mwindow->vwindows.size(); i++)
1535 VWindow *vwindow = mwindow->vwindows.get(i);
1536 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1537 result = vwindow->gui->drag_stop();
1538 vwindow->gui->unlock_window();
1544 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1545 result = mwindow->cwindow->gui->drag_stop();
1546 mwindow->cwindow->gui->unlock_window();
1549 lock_window("AWindowAssets::drag_stop_event");
1551 if(result) get_drag_popup()->set_animation(0);
1553 BC_ListBox::drag_stop_event();
1554 mwindow->session->current_operation = ::NO_OPERATION; // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
1558 int AWindowAssets::column_resize_event()
1560 mwindow->edl->session->asset_columns[0] = get_column_width(0);
1561 mwindow->edl->session->asset_columns[1] = get_column_width(1);
1576 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1577 : BC_Button(x, y, mwindow->theme->newbin_data)
1579 this->mwindow = mwindow;
1581 set_tooltip(_("New bin"));
1584 int AWindowNewFolder::handle_event()
1586 gui->newfolder_thread->start_new_folder();
1590 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1591 : BC_Button(x, y, mwindow->theme->deletebin_data)
1593 this->mwindow = mwindow;
1595 set_tooltip(_("Delete bin"));
1598 int AWindowDeleteFolder::handle_event()
1600 if(gui->folder_list->get_selection(0, 0))
1602 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
1603 mwindow->delete_folder(folder->get_text());
1608 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1609 : BC_Button(x, y, mwindow->theme->renamebin_data)
1611 this->mwindow = mwindow;
1613 set_tooltip(_("Rename bin"));
1616 int AWindowRenameFolder::handle_event()
1621 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1622 : BC_Button(x, y, mwindow->theme->deletedisk_data)
1624 this->mwindow = mwindow;
1626 set_tooltip(_("Delete asset from disk"));
1629 int AWindowDeleteDisk::handle_event()
1634 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1635 : BC_Button(x, y, mwindow->theme->deleteproject_data)
1637 this->mwindow = mwindow;
1639 set_tooltip(_("Delete asset from project"));
1642 int AWindowDeleteProject::handle_event()
1647 AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1648 : BC_Button(x, y, mwindow->theme->infoasset_data)
1650 this->mwindow = mwindow;
1652 set_tooltip(_("Edit information on asset"));
1655 int AWindowInfo::handle_event()
1657 gui->awindow->asset_edit->edit_asset(gui->selected_asset());
1661 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1662 : BC_Button(x, y, mwindow->theme->redrawindex_data)
1664 this->mwindow = mwindow;
1666 set_tooltip(_("Redraw index"));
1669 int AWindowRedrawIndex::handle_event()
1674 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1675 : BC_Button(x, y, mwindow->theme->pasteasset_data)
1677 this->mwindow = mwindow;
1679 set_tooltip(_("Paste asset on recordable tracks"));
1682 int AWindowPaste::handle_event()
1687 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1688 : BC_Button(x, y, mwindow->theme->appendasset_data)
1690 this->mwindow = mwindow;
1692 set_tooltip(_("Append asset in new tracks"));
1695 int AWindowAppend::handle_event()
1700 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1701 : BC_Button(x, y, mwindow->theme->viewasset_data)
1703 this->mwindow = mwindow;
1705 set_tooltip(_("View asset"));
1708 int AWindowView::handle_event()
1713 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w)
1714 : BC_MenuBar(x, y, w)
1716 this->mwindow = mwindow;
1720 void AddTools::create_objects()
1722 add_menu(add_plugins = new AddPluginsMenu(mwindow, gui));
1723 add_plugins->create_objects();
1726 AddPluginsMenu::AddPluginsMenu(MWindow *mwindow, AWindowGUI *gui)
1727 : BC_Menu("Add Tools")
1729 this->mwindow = mwindow;
1733 void AddPluginsMenu::create_objects()
1736 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
1737 PluginServer *plugin = MWindow::plugindb->get(i);
1738 if( !plugin->audio && !plugin->video ) continue;
1739 int idx = plugin->dir_idx;
1740 uint32_t msk = 1 << idx;
1741 if( (msk & vis) != 0 ) continue;
1743 char parent[BCTEXTLEN];
1744 strcpy(parent, plugin->path);
1745 char *cp = strrchr(parent, '/');
1748 char *bp = strrchr(parent, '/');
1749 if( !bp ) bp = parent; else ++bp;
1750 if( !strcmp(bp, "ladspa") )
1751 gui->plugin_visibility &= ~(1 << idx);
1752 add_item(new AddPluginItem(this, bp, idx));
1757 AddPluginItem::AddPluginItem(AddPluginsMenu *menu, char const *text, int idx)
1762 uint32_t msk = 1 << idx, vis = menu->gui->plugin_visibility;
1763 int chk = (msk & vis) ? 1 : 0;
1767 int AddPluginItem::handle_event()
1769 int chk = get_checked() ^ 1;
1771 uint32_t msk = 1 << idx, vis = menu->gui->plugin_visibility;
1772 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
1773 menu->gui->update_effects();
1774 menu->gui->update_assets();