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 "bccmodels.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) ) {
116 if( !plugin ) delete icon_vframe;
120 void AssetPicon::reset()
132 void AssetPicon::create_objects()
135 char name[BCTEXTLEN];
136 int pixmap_w, pixmap_h;
141 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
144 fs.extract_name(name, indexable->path);
148 if(indexable && indexable->is_asset)
150 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
151 Asset *asset = (Asset*)indexable;
152 if(asset->video_data)
154 if(mwindow->preferences->use_thumbnails)
156 gui->unlock_window();
157 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
158 File *file = mwindow->video_cache->check_out(asset,
161 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
165 int height = asset->height > 0 ? asset->height : 1;
166 pixmap_w = pixmap_h * asset->width / height;
169 file->set_video_position(0, 0);
171 if(gui->temp_picon &&
172 (gui->temp_picon->get_w() != asset->width ||
173 gui->temp_picon->get_h() != asset->height))
175 delete gui->temp_picon;
181 gui->temp_picon = new VFrame(0, -1,
182 asset->width, asset->height,
186 file->read_frame(gui->temp_picon);
187 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
188 mwindow->video_cache->check_in(asset);
190 gui->lock_window("AssetPicon::create_objects 1");
191 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
192 icon->draw_vframe(gui->temp_picon,
193 0, 0, pixmap_w, pixmap_h, 0, 0);
194 //printf("%d %d\n", gui->temp_picon->get_w(), gui->temp_picon->get_h());
195 icon_vframe = new VFrame(0,
196 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
197 BC_CModels::transfer(
198 icon_vframe->get_rows(),
199 gui->temp_picon->get_rows(),
200 0, 0, 0, 0, 0, 0, 0, 0,
201 gui->temp_picon->get_w(),
202 gui->temp_picon->get_h(),
203 0, 0, pixmap_w, pixmap_h,
204 BC_RGB888, BC_RGB888,
207 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
212 gui->lock_window("AssetPicon::create_objects 2");
213 icon = gui->video_icon;
214 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
219 icon = gui->video_icon;
220 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
224 if(asset->audio_data)
226 icon = gui->audio_icon;
227 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND];
229 //printf("AssetPicon::create_objects 2\n");
231 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
234 if(indexable && !indexable->is_asset)
236 icon = gui->video_icon;
237 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
242 //printf("AssetPicon::create_objects 4 %s\n", edl->local_session->clip_title);
243 set_text(strcpy(name, edl->local_session->clip_title));
244 icon = gui->clip_icon;
245 icon_vframe = mwindow->theme->get_image("clip_icon");
250 strcpy(name, _(plugin->title));
252 icon_vframe = plugin->get_picon();
254 icon = gui->create_pixmap(icon_vframe);
255 else if( plugin->audio ) {
256 if( plugin->transition ) {
257 icon = gui->atransition_icon;
258 icon_vframe = gui->atransition_vframe;
260 else if( !plugin->is_ladspa() ) {
261 icon = gui->aeffect_icon;
262 icon_vframe = gui->aeffect_vframe;
265 icon = gui->ladspa_icon;
266 icon_vframe = gui->ladspa_vframe;
269 else if( plugin->video ) {
270 if( plugin->transition ) {
271 icon = gui->vtransition_icon;
272 icon_vframe = gui->vtransition_vframe;
275 icon = gui->veffect_icon;
276 icon_vframe = gui->veffect_vframe;
281 icon = gui->file_icon;
282 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
285 set_icon_vframe(icon_vframe);
287 if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
295 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
296 : BC_Window(PROGRAM_NAME ": Resources",
297 mwindow->session->awindow_x,
298 mwindow->session->awindow_y,
299 mwindow->session->awindow_w,
300 mwindow->session->awindow_h,
307 // printf("AWindowGUI::AWindowGUI %d %d %d %d\n",
308 // mwindow->session->awindow_x,
309 // mwindow->session->awindow_y,
310 // mwindow->session->awindow_w,
311 // mwindow->session->awindow_h);
312 this->mwindow = mwindow;
313 this->awindow = awindow;
319 atransition_icon = 0; atransition_vframe = 0;
320 vtransition_icon = 0; vtransition_vframe = 0;
321 aeffect_icon = 0; aeffect_vframe = 0;
322 ladspa_icon = 0; ladspa_vframe = 0;
323 veffect_icon = 0; veffect_vframe = 0;
324 newfolder_thread = 0;
330 plugin_visibility = ~0;
333 AWindowGUI::~AWindowGUI()
335 assets.remove_all_objects();
336 folders.remove_all_objects();
337 aeffects.remove_all_objects();
338 veffects.remove_all_objects();
339 atransitions.remove_all_objects();
340 vtransitions.remove_all_objects();
341 displayed_assets[1].remove_all_objects();
347 delete atransition_icon;
348 delete vtransition_icon;
351 delete ladspa_vframe;
353 delete newfolder_thread;
355 delete assetlist_menu;
356 delete folderlist_menu;
357 if(temp_picon) delete temp_picon;
358 delete remove_plugin;
361 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
363 return icon == file_icon ||
364 icon == audio_icon ||
365 icon == folder_icon ||
367 icon == video_icon ||
368 icon == veffect_icon ||
369 icon == vtransition_icon ||
370 icon == aeffect_icon ||
371 icon == ladspa_icon ||
372 icon == atransition_icon;
375 void AWindowGUI::create_objects()
379 lock_window("AWindowGUI::create_objects");
381 //printf("AWindowGUI::create_objects 1\n");
382 asset_titles[0] = _("Title");
383 asset_titles[1] = _("Comments");
387 set_icon(mwindow->theme->get_image("awindow_icon"));
388 file_icon = new BC_Pixmap(this,
389 BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN],
392 folder_icon = new BC_Pixmap(this,
393 BC_WindowBase::get_resources()->type_to_icon[ICON_FOLDER],
396 audio_icon = new BC_Pixmap(this,
397 BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND],
400 video_icon = new BC_Pixmap(this,
401 BC_WindowBase::get_resources()->type_to_icon[ICON_FILM],
406 clip_vframe = mwindow->theme->get_image("clip_icon");
407 clip_icon = new BC_Pixmap(this, clip_vframe, PIXMAP_ALPHA);
408 atransition_vframe = mwindow->theme->get_image("atransition_icon");
409 atransition_icon = new BC_Pixmap(this, atransition_vframe, PIXMAP_ALPHA);
410 vtransition_vframe = mwindow->theme->get_image("vtransition_icon");
411 vtransition_icon = new BC_Pixmap(this, vtransition_vframe, PIXMAP_ALPHA);
412 aeffect_vframe = mwindow->theme->get_image("aeffect_icon");
413 aeffect_icon = new BC_Pixmap(this, aeffect_vframe, PIXMAP_ALPHA);
414 ladspa_vframe = new VFrame(lad_picon_png);
415 ladspa_icon = new BC_Pixmap(this, ladspa_vframe, PIXMAP_ALPHA);
416 veffect_vframe = mwindow->theme->get_image("veffect_icon");
417 veffect_icon = new BC_Pixmap(this, veffect_vframe, PIXMAP_ALPHA);
422 folders.append(picon = new AssetPicon(mwindow,
425 picon->persistent = 1;
426 folders.append(picon = new AssetPicon(mwindow,
429 picon->persistent = 1;
430 folders.append(picon = new AssetPicon(mwindow,
432 ATRANSITION_FOLDER));
433 picon->persistent = 1;
434 folders.append(picon = new AssetPicon(mwindow,
436 VTRANSITION_FOLDER));
437 picon->persistent = 1;
440 mwindow->theme->get_awindow_sizes(this);
443 add_subwindow(asset_list = new AWindowAssets(mwindow,
445 mwindow->theme->alist_x,
446 mwindow->theme->alist_y,
447 mwindow->theme->alist_w,
448 mwindow->theme->alist_h));
451 add_subwindow(divider = new AWindowDivider(mwindow,
453 mwindow->theme->adivider_x,
454 mwindow->theme->adivider_y,
455 mwindow->theme->adivider_w,
456 mwindow->theme->adivider_h));
459 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
462 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
463 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
464 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, fw));
465 add_tools->create_objects();
466 fy += add_tools->get_h(); fh -= add_tools->get_h();
468 add_subwindow(folder_list = new AWindowFolders(mwindow,
469 this, fx, fy, fw, fh));
474 //int x = mwindow->theme->abuttons_x;
475 //int y = mwindow->theme->abuttons_y;
479 newfolder_thread = new NewFolderThread(mwindow, this);
481 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
482 asset_menu->create_objects();
486 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
489 assetlist_menu->create_objects();
493 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
494 folderlist_menu->create_objects();
495 //printf("AWindowGUI::create_objects 2\n");
501 int AWindowGUI::resize_event(int w, int h)
503 mwindow->session->awindow_x = get_x();
504 mwindow->session->awindow_y = get_y();
505 mwindow->session->awindow_w = w;
506 mwindow->session->awindow_h = h;
508 mwindow->theme->get_awindow_sizes(this);
509 mwindow->theme->draw_awindow_bg(this);
511 asset_list->reposition_window(mwindow->theme->alist_x,
512 mwindow->theme->alist_y,
513 mwindow->theme->alist_w,
514 mwindow->theme->alist_h);
515 divider->reposition_window(mwindow->theme->adivider_x,
516 mwindow->theme->adivider_y,
517 mwindow->theme->adivider_w,
518 mwindow->theme->adivider_h);
520 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
521 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
522 add_tools->reposition_window(fx, fy, fw, add_tools->get_h());
523 fy += add_tools->get_h(); fh -= add_tools->get_h();
524 folder_list->reposition_window(fx, fy, fw, fh);
526 // int x = mwindow->theme->abuttons_x;
527 // int y = mwindow->theme->abuttons_y;
528 // new_bin->reposition_window(x, y);
529 // x += new_bin->get_w();
530 // delete_bin->reposition_window(x, y);
531 // x += delete_bin->get_w();
532 // rename_bin->reposition_window(x, y);
533 // x += rename_bin->get_w();
534 // delete_disk->reposition_window(x, y);
535 // x += delete_disk->get_w();
536 // delete_project->reposition_window(x, y);
537 // x += delete_project->get_w();
538 // info->reposition_window(x, y);
539 // x += info->get_w();
540 // redraw_index->reposition_window(x, y);
541 // x += redraw_index->get_w();
542 // paste->reposition_window(x, y);
543 // x += paste->get_w();
544 // append->reposition_window(x, y);
545 // x += append->get_w();
546 // view->reposition_window(x, y);
548 BC_WindowBase::resize_event(w, h);
552 int AWindowGUI::translation_event()
554 mwindow->session->awindow_x = get_x();
555 mwindow->session->awindow_y = get_y();
559 void AWindowGUI::reposition_objects()
561 mwindow->theme->get_awindow_sizes(this);
562 asset_list->reposition_window(mwindow->theme->alist_x,
563 mwindow->theme->alist_y,
564 mwindow->theme->alist_w,
565 mwindow->theme->alist_h);
566 divider->reposition_window(mwindow->theme->adivider_x,
567 mwindow->theme->adivider_y,
568 mwindow->theme->adivider_w,
569 mwindow->theme->adivider_h);
570 folder_list->reposition_window(mwindow->theme->afolders_x,
571 mwindow->theme->afolders_y,
572 mwindow->theme->afolders_w,
573 mwindow->theme->afolders_h);
577 int AWindowGUI::close_event()
580 mwindow->session->show_awindow = 0;
583 mwindow->gui->lock_window("AWindowGUI::close_event");
584 mwindow->gui->mainmenu->show_awindow->set_checked(0);
585 mwindow->gui->unlock_window();
587 lock_window("AWindowGUI::close_event");
588 mwindow->save_defaults();
592 AWindowRemovePluginGUI::
593 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
594 int x, int y, PluginServer *plugin)
595 : BC_Window(PROGRAM_NAME ": Remove plugin", x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
597 this->awindow = awindow;
598 this->thread = thread;
599 this->plugin = plugin;
600 VFrame *vframe = plugin->get_picon();
601 icon = vframe ? create_pixmap(vframe) : 0;
602 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
605 AWindowRemovePluginGUI::
606 ~AWindowRemovePluginGUI()
608 if( !awindow->gui->protected_pixmap(icon) )
610 plugin_list.remove_all();
613 void AWindowRemovePluginGUI::create_objects()
615 BC_Button *ok_button = new BC_OKButton(this);
616 add_subwindow(ok_button);
617 BC_Button *cancel_button = new BC_CancelButton(this);
618 add_subwindow(cancel_button);
620 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
621 add_subwindow(title);
622 y += title->get_h() + 5;
623 list = new BC_ListBox(x, y,
624 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
625 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
630 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
633 for( int i=0; i<folder.size(); ) {
634 AssetPicon *picon = (AssetPicon *)folder[i];
635 if( picon->plugin == plugin ) {
636 folder.remove_object_number(i);
645 void AWindowRemovePlugin::handle_close_event(int result)
648 printf("remove %s\n", plugin->path);
649 ArrayList<BC_ListBoxItem*> *folder =
650 plugin->audio ? plugin->transition ?
651 &awindow->gui->atransitions :
652 &awindow->gui->aeffects :
653 plugin->video ? plugin->transition ?
654 &awindow->gui->vtransitions :
655 &awindow->gui->veffects :
657 if( folder ) remove_plugin(plugin, *folder);
658 awindow->gui->update_assets();
659 char png_path[BCTEXTLEN], plugin_path[BCTEXTLEN], index_path[BCTEXTLEN];
660 strcpy(plugin_path, plugin->path);
661 if( !plugin->get_plugin_png_path(png_path) ) png_path[0] = 0;
662 MWindow *mwindow = awindow->mwindow;
663 sprintf(index_path, "%s/%s", mwindow->preferences->plugin_dir, PLUGIN_FILE);
664 mwindow->plugindb->remove(plugin);
665 plugin->delete_this();
667 if( png_path[0] ) remove(png_path);
672 AWindowRemovePlugin::
673 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
676 this->awindow = awindow;
677 this->plugin = plugin;
680 AWindowRemovePlugin::
681 ~AWindowRemovePlugin()
686 BC_Window* AWindowRemovePlugin::new_gui()
688 int x = awindow->gui->get_abs_cursor_x(0);
689 int y = awindow->gui->get_abs_cursor_y(0);
690 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
691 gui->create_objects();
695 int AWindowGUI::keypress_event()
697 switch(get_keypress()) {
706 PluginServer* plugin = selected_plugin();
708 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
710 remove_plugin->start();
717 void AWindowGUI::update_folder_list()
719 //printf("AWindowGUI::update_folder_list 1\n");
720 for(int i = 0; i < folders.total; i++)
722 AssetPicon *picon = (AssetPicon*)folders.values[i];
725 //printf("AWindowGUI::update_folder_list 1\n");
727 // Search assets for folders
728 for(int i = 0; i < mwindow->edl->folders.total; i++)
730 char *folder = mwindow->edl->folders.values[i];
732 //printf("AWindowGUI::update_folder_list 1.1\n");
734 for(int j = 0; j < folders.total; j++)
736 AssetPicon *picon = (AssetPicon*)folders.values[j];
737 if(!strcasecmp(picon->get_text(), folder))
747 AssetPicon *picon = new AssetPicon(mwindow, this, folder);
748 picon->create_objects();
749 folders.append(picon);
751 //printf("AWindowGUI::update_folder_list 1.3\n");
753 //printf("AWindowGUI::update_folder_list 1\n");
754 //for(int i = 0; i < folders.total; i++)
755 // printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
758 for(int i = folders.total - 1; i >= 0; i--)
760 AssetPicon *picon = (AssetPicon*)folders.values[i];
761 if(!picon->in_use && !picon->persistent)
764 folders.remove_number(i);
767 //for(int i = 0; i < folders.total; i++)
768 // printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
769 //printf("AWindowGUI::update_folder_list 2\n");
772 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
773 int do_audio, int do_video, int is_realtime, int is_transition)
775 ArrayList<PluginServer*> plugin_list;
776 // Get pointers to plugindb entries
777 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
780 for(int i = 0; i < plugin_list.total; i++) {
781 PluginServer *server = plugin_list.values[i];
782 int visible = plugin_visibility & (1<<server->dir_idx);
783 if(!visible) continue;
784 // Create new listitem
785 AssetPicon *picon = new AssetPicon(mwindow, this, server);
786 picon->create_objects();
787 output->append(picon);
791 void AWindowGUI::update_asset_list()
793 //printf("AWindowGUI::update_asset_list 1\n");
794 for(int i = 0; i < assets.total; i++)
796 AssetPicon *picon = (AssetPicon*)assets.values[i];
804 //printf("AWindowGUI::update_asset_list 2\n");
807 // Synchronize EDL clips
808 for(int i = 0; i < mwindow->edl->clips.total; i++)
812 // Look for clip in existing listitems
813 for(int j = 0; j < assets.total && !exists; j++)
815 AssetPicon *picon = (AssetPicon*)assets.values[j];
817 if(picon->id == mwindow->edl->clips.values[i]->id)
819 picon->edl = mwindow->edl->clips.values[i];
820 picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title);
826 // Create new listitem
829 AssetPicon *picon = new AssetPicon(mwindow,
831 mwindow->edl->clips.values[i]);
832 picon->create_objects();
833 assets.append(picon);
841 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
844 // Synchronize EDL assets
845 for(Asset *current = mwindow->edl->assets->first;
851 // Look for asset in existing listitems
852 for(int j = 0; j < assets.total && !exists; j++)
854 AssetPicon *picon = (AssetPicon*)assets.values[j];
856 if(picon->id == current->id)
858 picon->indexable = current;
865 // Create new listitem
868 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
869 AssetPicon *picon = new AssetPicon(mwindow, this, current);
870 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
871 picon->create_objects();
872 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
873 assets.append(picon);
879 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
882 // Synchronize nested EDLs
883 for(int i = 0; i < mwindow->edl->nested_edls->size(); i++)
886 Indexable *indexable = mwindow->edl->nested_edls->get(i);
888 // Look for asset in existing listitems
889 for(int j = 0; j < assets.total && !exists; j++)
891 AssetPicon *picon = (AssetPicon*)assets.values[j];
893 if(picon->id == indexable->id)
895 picon->indexable = indexable;
902 // Create new listitem
905 AssetPicon *picon = new AssetPicon(mwindow,
908 picon->create_objects();
909 assets.append(picon);
921 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
922 for(int i = assets.size() - 1; i >= 0; i--)
924 AssetPicon *picon = (AssetPicon*)assets.get(i);
925 //printf("AWindowGUI::update_asset_list %s %d\n", picon->asset->path, picon->in_use);
929 assets.remove_number(i);
932 //printf("AWindowGUI::update_asset_list 7 %d\n", assets.total);
939 void AWindowGUI::sort_assets()
941 //printf("AWindowGUI::sort_assets 1 %s\n", mwindow->edl->session->current_folder);
942 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
943 sort_picons(&aeffects,
946 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
947 sort_picons(&veffects,
950 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
951 sort_picons(&atransitions,
954 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
955 sort_picons(&vtransitions,
959 mwindow->edl->session->current_folder);
974 void AWindowGUI::collect_assets()
977 mwindow->session->drag_assets->remove_all();
978 mwindow->session->drag_clips->remove_all();
981 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
984 if(result->indexable) mwindow->session->drag_assets->append(result->indexable);
985 if(result->edl) mwindow->session->drag_clips->append(result->edl);
989 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
990 ArrayList<BC_ListBoxItem*> *src,
993 // Remove current pointers
995 dst[1].remove_all_objects();
997 // Create new pointers
998 //if(folder) printf("AWindowGUI::copy_picons 1 %s\n", folder);
999 for(int i = 0; i < src->total; i++)
1001 AssetPicon *picon = (AssetPicon*)src->values[i];
1002 //printf("AWindowGUI::copy_picons 2 %s\n", picon->asset->folder);
1004 (folder && picon->indexable && !strcasecmp(picon->indexable->folder, folder)) ||
1005 (folder && picon->edl && !strcasecmp(picon->edl->local_session->folder, folder)))
1007 BC_ListBoxItem *item2, *item1;
1008 dst[0].append(item1 = picon);
1010 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1012 dst[1].append(item2 = new BC_ListBoxItem(""));
1013 item1->set_autoplace_text(1);
1014 item2->set_autoplace_text(1);
1015 //printf("AWindowGUI::copy_picons 3 %s\n", picon->get_text());
1020 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src,
1023 //printf("AWindowGUI::sort_picons 1\n")
1028 for(int i = 0; i < src->total - 1; i++)
1030 BC_ListBoxItem *item1 = src->values[i];
1031 BC_ListBoxItem *item2 = src->values[i + 1];
1032 item1->set_autoplace_icon(1);
1033 item2->set_autoplace_icon(1);
1034 item1->set_autoplace_text(1);
1035 item2->set_autoplace_text(1);
1036 if(strcmp(item1->get_text(), item2->get_text()) > 0)
1038 src->values[i + 1] = item1;
1039 src->values[i] = item2;
1047 void AWindowGUI::filter_displayed_assets()
1049 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1050 copy_picons(displayed_assets,
1054 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1055 copy_picons(displayed_assets,
1059 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1060 copy_picons(displayed_assets,
1064 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1065 copy_picons(displayed_assets,
1069 copy_picons(displayed_assets,
1071 mwindow->edl->session->current_folder);
1075 void AWindowGUI::update_assets()
1077 //printf("AWindowGUI::update_assets 1\n");
1078 update_folder_list();
1079 //printf("AWindowGUI::update_assets 2\n");
1080 update_asset_list();
1081 //printf("AWindowGUI::update_assets 3\n");
1082 filter_displayed_assets();
1084 //for(int i = 0; i < folders.total; i++)
1085 //printf("AWindowGUI::update_assets 4\n");
1086 // printf("AWindowGUI::update_assets %s\n", folders.values[i]->get_text());
1087 if(mwindow->edl->session->folderlist_format != folder_list->get_format())
1088 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1089 folder_list->update(&folders,
1093 folder_list->get_xposition(),
1094 folder_list->get_yposition(),
1096 //printf("AWindowGUI::update_assets 5\n");
1098 if(mwindow->edl->session->assetlist_format != asset_list->get_format())
1099 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1102 //printf("AWindowGUI::update_assets 6 %d\n", displayed_assets[0].total);
1103 asset_list->update(displayed_assets,
1105 mwindow->edl->session->asset_columns,
1107 asset_list->get_xposition(),
1108 asset_list->get_yposition(),
1111 //printf("AWindowGUI::update_assets 7\n");
1114 //printf("AWindowGUI::update_assets 8\n");
1118 void AWindowGUI::update_effects()
1120 aeffects.remove_all_objects();
1121 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1122 veffects.remove_all_objects();
1123 create_persistent_folder(&veffects, 0, 1, 1, 0);
1124 atransitions.remove_all_objects();
1125 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1126 vtransitions.remove_all_objects();
1127 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1130 int AWindowGUI::current_folder_number()
1133 for(int i = 0; i < folders.total; i++)
1135 if(!strcasecmp(folders.values[i]->get_text(), mwindow->edl->session->current_folder))
1144 int AWindowGUI::drag_motion()
1146 if(get_hidden()) return 0;
1152 int AWindowGUI::drag_stop()
1154 if(get_hidden()) return 0;
1159 Indexable* AWindowGUI::selected_asset()
1161 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1162 return picon ? picon->indexable : 0;
1165 PluginServer* AWindowGUI::selected_plugin()
1167 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1168 return picon ? picon->plugin : 0;
1171 AssetPicon* AWindowGUI::selected_folder()
1173 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1186 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1187 : BC_SubWindow(x, y, w, h)
1189 this->mwindow = mwindow;
1192 AWindowDivider::~AWindowDivider()
1196 int AWindowDivider::button_press_event()
1198 if(is_event_win() && cursor_inside())
1200 mwindow->session->current_operation = DRAG_PARTITION;
1206 int AWindowDivider::cursor_motion_event()
1208 if(mwindow->session->current_operation == DRAG_PARTITION)
1210 mwindow->session->afolders_w = gui->get_relative_cursor_x();
1211 gui->reposition_objects();
1216 int AWindowDivider::button_release_event()
1218 if(mwindow->session->current_operation == DRAG_PARTITION)
1220 mwindow->session->current_operation = NO_OPERATION;
1231 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1236 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
1237 LISTBOX_ICONS : LISTBOX_TEXT,
1238 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
1239 0, // Titles for columns. Set to 0 for no titles
1240 0, // width of each column
1241 1, // Total columns.
1242 0, // Pixel of top of window.
1243 0, // If this listbox is a popup window
1244 LISTBOX_SINGLE, // Select one item or multiple items
1245 ICON_TOP, // Position of icon relative to text of each item
1248 this->mwindow = mwindow;
1253 AWindowFolders::~AWindowFolders()
1257 int AWindowFolders::selection_changed()
1259 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1262 if(get_button_down() && get_buttonpress() == 3)
1264 gui->folderlist_menu->update_titles();
1265 gui->folderlist_menu->activate_menu();
1268 strcpy(mwindow->edl->session->current_folder, picon->get_text());
1269 //printf("AWindowFolders::selection_changed 1\n");
1270 gui->asset_list->draw_background();
1271 gui->update_assets();
1276 int AWindowFolders::button_press_event()
1280 result = BC_ListBox::button_press_event();
1284 if(get_buttonpress() == 3 && is_event_win() && cursor_inside())
1286 gui->folderlist_menu->update_titles();
1287 gui->folderlist_menu->activate_menu();
1302 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1307 mwindow->edl->session->assetlist_format == ASSETS_ICONS ?
1308 LISTBOX_ICONS : LISTBOX_TEXT,
1309 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
1310 gui->asset_titles, // Titles for columns. Set to 0 for no titles
1311 mwindow->edl->session->asset_columns, // width of each column
1312 1, // Total columns.
1313 0, // Pixel of top of window.
1314 0, // If this listbox is a popup window
1315 LISTBOX_MULTIPLE, // Select one item or multiple items
1316 ICON_TOP, // Position of icon relative to text of each item
1319 this->mwindow = mwindow;
1324 AWindowAssets::~AWindowAssets()
1328 int AWindowAssets::button_press_event()
1332 result = BC_ListBox::button_press_event();
1334 if(!result && get_buttonpress() == 3 && is_event_win() && cursor_inside())
1336 BC_ListBox::deactivate_selection();
1337 gui->assetlist_menu->update_titles();
1338 gui->assetlist_menu->activate_menu();
1347 int AWindowAssets::handle_event()
1349 //printf("AWindowAssets::handle_event 1 %d %d\n", get_buttonpress(), get_selection(0, 0));
1350 if(get_selection(0, 0))
1352 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1356 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1360 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1364 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1368 if(mwindow->vwindows.size())
1370 //printf("AWindowAssets::handle_event 2 %d %d\n", get_buttonpress(), get_selection(0, 0));
1371 mwindow->vwindows.get(DEFAULT_VWINDOW)->gui->lock_window("AWindowAssets::handle_event");
1373 if(((AssetPicon*)get_selection(0, 0))->indexable)
1374 mwindow->vwindows.get(DEFAULT_VWINDOW)->change_source(((AssetPicon*)get_selection(0, 0))->indexable);
1376 if(((AssetPicon*)get_selection(0, 0))->edl)
1377 mwindow->vwindows.get(DEFAULT_VWINDOW)->change_source(((AssetPicon*)get_selection(0, 0))->edl);
1379 mwindow->vwindows.get(DEFAULT_VWINDOW)->gui->unlock_window();
1387 int AWindowAssets::selection_changed()
1389 // Show popup window
1390 if(get_button_down() && get_buttonpress() == 3 && get_selection(0, 0))
1392 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER) ||
1393 !strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER) ||
1394 !strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER) ||
1395 !strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1397 gui->assetlist_menu->update_titles();
1398 gui->assetlist_menu->activate_menu();
1402 if(((AssetPicon*)get_selection(0, 0))->indexable)
1403 gui->asset_menu->update();
1405 if(((AssetPicon*)get_selection(0, 0))->edl)
1406 gui->asset_menu->update();
1410 gui->asset_menu->activate_menu();
1413 BC_ListBox::deactivate_selection();
1419 void AWindowAssets::draw_background()
1421 clear_box(0,0,get_w(),get_h(),get_bg_surface());
1423 set_font(LARGEFONT);
1425 get_text_width(LARGEFONT, mwindow->edl->session->current_folder) - 4,
1427 mwindow->edl->session->current_folder,
1432 int AWindowAssets::drag_start_event()
1434 int collect_pluginservers = 0;
1435 int collect_assets = 0;
1437 if(BC_ListBox::drag_start_event())
1439 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1441 mwindow->session->current_operation = DRAG_AEFFECT;
1442 collect_pluginservers = 1;
1445 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1447 mwindow->session->current_operation = DRAG_VEFFECT;
1448 collect_pluginservers = 1;
1451 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1453 mwindow->session->current_operation = DRAG_ATRANSITION;
1454 collect_pluginservers = 1;
1457 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1459 mwindow->session->current_operation = DRAG_VTRANSITION;
1460 collect_pluginservers = 1;
1464 mwindow->session->current_operation = DRAG_ASSET;
1469 if(collect_pluginservers)
1472 mwindow->session->drag_pluginservers->remove_all();
1475 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
1478 mwindow->session->drag_pluginservers->append(result->plugin);
1484 gui->collect_assets();
1492 int AWindowAssets::drag_motion_event()
1494 BC_ListBox::drag_motion_event();
1497 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1498 mwindow->gui->drag_motion();
1499 mwindow->gui->unlock_window();
1501 for(int i = 0; i < mwindow->vwindows.size(); i++)
1503 VWindow *vwindow = mwindow->vwindows.get(i);
1504 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1505 vwindow->gui->drag_motion();
1506 vwindow->gui->unlock_window();
1509 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1510 mwindow->cwindow->gui->drag_motion();
1511 mwindow->cwindow->gui->unlock_window();
1513 lock_window("AWindowAssets::drag_motion_event");
1517 int AWindowAssets::drag_stop_event()
1521 result = gui->drag_stop();
1527 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1528 result = mwindow->gui->drag_stop();
1529 mwindow->gui->unlock_window();
1534 for(int i = 0; i < mwindow->vwindows.size(); i++)
1536 VWindow *vwindow = mwindow->vwindows.get(i);
1537 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1538 result = vwindow->gui->drag_stop();
1539 vwindow->gui->unlock_window();
1545 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1546 result = mwindow->cwindow->gui->drag_stop();
1547 mwindow->cwindow->gui->unlock_window();
1550 lock_window("AWindowAssets::drag_stop_event");
1552 if(result) get_drag_popup()->set_animation(0);
1554 BC_ListBox::drag_stop_event();
1555 mwindow->session->current_operation = ::NO_OPERATION; // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
1559 int AWindowAssets::column_resize_event()
1561 mwindow->edl->session->asset_columns[0] = get_column_width(0);
1562 mwindow->edl->session->asset_columns[1] = get_column_width(1);
1577 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1578 : BC_Button(x, y, mwindow->theme->newbin_data)
1580 this->mwindow = mwindow;
1582 set_tooltip(_("New bin"));
1585 int AWindowNewFolder::handle_event()
1587 gui->newfolder_thread->start_new_folder();
1591 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1592 : BC_Button(x, y, mwindow->theme->deletebin_data)
1594 this->mwindow = mwindow;
1596 set_tooltip(_("Delete bin"));
1599 int AWindowDeleteFolder::handle_event()
1601 if(gui->folder_list->get_selection(0, 0))
1603 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
1604 mwindow->delete_folder(folder->get_text());
1609 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1610 : BC_Button(x, y, mwindow->theme->renamebin_data)
1612 this->mwindow = mwindow;
1614 set_tooltip(_("Rename bin"));
1617 int AWindowRenameFolder::handle_event()
1622 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1623 : BC_Button(x, y, mwindow->theme->deletedisk_data)
1625 this->mwindow = mwindow;
1627 set_tooltip(_("Delete asset from disk"));
1630 int AWindowDeleteDisk::handle_event()
1635 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1636 : BC_Button(x, y, mwindow->theme->deleteproject_data)
1638 this->mwindow = mwindow;
1640 set_tooltip(_("Delete asset from project"));
1643 int AWindowDeleteProject::handle_event()
1648 AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1649 : BC_Button(x, y, mwindow->theme->infoasset_data)
1651 this->mwindow = mwindow;
1653 set_tooltip(_("Edit information on asset"));
1656 int AWindowInfo::handle_event()
1658 gui->awindow->asset_edit->edit_asset(gui->selected_asset());
1662 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1663 : BC_Button(x, y, mwindow->theme->redrawindex_data)
1665 this->mwindow = mwindow;
1667 set_tooltip(_("Redraw index"));
1670 int AWindowRedrawIndex::handle_event()
1675 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1676 : BC_Button(x, y, mwindow->theme->pasteasset_data)
1678 this->mwindow = mwindow;
1680 set_tooltip(_("Paste asset on recordable tracks"));
1683 int AWindowPaste::handle_event()
1688 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1689 : BC_Button(x, y, mwindow->theme->appendasset_data)
1691 this->mwindow = mwindow;
1693 set_tooltip(_("Append asset in new tracks"));
1696 int AWindowAppend::handle_event()
1701 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1702 : BC_Button(x, y, mwindow->theme->viewasset_data)
1704 this->mwindow = mwindow;
1706 set_tooltip(_("View asset"));
1709 int AWindowView::handle_event()
1714 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w)
1715 : BC_MenuBar(x, y, w)
1717 this->mwindow = mwindow;
1721 void AddTools::create_objects()
1723 add_menu(add_plugins = new AddPluginsMenu(mwindow, gui));
1724 add_plugins->create_objects();
1727 AddPluginsMenu::AddPluginsMenu(MWindow *mwindow, AWindowGUI *gui)
1728 : BC_Menu("Add Tools")
1730 this->mwindow = mwindow;
1734 void AddPluginsMenu::create_objects()
1737 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
1738 PluginServer *plugin = MWindow::plugindb->get(i);
1739 if( !plugin->audio && !plugin->video ) continue;
1740 int idx = plugin->dir_idx;
1741 uint32_t msk = 1 << idx;
1742 if( (msk & vis) != 0 ) continue;
1744 char parent[BCTEXTLEN];
1745 strcpy(parent, plugin->path);
1746 char *cp = strrchr(parent, '/');
1749 char *bp = strrchr(parent, '/');
1750 if( !bp ) bp = parent; else ++bp;
1751 if( !strcmp(bp, "ladspa") )
1752 gui->plugin_visibility &= ~(1 << idx);
1753 add_item(new AddPluginItem(this, bp, idx));
1758 AddPluginItem::AddPluginItem(AddPluginsMenu *menu, char const *text, int idx)
1763 uint32_t msk = 1 << idx, vis = menu->gui->plugin_visibility;
1764 int chk = (msk & vis) ? 1 : 0;
1768 int AddPluginItem::handle_event()
1770 int chk = get_checked() ^ 1;
1772 uint32_t msk = 1 << idx, vis = menu->gui->plugin_visibility;
1773 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
1774 menu->gui->update_effects();
1775 menu->gui->update_assets();