X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.0%2Fcinelerra%2Fawindowgui.C;h=f7fd1c60707d36f64f6133d9591b2e1851008ea1;hp=70df0cce36a7813a57a33ef7a4ddd334fcbbc86b;hb=52fcc46226f9df46f9ce9d0566dc568455a7db0b;hpb=fa7f91658c01ba88aab006beff8b167a4bbb7085 diff --git a/cinelerra-5.0/cinelerra/awindowgui.C b/cinelerra-5.0/cinelerra/awindowgui.C index 70df0cce..f7fd1c60 100644 --- a/cinelerra-5.0/cinelerra/awindowgui.C +++ b/cinelerra-5.0/cinelerra/awindowgui.C @@ -28,6 +28,7 @@ #include "awindow.h" #include "awindowmenu.h" #include "bcsignals.h" +#include "bchash.h" #include "cache.h" #include "bccmodels.h" #include "cursors.h" @@ -50,15 +51,76 @@ #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 + + +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) @@ -109,6 +171,8 @@ AssetPicon::AssetPicon(MWindow *mwindow, 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) ) { @@ -124,6 +188,7 @@ void AssetPicon::reset() edl = 0; icon = 0; icon_vframe = 0; + vicon = 0; in_use = 1; id = 0; persistent = 0; @@ -136,7 +201,7 @@ void AssetPicon::create_objects() int pixmap_w, pixmap_h; const int debug = 0; - pixmap_h = 50; + pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale; if(debug) printf("AssetPicon::create_objects %d\n", __LINE__); if(indexable) @@ -194,16 +259,16 @@ void AssetPicon::create_objects() //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); - BC_CModels::transfer( - icon_vframe->get_rows(), - gui->temp_picon->get_rows(), - 0, 0, 0, 0, 0, 0, 0, 0, - gui->temp_picon->get_w(), - gui->temp_picon->get_h(), - 0, 0, pixmap_w, pixmap_h, - BC_RGB888, BC_RGB888, - 0, 0, 0); - + 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__); } @@ -257,20 +322,28 @@ void AssetPicon::create_objects() icon = gui->atransition_icon; icon_vframe = gui->atransition_vframe; } - else if( !plugin->is_ladspa() ) { - icon = gui->aeffect_icon; - icon_vframe = gui->aeffect_vframe; + else if( plugin->is_ffmpeg() ) { + icon = gui->ff_aud_icon; + icon_vframe = gui->ff_aud_vframe; } - else { + 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; @@ -321,13 +394,17 @@ AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow) 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; remove_plugin = 0; - plugin_visibility = ~0; + vicon_thread = 0; + vicon_drawing = 1; } AWindowGUI::~AWindowGUI() @@ -339,6 +416,8 @@ AWindowGUI::~AWindowGUI() atransitions.remove_all_objects(); vtransitions.remove_all_objects(); displayed_assets[1].remove_all_objects(); + + delete vicon_thread; delete file_icon; delete audio_icon; delete video_icon; @@ -349,6 +428,10 @@ AWindowGUI::~AWindowGUI() 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; @@ -361,15 +444,17 @@ AWindowGUI::~AWindowGUI() bool AWindowGUI::protected_pixmap(BC_Pixmap *icon) { return icon == file_icon || - icon == audio_icon || icon == folder_icon || - icon == clip_icon || + icon == audio_icon || icon == video_icon || - icon == veffect_icon || + icon == clip_icon || icon == vtransition_icon || + icon == atransition_icon || + icon == veffect_icon || icon == aeffect_icon || icon == ladspa_icon || - icon == atransition_icon; + icon == ff_aud_icon || + icon == ff_vid_icon; } void AWindowGUI::create_objects() @@ -411,8 +496,12 @@ SET_TRACE 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 VFrame(lad_picon_png); + 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); @@ -438,6 +527,7 @@ SET_TRACE SET_TRACE mwindow->theme->get_awindow_sizes(this); + load_defaults(mwindow->defaults); SET_TRACE add_subwindow(asset_list = new AWindowAssets(mwindow, @@ -447,6 +537,9 @@ SET_TRACE 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, @@ -459,9 +552,12 @@ 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; - add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, fw)); + 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 @@ -507,21 +603,7 @@ int AWindowGUI::resize_event(int w, int h) mwindow->theme->get_awindow_sizes(this); mwindow->theme->draw_awindow_bg(this); - - 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->reposition_window(fx, fy, fw, add_tools->get_h()); - fy += add_tools->get_h(); fh -= add_tools->get_h(); - folder_list->reposition_window(fx, fy, fw, fh); + reposition_objects(); // int x = mwindow->theme->abuttons_x; // int y = mwindow->theme->abuttons_y; @@ -559,21 +641,35 @@ int AWindowGUI::translation_event() void AWindowGUI::reposition_objects() { mwindow->theme->get_awindow_sizes(this); - 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); - folder_list->reposition_window(mwindow->theme->afolders_x, - mwindow->theme->afolders_y, - mwindow->theme->afolders_w, - mwindow->theme->afolders_h); - flush(); + 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(); @@ -585,10 +681,24 @@ int AWindowGUI::close_event() 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( strcmp(mwindow->edl->session->current_folder, 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) @@ -656,16 +766,20 @@ void AWindowRemovePlugin::handle_close_event(int result) 0; if( folder ) remove_plugin(plugin, *folder); awindow->gui->update_assets(); - char png_path[BCTEXTLEN], plugin_path[BCTEXTLEN], index_path[BCTEXTLEN]; + char plugin_path[BCTEXTLEN]; strcpy(plugin_path, plugin->path); - if( !plugin->get_plugin_png_path(png_path) ) png_path[0] = 0; MWindow *mwindow = awindow->mwindow; - sprintf(index_path, "%s/%s", mwindow->preferences->plugin_dir, PLUGIN_FILE); mwindow->plugindb->remove(plugin); - plugin->delete_this(); + delete plugin; plugin = 0; remove(plugin_path); - if( png_path[0] ) remove(png_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); } } @@ -716,6 +830,7 @@ int AWindowGUI::keypress_event() void AWindowGUI::update_folder_list() { + stop_vicon_drawing(); //printf("AWindowGUI::update_folder_list 1\n"); for(int i = 0; i < folders.total; i++) { @@ -767,6 +882,7 @@ void AWindowGUI::update_folder_list() //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, @@ -1181,8 +1297,6 @@ AssetPicon* AWindowGUI::selected_folder() - - AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h) : BC_SubWindow(x, y, w, h) { @@ -1209,6 +1323,7 @@ int AWindowDivider::cursor_motion_event() { mwindow->session->afolders_w = gui->get_relative_cursor_x(); gui->reposition_objects(); + gui->flush(); } return 0; } @@ -1259,6 +1374,8 @@ 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(); @@ -1269,6 +1386,8 @@ int AWindowFolders::selection_changed() //printf("AWindowFolders::selection_changed 1\n"); gui->asset_list->draw_background(); gui->update_assets(); + + gui->start_vicon_drawing(); } return 1; } @@ -1413,6 +1532,15 @@ int AWindowAssets::selection_changed() 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; } @@ -1563,6 +1691,19 @@ int AWindowAssets::column_resize_event() return 1; } +int AWindowAssets::cursor_enter_event() +{ + int ret = BC_ListBox::cursor_enter_event(); + gui->start_vicon_drawing(); + return ret; +} + +int AWindowAssets::cursor_leave_event() +{ + gui->stop_vicon_drawing(); + return BC_ListBox::cursor_leave_event(); +} + @@ -1711,8 +1852,8 @@ int AWindowView::handle_event() return 1; } -AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w) - : BC_MenuBar(x, y, w) +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; @@ -1720,20 +1861,11 @@ AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w) void AddTools::create_objects() { - add_menu(add_plugins = new AddPluginsMenu(mwindow, gui)); - add_plugins->create_objects(); -} - -AddPluginsMenu::AddPluginsMenu(MWindow *mwindow, AWindowGUI *gui) - : BC_Menu("Add Tools") -{ - this->mwindow = mwindow; - this->gui = gui; -} - -void AddPluginsMenu::create_objects() -{ - uint32_t vis = 0; + 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; @@ -1743,24 +1875,19 @@ void AddPluginsMenu::create_objects() vis |= msk; char parent[BCTEXTLEN]; strcpy(parent, plugin->path); - char *cp = strrchr(parent, '/'); - if( !cp ) continue; - *cp = 0; char *bp = strrchr(parent, '/'); + if( bp ) { *bp = 0; bp = strrchr(parent, '/'); } if( !bp ) bp = parent; else ++bp; - if( !strcmp(bp, "ladspa") ) - gui->plugin_visibility &= ~(1 << idx); add_item(new AddPluginItem(this, bp, idx)); } - } -AddPluginItem::AddPluginItem(AddPluginsMenu *menu, char const *text, int idx) +AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx) : BC_MenuItem(text) { this->menu = menu; this->idx = idx; - uint32_t msk = 1 << idx, vis = menu->gui->plugin_visibility; + uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility; int chk = (msk & vis) ? 1 : 0; set_checked(chk); } @@ -1769,10 +1896,41 @@ int AddPluginItem::handle_event() { int chk = get_checked() ^ 1; set_checked(chk); - uint32_t msk = 1 << idx, vis = menu->gui->plugin_visibility; + 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->update_assets(); + menu->gui->save_defaults(menu->mwindow->defaults); + 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; }