/* * CINELERRA * Copyright (C) 1997-2012 Adam Williams * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "asset.h" #include "assetedit.h" #include "assetpopup.h" #include "assets.h" #include "awindowgui.h" #include "awindowgui.inc" #include "awindow.h" #include "awindowmenu.h" #include "bcsignals.h" #include "bchash.h" #include "cache.h" #include "bccmodels.h" #include "cursors.h" #include "cwindowgui.h" #include "cwindow.h" #include "edl.h" #include "edlsession.h" #include "file.h" #include "filesystem.h" #include "indexable.h" #include "keys.h" #include "language.h" #include "labels.h" #include "labeledit.h" #include "localsession.h" #include "mainmenu.h" #include "mainsession.h" #include "mwindowgui.h" #include "mwindow.h" #include "nestededls.h" #include "newfolder.h" #include "preferences.h" #include "theme.h" #include "vframe.h" #include "vicon.h" #include "vwindowgui.h" #include "vwindow.h" #include "data/lad_picon_png.h" #include "data/ff_audio_png.h" #include "data/ff_video_png.h" #include #include #include const char *AWindowGUI::folder_names[] = { N_("Audio Effects"), N_("Video Effects"), N_("Audio Transitions"), N_("Video Transitions"), N_("Labels"), N_("Clips"), N_("Media"), N_("User") }; AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length) : VIcon(w, h, framerate) { this->picon = picon; this->length = length; temp = 0; } AssetVIcon::~AssetVIcon() { delete temp; } VFrame *AssetVIcon::frame() { if( seq_no >= images.size() ) { MWindow *mwindow = picon->mwindow; Asset *asset = (Asset *)picon->indexable; File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1); if( !file ) return 0; if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) { delete temp; temp = 0; } if( !temp ) temp = new VFrame(asset->width, asset->height, BC_RGB888); int ww = picon->gui->vicon_thread->view_w; int hh = picon->gui->vicon_thread->view_h; while( seq_no >= images.size() ) { file->set_layer(0); int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate; file->set_video_position(pos,0); file->read_frame(temp); add_image(temp, ww, hh, BC_RGB8); } mwindow->video_cache->check_in(asset); } return *images[seq_no]; } int64_t AssetVIcon::set_seq_no(int64_t no) { if( no >= length ) no = 0; return seq_no = no; } int AssetVIcon::get_vx() { BC_ListBox *lbox = picon->gui->asset_list; return lbox->get_item_x(picon); } int AssetVIcon::get_vy() { BC_ListBox *lbox = picon->gui->asset_list; return lbox->get_item_y(picon) + lbox->get_title_h(); } AssetPicon::AssetPicon(MWindow *mwindow, AWindowGUI *gui, Indexable *indexable) : BC_ListBoxItem() { reset(); this->mwindow = mwindow; this->gui = gui; this->indexable = indexable; indexable->add_user(); this->id = indexable->id; } AssetPicon::AssetPicon(MWindow *mwindow, AWindowGUI *gui, EDL *edl) : BC_ListBoxItem() { reset(); this->mwindow = mwindow; this->gui = gui; this->edl = edl; edl->add_user(); this->id = edl->id; } AssetPicon::AssetPicon(MWindow *mwindow, AWindowGUI *gui, int folder) : BC_ListBoxItem(_(AWindowGUI::folder_names[folder]), gui->folder_icon) { reset(); foldernum = folder; this->mwindow = mwindow; this->gui = gui; } AssetPicon::AssetPicon(MWindow *mwindow, AWindowGUI *gui, const char *folder_name, int folder_num) : BC_ListBoxItem(folder_name, gui->folder_icon) { reset(); foldernum = folder_num; this->mwindow = mwindow; this->gui = gui; } AssetPicon::AssetPicon(MWindow *mwindow, AWindowGUI *gui, PluginServer *plugin) : BC_ListBoxItem() { reset(); this->mwindow = mwindow; this->gui = gui; this->plugin = plugin; } AssetPicon::AssetPicon(MWindow *mwindow, AWindowGUI *gui, Label *label) : BC_ListBoxItem() { reset(); this->mwindow = mwindow; this->gui = gui; this->label = label; indexable = 0; icon = 0; id = 0; } AssetPicon::~AssetPicon() { if( vicon ) gui->vicon_thread->del_vicon(vicon); if(indexable) indexable->remove_user(); if(edl) edl->remove_user(); if( icon && !gui->protected_pixmap(icon) ) { delete icon; if( !plugin ) delete icon_vframe; } } void AssetPicon::reset() { plugin = 0; label = 0; indexable = 0; edl = 0; icon = 0; icon_vframe = 0; vicon = 0; in_use = 1; id = 0; persistent = 0; } void AssetPicon::create_objects() { FileSystem fs; char name[BCTEXTLEN]; int pixmap_w, pixmap_h; const int debug = 0; pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale; if(debug) printf("AssetPicon::create_objects %d\n", __LINE__); if(indexable) { fs.extract_name(name, indexable->path); set_text(name); } if(indexable && indexable->is_asset) { if(debug) printf("AssetPicon::create_objects %d\n", __LINE__); Asset *asset = (Asset*)indexable; if(asset->video_data) { if(mwindow->preferences->use_thumbnails) { gui->unlock_window(); if(debug) printf("AssetPicon::create_objects %d\n", __LINE__); File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1); if(debug) printf("AssetPicon::create_objects %d\n", __LINE__); if(file) { int height = asset->height > 0 ? asset->height : 1; pixmap_w = pixmap_h * asset->width / height; file->set_layer(0); file->set_video_position(0, 0); if(gui->temp_picon && (gui->temp_picon->get_w() != asset->width || gui->temp_picon->get_h() != asset->height)) { delete gui->temp_picon; gui->temp_picon = 0; } if(!gui->temp_picon) { gui->temp_picon = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1); } file->read_frame(gui->temp_picon); if(debug) printf("AssetPicon::create_objects %d\n", __LINE__); mwindow->video_cache->check_in(asset); gui->lock_window("AssetPicon::create_objects 1"); icon = new BC_Pixmap(gui, pixmap_w, pixmap_h); icon->draw_vframe(gui->temp_picon, 0, 0, pixmap_w, pixmap_h, 0, 0); //printf("%d %d\n", gui->temp_picon->get_w(), gui->temp_picon->get_h()); icon_vframe = new VFrame(0, -1, pixmap_w, pixmap_h, BC_RGB888, -1); icon_vframe->transfer_from(gui->temp_picon); // vicon images double framerate = asset->get_frame_rate(); if( !framerate ) framerate = VICON_RATE; int64_t frames = asset->get_video_frames(); double secs = frames / framerate; if( secs > 5 ) secs = 5; int64_t length = secs * gui->vicon_thread->refresh_rate; vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length); gui->vicon_thread->add_vicon(vicon); if(debug) printf("AssetPicon::create_objects %d\n", __LINE__); } else { gui->lock_window("AssetPicon::create_objects 2"); icon = gui->video_icon; icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM]; } } else { icon = gui->video_icon; icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM]; } } else if(asset->audio_data) { icon = gui->audio_icon; icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND]; } //printf("AssetPicon::create_objects 2\n"); if(debug) printf("AssetPicon::create_objects %d\n", __LINE__); } else if(indexable && !indexable->is_asset) { icon = gui->video_icon; icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM]; } else if(edl) { //printf("AssetPicon::create_objects 4 %s\n", edl->local_session->clip_title); set_text(strcpy(name, edl->local_session->clip_title)); icon = gui->clip_icon; icon_vframe = mwindow->theme->get_image("clip_icon"); } else if(plugin) { strcpy(name, _(plugin->title)); set_text(name); icon_vframe = plugin->get_picon(); if( icon_vframe ) icon = gui->create_pixmap(icon_vframe); else if( plugin->audio ) { if( plugin->transition ) { icon = gui->atransition_icon; icon_vframe = gui->atransition_vframe; } else if( plugin->is_ffmpeg() ) { icon = gui->ff_aud_icon; icon_vframe = gui->ff_aud_vframe; } else if( plugin->is_ladspa() ) { icon = gui->ladspa_icon; icon_vframe = gui->ladspa_vframe; } else { icon = gui->aeffect_icon; icon_vframe = gui->aeffect_vframe; } } else if( plugin->video ) { if( plugin->transition ) { icon = gui->vtransition_icon; icon_vframe = gui->vtransition_vframe; } else if( plugin->is_ffmpeg() ) { icon = gui->ff_vid_icon; icon_vframe = gui->ff_vid_vframe; } else { icon = gui->veffect_icon; icon_vframe = gui->veffect_vframe; } } } else if(label) { Units::totext(name, label->position, mwindow->edl->session->time_format, mwindow->edl->session->sample_rate, mwindow->edl->session->frame_rate, mwindow->edl->session->frames_per_foot); set_text(name); icon = gui->file_icon; icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN]; set_icon(icon); set_icon_vframe(icon_vframe); } if( !icon ) { icon = gui->file_icon; icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN]; } set_icon(icon); set_icon_vframe(icon_vframe); if(debug) printf("AssetPicon::create_objects %d\n", __LINE__); } AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow) : BC_Window(_(PROGRAM_NAME ": Resources"), mwindow->session->awindow_x, mwindow->session->awindow_y, mwindow->session->awindow_w, mwindow->session->awindow_h, 100, 100, 1, 1, 1) { // printf("AWindowGUI::AWindowGUI %d %d %d %d\n", // mwindow->session->awindow_x, // mwindow->session->awindow_y, // mwindow->session->awindow_w, // mwindow->session->awindow_h); this->mwindow = mwindow; this->awindow = awindow; file_icon = 0; audio_icon = 0; video_icon = 0; folder_icon = 0; clip_icon = 0; atransition_icon = 0; atransition_vframe = 0; vtransition_icon = 0; vtransition_vframe = 0; aeffect_icon = 0; aeffect_vframe = 0; ladspa_icon = 0; ladspa_vframe = 0; veffect_icon = 0; veffect_vframe = 0; ff_aud_icon = 0; ff_aud_vframe = 0; ff_vid_icon = 0; ff_vid_vframe = 0; plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1; newfolder_thread = 0; asset_menu = 0; assetlist_menu = 0; folderlist_menu = 0; temp_picon = 0; allow_iconlisting = 1; remove_plugin = 0; vicon_thread = 0; vicon_drawing = 1; } AWindowGUI::~AWindowGUI() { assets.remove_all_objects(); folders.remove_all_objects(); aeffects.remove_all_objects(); veffects.remove_all_objects(); atransitions.remove_all_objects(); vtransitions.remove_all_objects(); labellist.remove_all_objects(); displayed_assets[1].remove_all_objects(); delete vicon_thread; delete file_icon; delete audio_icon; delete video_icon; delete folder_icon; delete clip_icon; delete atransition_icon; delete vtransition_icon; delete aeffect_icon; delete ladspa_icon; delete ladspa_vframe; delete ff_aud_icon; delete ff_aud_vframe; delete ff_vid_icon; delete ff_vid_vframe; delete veffect_icon; delete newfolder_thread; delete asset_menu; delete label_menu; delete assetlist_menu; delete folderlist_menu; if(temp_picon) delete temp_picon; delete remove_plugin; } bool AWindowGUI::protected_pixmap(BC_Pixmap *icon) { return icon == file_icon || icon == folder_icon || icon == audio_icon || icon == video_icon || icon == clip_icon || icon == vtransition_icon || icon == atransition_icon || icon == veffect_icon || icon == aeffect_icon || icon == ladspa_icon || icon == ff_aud_icon || icon == ff_vid_icon; } void AWindowGUI::create_objects() { AssetPicon *picon; lock_window("AWindowGUI::create_objects"); SET_TRACE //printf("AWindowGUI::create_objects 1\n"); asset_titles[0] = _("Title"); asset_titles[1] = _("Comments"); SET_TRACE set_icon(mwindow->theme->get_image("awindow_icon")); file_icon = new BC_Pixmap(this, BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN], PIXMAP_ALPHA); folder_icon = new BC_Pixmap(this, BC_WindowBase::get_resources()->type_to_icon[ICON_FOLDER], PIXMAP_ALPHA); audio_icon = new BC_Pixmap(this, BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND], PIXMAP_ALPHA); video_icon = new BC_Pixmap(this, BC_WindowBase::get_resources()->type_to_icon[ICON_FILM], PIXMAP_ALPHA); SET_TRACE clip_vframe = mwindow->theme->get_image("clip_icon"); clip_icon = new BC_Pixmap(this, clip_vframe, PIXMAP_ALPHA); atransition_vframe = mwindow->theme->get_image("atransition_icon"); atransition_icon = new BC_Pixmap(this, atransition_vframe, PIXMAP_ALPHA); vtransition_vframe = mwindow->theme->get_image("vtransition_icon"); vtransition_icon = new BC_Pixmap(this, vtransition_vframe, PIXMAP_ALPHA); aeffect_vframe = mwindow->theme->get_image("aeffect_icon"); aeffect_icon = new BC_Pixmap(this, aeffect_vframe, PIXMAP_ALPHA); ladspa_vframe = new VFramePng(lad_picon_png); ladspa_icon = new BC_Pixmap(this, ladspa_vframe, PIXMAP_ALPHA); ff_aud_vframe = new VFramePng(ff_audio_png); ff_aud_icon = new BC_Pixmap(this, ff_aud_vframe, PIXMAP_ALPHA); ff_vid_vframe = new VFramePng(ff_video_png); ff_vid_icon = new BC_Pixmap(this, ff_vid_vframe, PIXMAP_ALPHA); veffect_vframe = mwindow->theme->get_image("veffect_icon"); veffect_icon = new BC_Pixmap(this, veffect_vframe, PIXMAP_ALPHA); SET_TRACE // Mandatory folders folders.append(picon = new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER)); picon->persistent = 1; folders.append(picon = new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER)); picon->persistent = 1; folders.append(picon = new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER)); picon->persistent = 1; folders.append(picon = new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER)); picon->persistent = 1; folders.append(picon = new AssetPicon(mwindow, this, AW_LABEL_FOLDER)); picon->persistent = 1; folders.append(picon = new AssetPicon(mwindow, this, AW_CLIP_FOLDER)); picon->persistent = 1; folders.append(picon = new AssetPicon(mwindow, this, AW_MEDIA_FOLDER)); picon->persistent = 1; create_label_folder(); SET_TRACE mwindow->theme->get_awindow_sizes(this); load_defaults(mwindow->defaults); SET_TRACE add_subwindow(asset_list = new AWindowAssets(mwindow, this, mwindow->theme->alist_x, mwindow->theme->alist_y, mwindow->theme->alist_w, mwindow->theme->alist_h)); vicon_thread = new VIconThread(asset_list); vicon_thread->start(); SET_TRACE add_subwindow(divider = new AWindowDivider(mwindow, this, mwindow->theme->adivider_x, mwindow->theme->adivider_y, mwindow->theme->adivider_w, mwindow->theme->adivider_h)); SET_TRACE divider->set_cursor(HSEPARATE_CURSOR, 0, 0); SET_TRACE int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y; int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h; VFrame **images = mwindow->theme->get_image_set("playpatch_data"); AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h); add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images)); add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility"))); add_tools->create_objects(); fy += add_tools->get_h(); fh -= add_tools->get_h(); SET_TRACE add_subwindow(folder_list = new AWindowFolders(mwindow, this, fx, fy, fw, fh)); SET_TRACE update_effects(); SET_TRACE //int x = mwindow->theme->abuttons_x; //int y = mwindow->theme->abuttons_y; SET_TRACE newfolder_thread = new NewFolderThread(mwindow, this); add_subwindow(asset_menu = new AssetPopup(mwindow, this)); asset_menu->create_objects(); add_subwindow(label_menu = new LabelPopup(mwindow, this)); label_menu->create_objects(); SET_TRACE add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this)); SET_TRACE assetlist_menu->create_objects(); SET_TRACE add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this)); folderlist_menu->create_objects(); //printf("AWindowGUI::create_objects 2\n"); SET_TRACE create_custom_xatoms(); unlock_window(); } int AWindowGUI::resize_event(int w, int h) { mwindow->session->awindow_x = get_x(); mwindow->session->awindow_y = get_y(); mwindow->session->awindow_w = w; mwindow->session->awindow_h = h; mwindow->theme->get_awindow_sizes(this); mwindow->theme->draw_awindow_bg(this); reposition_objects(); // int x = mwindow->theme->abuttons_x; // int y = mwindow->theme->abuttons_y; // new_bin->reposition_window(x, y); // x += new_bin->get_w(); // delete_bin->reposition_window(x, y); // x += delete_bin->get_w(); // rename_bin->reposition_window(x, y); // x += rename_bin->get_w(); // delete_disk->reposition_window(x, y); // x += delete_disk->get_w(); // delete_project->reposition_window(x, y); // x += delete_project->get_w(); // info->reposition_window(x, y); // x += info->get_w(); // redraw_index->reposition_window(x, y); // x += redraw_index->get_w(); // paste->reposition_window(x, y); // x += paste->get_w(); // append->reposition_window(x, y); // x += append->get_w(); // view->reposition_window(x, y); BC_WindowBase::resize_event(w, h); return 1; } int AWindowGUI::translation_event() { mwindow->session->awindow_x = get_x(); mwindow->session->awindow_y = get_y(); return 0; } void AWindowGUI::reposition_objects() { asset_list->reposition_window( mwindow->theme->alist_x, mwindow->theme->alist_y, mwindow->theme->alist_w, mwindow->theme->alist_h); divider->reposition_window( mwindow->theme->adivider_x, mwindow->theme->adivider_y, mwindow->theme->adivider_w, mwindow->theme->adivider_h); int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y; int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h; add_tools->resize_event(fw-avicon_w, add_tools->get_h()); avicon_drawing->reposition_window(fw-avicon_w, fy); fy += add_tools->get_h(); fh -= add_tools->get_h(); folder_list->reposition_window(fx, fy, fw, fh); } int AWindowGUI::save_defaults(BC_Hash *defaults) { defaults->update("PLUGIN_VISIBILTY", plugin_visibility); defaults->update("VICON_DRAWING", vicon_drawing); return 0; } int AWindowGUI::load_defaults(BC_Hash *defaults) { plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility); vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing); return 0; } int AWindowGUI::close_event() { hide_window(); mwindow->session->show_awindow = 0; unlock_window(); mwindow->gui->lock_window("AWindowGUI::close_event"); mwindow->gui->mainmenu->show_awindow->set_checked(0); mwindow->gui->unlock_window(); lock_window("AWindowGUI::close_event"); save_defaults(mwindow->defaults); mwindow->save_defaults(); return 1; } void AWindowGUI::start_vicon_drawing() { if( !vicon_drawing ) return; if( mwindow->edl->session->awindow_folder != AW_MEDIA_FOLDER ) return; if( mwindow->edl->session->assetlist_format != ASSETS_ICONS ) return; vicon_thread->start_drawing(); } void AWindowGUI::stop_vicon_drawing() { vicon_thread->stop_drawing(); } AWindowRemovePluginGUI:: AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread, int x, int y, PluginServer *plugin) : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1) { this->awindow = awindow; this->thread = thread; this->plugin = plugin; VFrame *vframe = plugin->get_picon(); icon = vframe ? create_pixmap(vframe) : 0; plugin_list.append(new BC_ListBoxItem(plugin->title, icon)); } AWindowRemovePluginGUI:: ~AWindowRemovePluginGUI() { if( !awindow->gui->protected_pixmap(icon) ) delete icon; plugin_list.remove_all(); } void AWindowRemovePluginGUI::create_objects() { BC_Button *ok_button = new BC_OKButton(this); add_subwindow(ok_button); BC_Button *cancel_button = new BC_CancelButton(this); add_subwindow(cancel_button); int x = 10, y = 10; BC_Title *title = new BC_Title(x, y, _("remove plugin?")); add_subwindow(title); y += title->get_h() + 5; list = new BC_ListBox(x, y, get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list, 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0); add_subwindow(list); show_window(); } int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList &folder) { int ret = 0; for( int i=0; iplugin == plugin ) { folder.remove_object_number(i); ++ret; continue; } ++i; } return ret; } void AWindowRemovePlugin::handle_close_event(int result) { if( !result ) { printf(_("remove %s\n"), plugin->path); ArrayList *folder = plugin->audio ? plugin->transition ? &awindow->gui->atransitions : &awindow->gui->aeffects : plugin->video ? plugin->transition ? &awindow->gui->vtransitions : &awindow->gui->veffects : 0; if( folder ) remove_plugin(plugin, *folder); char plugin_path[BCTEXTLEN]; strcpy(plugin_path, plugin->path); MWindow *mwindow = awindow->mwindow; mwindow->plugindb->remove(plugin); remove(plugin_path); char index_path[BCTEXTLEN]; sprintf(index_path, "%s/%s", mwindow->preferences->plugin_dir, PLUGIN_FILE); remove(index_path); char png_path[BCTEXTLEN]; if( plugin->get_theme_png_path(png_path, mwindow->preferences->theme) ) remove(png_path); if( plugin->get_theme_png_path(png_path, "picon") ) remove(png_path); delete plugin; plugin = 0; awindow->gui->async_update_assets(); } } AWindowRemovePlugin:: AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin) : BC_DialogThread() { this->awindow = awindow; this->plugin = plugin; } AWindowRemovePlugin:: ~AWindowRemovePlugin() { close_window(); } BC_Window* AWindowRemovePlugin::new_gui() { int x = awindow->gui->get_abs_cursor_x(0); int y = awindow->gui->get_abs_cursor_y(0); AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin); gui->create_objects(); return gui; } int AWindowGUI::keypress_event() { switch(get_keypress()) { case 'w': case 'W': if(ctrl_down()) { close_event(); return 1; } break; case DELETE: if(shift_down()) { PluginServer* plugin = selected_plugin(); if( !plugin ) break; remove_plugin = new AWindowRemovePlugin(awindow, plugin); unlock_window(); remove_plugin->start(); lock_window(); } } return 0; } int AWindowGUI::create_custom_xatoms() { UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS"); return 0; } int AWindowGUI::recieve_custom_xatoms(xatom_event *event) { if( event->message_type == UpdateAssetsXAtom ) { update_assets(); return 1; } return 0; } void AWindowGUI::async_update_assets() { xatom_event event; event.message_type = UpdateAssetsXAtom; send_custom_xatom(&event); } void AWindowGUI::update_folder_list() { stop_vicon_drawing(); //printf("AWindowGUI::update_folder_list 1\n"); for(int i = 0; i < folders.total; i++) { AssetPicon *picon = (AssetPicon*)folders.values[i]; picon->in_use--; } //printf("AWindowGUI::update_folder_list 1\n"); // Search assets for folders for(int i = 0; i < mwindow->edl->folders.total; i++) { const char *folder = mwindow->edl->folders.values[i]; int exists = 0; //printf("AWindowGUI::update_folder_list 1.1\n"); for(int j = 0; j < folders.total; j++) { AssetPicon *picon = (AssetPicon*)folders.values[j]; if(!strcasecmp(picon->get_text(), folder)) { exists = 1; picon->in_use = 1; break; } } if(!exists) { int aw_folder = folder_number(folder); AssetPicon *picon = aw_folder >= 0 ? new AssetPicon(mwindow, this, aw_folder) : new AssetPicon(mwindow, this, folder, AW_USER_FOLDER); picon->create_objects(); folders.append(picon); } //printf("AWindowGUI::update_folder_list 1.3\n"); } //printf("AWindowGUI::update_folder_list 1\n"); //for(int i = 0; i < folders.total; i++) // printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text()); // Delete excess for(int i = folders.total - 1; i >= 0; i--) { AssetPicon *picon = (AssetPicon*)folders.values[i]; if(!picon->in_use && !picon->persistent) { delete picon; folders.remove_number(i); } } //for(int i = 0; i < folders.total; i++) // printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text()); //printf("AWindowGUI::update_folder_list 2\n"); start_vicon_drawing(); } void AWindowGUI::create_persistent_folder(ArrayList *output, int do_audio, int do_video, int is_realtime, int is_transition) { ArrayList plugin_list; // Get pointers to plugindb entries mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition, 0, plugin_list); for(int i = 0; i < plugin_list.total; i++) { PluginServer *server = plugin_list.values[i]; int visible = plugin_visibility & (1<dir_idx); if(!visible) continue; // Create new listitem AssetPicon *picon = new AssetPicon(mwindow, this, server); picon->create_objects(); output->append(picon); } } void AWindowGUI::create_label_folder() { Label *current; for(current = mwindow->edl->labels->first; current; current = NEXT) { AssetPicon *picon = new AssetPicon(mwindow, this, current); picon->create_objects(); labellist.append(picon); } } void AWindowGUI::update_asset_list() { //printf("AWindowGUI::update_asset_list 1\n"); for(int i = 0; i < assets.total; i++) { AssetPicon *picon = (AssetPicon*)assets.values[i]; picon->in_use--; } //printf("AWindowGUI::update_asset_list 2\n"); // Synchronize EDL clips for(int i = 0; i < mwindow->edl->clips.total; i++) { int exists = 0; // Look for clip in existing listitems for(int j = 0; j < assets.total && !exists; j++) { AssetPicon *picon = (AssetPicon*)assets.values[j]; if(picon->id == mwindow->edl->clips.values[i]->id) { picon->edl = mwindow->edl->clips.values[i]; picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title); exists = 1; picon->in_use = 1; } } // Create new listitem if(!exists) { AssetPicon *picon = new AssetPicon(mwindow, this, mwindow->edl->clips.values[i]); picon->create_objects(); assets.append(picon); } } //printf("AWindowGUI::update_asset_list %d\n", __LINE__); // Synchronize EDL assets for(Asset *current = mwindow->edl->assets->first; current; current = NEXT) { int exists = 0; // Look for asset in existing listitems for(int j = 0; j < assets.total && !exists; j++) { AssetPicon *picon = (AssetPicon*)assets.values[j]; if(picon->id == current->id) { picon->indexable = current; exists = 1; picon->in_use = 1; break; } } // Create new listitem if(!exists) { //printf("AWindowGUI::update_asset_list %d\n", __LINE__); AssetPicon *picon = new AssetPicon(mwindow, this, current); //printf("AWindowGUI::update_asset_list %d\n", __LINE__); picon->create_objects(); //printf("AWindowGUI::update_asset_list %d\n", __LINE__); assets.append(picon); } } //printf("AWindowGUI::update_asset_list %d\n", __LINE__); // Synchronize nested EDLs for(int i = 0; i < mwindow->edl->nested_edls->size(); i++) { int exists = 0; Indexable *indexable = mwindow->edl->nested_edls->get(i); // Look for asset in existing listitems for(int j = 0; j < assets.total && !exists; j++) { AssetPicon *picon = (AssetPicon*)assets.values[j]; if(picon->id == indexable->id) { picon->indexable = indexable; exists = 1; picon->in_use = 1; break; } } // Create new listitem if(!exists) { AssetPicon *picon = new AssetPicon(mwindow, this, indexable); picon->create_objects(); assets.append(picon); } } //printf("AWindowGUI::update_asset_list %d\n", __LINE__); for(int i = assets.size() - 1; i >= 0; i--) { AssetPicon *picon = (AssetPicon*)assets.get(i); //printf("AWindowGUI::update_asset_list %s %d\n", picon->asset->path, picon->in_use); if(!picon->in_use) { delete picon; assets.remove_number(i); } } //printf("AWindowGUI::update_asset_list 7 %d\n", assets.total); } void AWindowGUI::update_picon(Indexable *indexable) { //printf("AWindowGUI::update_asset_list 1\n"); VIcon *vicon = 0; for(int i = 0; i < assets.total; i++) { AssetPicon *picon = (AssetPicon*)assets.values[i]; if( picon->indexable == indexable || picon->edl == (EDL *)indexable ) { char name[BCTEXTLEN]; FileSystem fs; fs.extract_name(name, indexable->path); picon->set_text(name); vicon = picon->vicon; break; } } if( vicon ) { stop_vicon_drawing(); vicon->clear_images(); vicon->reset(indexable->get_frame_rate()); start_vicon_drawing(); } } void AWindowGUI::sort_assets() { //printf("AWindowGUI::sort_assets 1 %s\n", mwindow->edl->session->current_folder); switch( mwindow->edl->session->awindow_folder ) { case AW_AEFFECT_FOLDER: sort_picons(&aeffects); break; case AW_VEFFECT_FOLDER: sort_picons(&veffects); break; case AW_ATRANSITION_FOLDER: sort_picons(&atransitions); break; case AW_VTRANSITION_FOLDER: sort_picons(&vtransitions); break; case AW_LABEL_FOLDER: // Labels should ALWAYS be sorted by time break; default: sort_picons(&assets); } update_assets(); } void AWindowGUI::collect_assets() { int i = 0; mwindow->session->drag_assets->remove_all(); mwindow->session->drag_clips->remove_all(); while(1) { AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++); if(!result) break; if(result->indexable) mwindow->session->drag_assets->append(result->indexable); if(result->edl) mwindow->session->drag_clips->append(result->edl); } } void AWindowGUI::copy_picons(ArrayList *dst, ArrayList *src, int folder) { // Remove current pointers dst[0].remove_all(); dst[1].remove_all_objects(); // Create new pointers //if(folder) printf("AWindowGUI::copy_picons 1 %s\n", folder); for(int i = 0; i < src->total; i++) { AssetPicon *picon = (AssetPicon*)src->values[i]; //printf("AWindowGUI::copy_picons 2 %s\n", picon->asset->folder); if( folder < 0 || (picon->indexable && picon->indexable->awindow_folder == folder) || (picon->edl && picon->edl->local_session->awindow_folder == folder) ) { BC_ListBoxItem *item2, *item1; dst[0].append(item1 = picon); if(picon->edl) dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes)); else if(picon->label && picon->label->textstr) dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr)); else dst[1].append(item2 = new BC_ListBoxItem("")); item1->set_autoplace_text(1); item2->set_autoplace_text(1); //printf("AWindowGUI::copy_picons 3 %s\n", picon->get_text()); } } } void AWindowGUI::sort_picons(ArrayList *src) { //printf("AWindowGUI::sort_picons 1\n") int done = 0; while(!done) { done = 1; for(int i = 0; i < src->total - 1; i++) { BC_ListBoxItem *item1 = src->values[i]; BC_ListBoxItem *item2 = src->values[i + 1]; item1->set_autoplace_icon(1); item2->set_autoplace_icon(1); item1->set_autoplace_text(1); item2->set_autoplace_text(1); if(strcmp(item1->get_text(), item2->get_text()) > 0) { src->values[i + 1] = item1; src->values[i] = item2; done = 0; } } } } void AWindowGUI::filter_displayed_assets() { allow_iconlisting = 1; asset_titles[0] = _("Title"); asset_titles[1] = _("Comments"); switch( mwindow->edl->session->awindow_folder ) { case AW_AEFFECT_FOLDER: copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER); break; case AW_VEFFECT_FOLDER: copy_picons(displayed_assets, &veffects, AW_NO_FOLDER); break; case AW_ATRANSITION_FOLDER: copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER); break; case AW_VTRANSITION_FOLDER: copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER); break; case AW_LABEL_FOLDER: copy_picons(displayed_assets, &labellist, AW_NO_FOLDER); asset_titles[0] = _("Time Stamps"); asset_titles[1] = _("Title"); allow_iconlisting = 0; break; default: copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder); break; } // Ensure the current folder icon is highlighted for(int i = 0; i < folders.total; i++) folders.values[i]->set_selected(0); folders.values[mwindow->edl->session->awindow_folder]->set_selected(1); } void AWindowGUI::update_assets() { //printf("AWindowGUI::update_assets 1\n"); update_folder_list(); //printf("AWindowGUI::update_assets 2\n"); update_asset_list(); labellist.remove_all_objects(); create_label_folder(); //printf("AWindowGUI::update_assets 3\n"); filter_displayed_assets(); //for(int i = 0; i < folders.total; i++) //printf("AWindowGUI::update_assets 4\n"); // printf("AWindowGUI::update_assets %s\n", folders.values[i]->get_text()); if(mwindow->edl->session->folderlist_format != folder_list->get_format()) folder_list->update_format(mwindow->edl->session->folderlist_format, 0); folder_list->update(&folders, 0, 0, 1, folder_list->get_xposition(), folder_list->get_yposition(), -1); //printf("AWindowGUI::update_assets 5\n"); if(mwindow->edl->session->assetlist_format != asset_list->get_format()) asset_list->update_format(mwindow->edl->session->assetlist_format, 0); //printf("AWindowGUI::update_assets 6 %d\n", displayed_assets[0].total); asset_list->update(displayed_assets, asset_titles, mwindow->edl->session->asset_columns, ASSET_COLUMNS, asset_list->get_xposition(), asset_list->get_yposition(), -1, 0); asset_list->center_selection(); //printf("AWindowGUI::update_assets 7\n"); flush(); //printf("AWindowGUI::update_assets 8\n"); return; } void AWindowGUI::update_effects() { aeffects.remove_all_objects(); create_persistent_folder(&aeffects, 1, 0, 1, 0); veffects.remove_all_objects(); create_persistent_folder(&veffects, 0, 1, 1, 0); atransitions.remove_all_objects(); create_persistent_folder(&atransitions, 1, 0, 0, 1); vtransitions.remove_all_objects(); create_persistent_folder(&vtransitions, 0, 1, 0, 1); } int AWindowGUI::folder_number(const char *name) { for(int i = 0; i < AWINDOW_FOLDERS; i++) { if( !strcasecmp(name, folder_names[i]) ) return i; } return AW_NO_FOLDER; } int AWindowGUI::drag_motion() { if(get_hidden()) return 0; int result = 0; return result; } int AWindowGUI::drag_stop() { if(get_hidden()) return 0; return 0; } Indexable* AWindowGUI::selected_asset() { AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0); return picon ? picon->indexable : 0; } PluginServer* AWindowGUI::selected_plugin() { AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0); return picon ? picon->plugin : 0; } AssetPicon* AWindowGUI::selected_folder() { AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0); return picon; } AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h) : BC_SubWindow(x, y, w, h) { this->mwindow = mwindow; this->gui = gui; } AWindowDivider::~AWindowDivider() { } int AWindowDivider::button_press_event() { if(is_event_win() && cursor_inside()) { mwindow->session->current_operation = DRAG_PARTITION; return 1; } return 0; } int AWindowDivider::cursor_motion_event() { if(mwindow->session->current_operation == DRAG_PARTITION) { int wmin = 25; int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin; int fw = gui->get_relative_cursor_x(); if( fw > wmax ) fw = wmax; if( fw < wmin ) fw = wmin; mwindow->session->afolders_w = fw; mwindow->theme->get_awindow_sizes(gui); gui->reposition_objects(); gui->flush(); } return 0; } int AWindowDivider::button_release_event() { if(mwindow->session->current_operation == DRAG_PARTITION) { mwindow->session->current_operation = NO_OPERATION; return 1; } return 0; } AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h) : BC_ListBox(x, y, w, h, mwindow->edl->session->folderlist_format == ASSETS_ICONS ? LISTBOX_ICONS : LISTBOX_TEXT, &gui->folders, // Each column has an ArrayList of BC_ListBoxItems. 0, // Titles for columns. Set to 0 for no titles 0, // width of each column 1, // Total columns. 0, // Pixel of top of window. 0, // If this listbox is a popup window LISTBOX_SINGLE, // Select one item or multiple items ICON_TOP, // Position of icon relative to text of each item 1) // Allow drags { this->mwindow = mwindow; this->gui = gui; set_drag_scroll(0); } AWindowFolders::~AWindowFolders() { } int AWindowFolders::selection_changed() { AssetPicon *picon = (AssetPicon*)get_selection(0, 0); if(picon) { gui->stop_vicon_drawing(); if(get_button_down() && get_buttonpress() == 3) { gui->folderlist_menu->update_titles(); gui->folderlist_menu->activate_menu(); } mwindow->edl->session->awindow_folder = picon->foldernum; //printf("AWindowFolders::selection_changed 1\n"); gui->asset_list->draw_background(); gui->async_update_assets(); gui->start_vicon_drawing(); } return 1; } int AWindowFolders::button_press_event() { int result = 0; result = BC_ListBox::button_press_event(); if(!result) { if(get_buttonpress() == 3 && is_event_win() && cursor_inside()) { gui->folderlist_menu->update_titles(); gui->folderlist_menu->activate_menu(); result = 1; } } return result; } AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h) : BC_ListBox(x, y, w, h, (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ? LISTBOX_ICONS : LISTBOX_TEXT, &gui->assets, // Each column has an ArrayList of BC_ListBoxItems. gui->asset_titles, // Titles for columns. Set to 0 for no titles mwindow->edl->session->asset_columns, // width of each column 1, // Total columns. 0, // Pixel of top of window. 0, // If this listbox is a popup window LISTBOX_MULTIPLE, // Select one item or multiple items ICON_TOP, // Position of icon relative to text of each item 1) // Allow drag { this->mwindow = mwindow; this->gui = gui; set_drag_scroll(0); } AWindowAssets::~AWindowAssets() { } int AWindowAssets::button_press_event() { int result = 0; result = BC_ListBox::button_press_event(); if(!result && get_buttonpress() == 3 && is_event_win() && cursor_inside()) { BC_ListBox::deactivate_selection(); gui->assetlist_menu->update_titles(); gui->assetlist_menu->activate_menu(); result = 1; } return result; } int AWindowAssets::handle_event() { //printf("AWindowAssets::handle_event 1 %d %d\n", get_buttonpress(), get_selection(0, 0)); AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0); if( !asset_picon ) return 0; switch( mwindow->edl->session->awindow_folder ) { case AW_AEFFECT_FOLDER: case AW_VEFFECT_FOLDER: case AW_ATRANSITION_FOLDER: case AW_VTRANSITION_FOLDER: return 1; } VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ? mwindow->vwindows.get(DEFAULT_VWINDOW) : 0; if( !vwindow || !vwindow->is_running() ) return 1; //printf("AWindowAssets::handle_event 2 %d %d\n", get_buttonpress(), get_selection(0, 0)); vwindow->gui->lock_window("AWindowAssets::handle_event"); if( asset_picon->indexable ) vwindow->change_source(asset_picon->indexable); else if( asset_picon->edl ) vwindow->change_source(asset_picon->edl); vwindow->gui->unlock_window(); return 1; } int AWindowAssets::selection_changed() { // Show popup window if( get_button_down() && get_buttonpress() == 3 && get_selection(0, 0) ) { switch( mwindow->edl->session->awindow_folder ) { case AW_AEFFECT_FOLDER: case AW_VEFFECT_FOLDER: case AW_ATRANSITION_FOLDER: case AW_VTRANSITION_FOLDER: gui->assetlist_menu->update_titles(); gui->assetlist_menu->activate_menu(); break; case AW_LABEL_FOLDER: if(((AssetPicon*)get_selection(0, 0))->label) gui->label_menu->activate_menu(); break; default: if(((AssetPicon*)get_selection(0, 0))->indexable) gui->asset_menu->update(); else if(((AssetPicon*)get_selection(0, 0))->edl) gui->asset_menu->update(); gui->asset_menu->activate_menu(); } BC_ListBox::deactivate_selection(); return 1; } else if( get_button_down() && get_buttonpress() == 1 && get_selection(0, 0) ) { VIcon *vicon = 0; if( !gui->vicon_thread->viewing ) { AssetPicon *picon = (AssetPicon*)get_selection(0, 0); vicon = picon->vicon; } gui->vicon_thread->set_view_popup(vicon); } return 0; } void AWindowAssets::draw_background() { clear_box(0,0,get_w(),get_h(),get_bg_surface()); set_color(BC_WindowBase::get_resources()->audiovideo_color); set_font(LARGEFONT); int aw_folder = mwindow->edl->session->awindow_folder; if( aw_folder < 0 ) return; const char *aw_name = _(AWindowGUI::folder_names[aw_folder]); draw_text(get_w() - get_text_width(LARGEFONT, aw_name) - 4, 30, aw_name, -1, get_bg_surface()); } int AWindowAssets::drag_start_event() { int collect_pluginservers = 0; int collect_assets = 0; if( BC_ListBox::drag_start_event() ) { switch( mwindow->edl->session->awindow_folder ) { case AW_AEFFECT_FOLDER: mwindow->session->current_operation = DRAG_AEFFECT; collect_pluginservers = 1; break; case AW_VEFFECT_FOLDER: mwindow->session->current_operation = DRAG_VEFFECT; collect_pluginservers = 1; break; case AW_ATRANSITION_FOLDER: mwindow->session->current_operation = DRAG_ATRANSITION; collect_pluginservers = 1; break; case AW_VTRANSITION_FOLDER: mwindow->session->current_operation = DRAG_VTRANSITION; collect_pluginservers = 1; break; case AW_LABEL_FOLDER: // do nothing! break; default: mwindow->session->current_operation = DRAG_ASSET; collect_assets = 1; break; } if(collect_pluginservers) { int i = 0; mwindow->session->drag_pluginservers->remove_all(); while(1) { AssetPicon *result = (AssetPicon*)get_selection(0, i++); if(!result) break; mwindow->session->drag_pluginservers->append(result->plugin); } } if(collect_assets) { gui->collect_assets(); } return 1; } return 0; } int AWindowAssets::drag_motion_event() { BC_ListBox::drag_motion_event(); unlock_window(); mwindow->gui->lock_window("AWindowAssets::drag_motion_event"); mwindow->gui->drag_motion(); mwindow->gui->unlock_window(); for(int i = 0; i < mwindow->vwindows.size(); i++) { VWindow *vwindow = mwindow->vwindows.get(i); if( !vwindow->is_running() ) continue; vwindow->gui->lock_window("AWindowAssets::drag_motion_event"); vwindow->gui->drag_motion(); vwindow->gui->unlock_window(); } mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event"); mwindow->cwindow->gui->drag_motion(); mwindow->cwindow->gui->unlock_window(); lock_window("AWindowAssets::drag_motion_event"); return 0; } int AWindowAssets::drag_stop_event() { int result = 0; result = gui->drag_stop(); unlock_window(); if(!result) { mwindow->gui->lock_window("AWindowAssets::drag_stop_event"); result = mwindow->gui->drag_stop(); mwindow->gui->unlock_window(); } if(!result) { for(int i = 0; i < mwindow->vwindows.size(); i++) { VWindow *vwindow = mwindow->vwindows.get(i); if( !vwindow->is_running() ) continue; vwindow->gui->lock_window("AWindowAssets::drag_stop_event"); result = vwindow->gui->drag_stop(); vwindow->gui->unlock_window(); } } if(!result) { mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event"); result = mwindow->cwindow->gui->drag_stop(); mwindow->cwindow->gui->unlock_window(); } lock_window("AWindowAssets::drag_stop_event"); if(result) get_drag_popup()->set_animation(0); BC_ListBox::drag_stop_event(); mwindow->session->current_operation = ::NO_OPERATION; // since NO_OPERATION is also defined in listbox, we have to reach for global scope... return 0; } int AWindowAssets::column_resize_event() { mwindow->edl->session->asset_columns[0] = get_column_width(0); mwindow->edl->session->asset_columns[1] = get_column_width(1); return 1; } int AWindowAssets::focus_in_event() { gui->start_vicon_drawing(); return 0; } int AWindowAssets::focus_out_event() { gui->stop_vicon_drawing(); return BC_ListBox::focus_out_event(); } AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y) : BC_Button(x, y, mwindow->theme->newbin_data) { this->mwindow = mwindow; this->gui = gui; set_tooltip(_("New bin")); } int AWindowNewFolder::handle_event() { gui->newfolder_thread->start_new_folder(); return 1; } AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y) : BC_Button(x, y, mwindow->theme->deletebin_data) { this->mwindow = mwindow; this->gui = gui; set_tooltip(_("Delete bin")); } int AWindowDeleteFolder::handle_event() { if(gui->folder_list->get_selection(0, 0)) { BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0); mwindow->delete_folder(folder->get_text()); } return 1; } AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y) : BC_Button(x, y, mwindow->theme->renamebin_data) { this->mwindow = mwindow; this->gui = gui; set_tooltip(_("Rename bin")); } int AWindowRenameFolder::handle_event() { return 1; } AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y) : BC_Button(x, y, mwindow->theme->deletedisk_data) { this->mwindow = mwindow; this->gui = gui; set_tooltip(_("Delete asset from disk")); } int AWindowDeleteDisk::handle_event() { return 1; } AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y) : BC_Button(x, y, mwindow->theme->deleteproject_data) { this->mwindow = mwindow; this->gui = gui; set_tooltip(_("Delete asset from project")); } int AWindowDeleteProject::handle_event() { return 1; } AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y) : BC_Button(x, y, mwindow->theme->infoasset_data) { this->mwindow = mwindow; this->gui = gui; set_tooltip(_("Edit information on asset")); } int AWindowInfo::handle_event() { gui->awindow->asset_edit->edit_asset(gui->selected_asset()); return 1; } AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y) : BC_Button(x, y, mwindow->theme->redrawindex_data) { this->mwindow = mwindow; this->gui = gui; set_tooltip(_("Redraw index")); } int AWindowRedrawIndex::handle_event() { return 1; } AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y) : BC_Button(x, y, mwindow->theme->pasteasset_data) { this->mwindow = mwindow; this->gui = gui; set_tooltip(_("Paste asset on recordable tracks")); } int AWindowPaste::handle_event() { return 1; } AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y) : BC_Button(x, y, mwindow->theme->appendasset_data) { this->mwindow = mwindow; this->gui = gui; set_tooltip(_("Append asset in new tracks")); } int AWindowAppend::handle_event() { return 1; } AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y) : BC_Button(x, y, mwindow->theme->viewasset_data) { this->mwindow = mwindow; this->gui = gui; set_tooltip(_("View asset")); } int AWindowView::handle_event() { return 1; } LabelPopup::LabelPopup(MWindow *mwindow, AWindowGUI *gui) : BC_PopupMenu(0, 0, 0, "", 0) { this->mwindow = mwindow; this->gui = gui; } LabelPopup::~LabelPopup() { } void LabelPopup::create_objects() { add_item(editlabel = new LabelPopupEdit(mwindow, this)); } int LabelPopup::update() { gui->collect_assets(); return 0; } LabelPopupEdit::LabelPopupEdit(MWindow *mwindow, LabelPopup *popup) : BC_MenuItem(_("Edit...")) { this->mwindow = mwindow; this->popup = popup; } LabelPopupEdit::~LabelPopupEdit() { } int LabelPopupEdit::handle_event() { int i = 0; while(1) { AssetPicon *result = (AssetPicon*)mwindow->awindow->gui->asset_list->get_selection(0, i++); if(!result) break; if(result->label) { mwindow->awindow->gui->awindow->label_edit->edit_label(result->label); break; } } return 1; } AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title) : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4) { this->mwindow = mwindow; this->gui = gui; } void AddTools::create_objects() { uint64_t vis = 0; add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID)); vis |= 1 << PLUGIN_LADSPA_ID; add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID)); vis |= 1 << PLUGIN_FFMPEG_ID; for( int i=0; isize(); ++i ) { PluginServer *plugin = MWindow::plugindb->get(i); if( !plugin->audio && !plugin->video ) continue; int idx = plugin->dir_idx; uint32_t msk = 1 << idx; if( (msk & vis) != 0 ) continue; vis |= msk; char parent[BCTEXTLEN]; strcpy(parent, plugin->path); char *bp = strrchr(parent, '/'); if( bp ) { *bp = 0; bp = strrchr(parent, '/'); } if( !bp ) bp = parent; else ++bp; add_item(new AddPluginItem(this, bp, idx)); } } #if 0 // plugin_dirs list from toplevel makefile include plugin_defs N_("ladspa") N_("ffmpeg") N_("audio_tools") N_("audio_transitions") N_("blending") N_("colors") N_("exotic") N_("transforms") N_("tv_effects") N_("video_tools") N_("video_transitions") #endif AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx) : BC_MenuItem(_(text)) { this->menu = menu; this->idx = idx; uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility; int chk = (msk & vis) ? 1 : 0; set_checked(chk); } int AddPluginItem::handle_event() { int chk = get_checked() ^ 1; set_checked(chk); uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility; menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk; menu->gui->update_effects(); menu->gui->save_defaults(menu->mwindow->defaults); menu->gui->async_update_assets(); return 1; } AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images) : BC_Toggle(x, y, images, agui->vicon_drawing) { this->agui = agui; set_tooltip(_("draw vicons")); } void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh) { int text_line = -1, toggle_x = -1, toggle_y = -1; int text_x = -1, text_y = -1, text_w = -1, text_h = -1; BC_Toggle::calculate_extents(agui, images, 1, &text_line, ww, hh, &toggle_x, &toggle_y, &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT); } AVIconDrawing::~AVIconDrawing() { } int AVIconDrawing::handle_event() { agui->vicon_drawing = get_value(); if( agui->vicon_drawing ) agui->start_vicon_drawing(); else agui->stop_vicon_drawing(); return 1; }