X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmwindow.C;h=8319bfbdead591e94afdb0a1e3ae7f79c87b36d2;hb=22c6251d37911a11e322bf7518e6a992ea0bb6c7;hp=c959af278e7dd832f0a173c6ba3b8df2fe8b2a50;hpb=9e3d90a964c0fbe97c0b58235336a47111932d5d;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index c959af27..8319bfbd 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -243,6 +243,7 @@ MWindow::MWindow() in_destructor = 0; speed_edl = 0; beeper = 0; + redraw_tracks = 0; shuttle = 0; wintv = 0; x10tv = 0; @@ -265,9 +266,10 @@ MWindow::~MWindow() #ifdef HAVE_DVB gui->channel_info->stop(); #endif - delete beeper; - delete create_bd; create_bd = 0; - delete create_dvd; create_dvd = 0; + delete beeper; beeper = 0; + delete redraw_tracks; redraw_tracks = 0; + delete create_bd; create_bd = 0; + delete create_dvd; create_dvd = 0; #ifdef HAVE_SHUTTLE delete shuttle; shuttle = 0; #endif @@ -301,6 +303,7 @@ MWindow::~MWindow() gui->del_keyboard_listener( (int (BC_WindowBase::*)(BC_WindowBase *)) &MWindowGUI::keyboard_listener); + reset_caches(); #if 0 // release the hounds if( awindow && awindow->gui ) awindow->gui->close(0); @@ -329,7 +332,6 @@ MWindow::~MWindow() gui->close(0); join(); #endif - reset_caches(); dead_plugins->remove_all_objects(); // must delete theme before destroying plugindb // theme destructor will be deleted by delete_plugins @@ -347,8 +349,9 @@ MWindow::~MWindow() delete gui; gui = 0; delete mainindexes; mainindexes = 0; delete mainprogress; mainprogress = 0; - delete audio_cache; audio_cache = 0; // delete the cache after the assets - delete video_cache; video_cache = 0; // delete the cache after the assets + // delete the caches after the assets + if( audio_cache ) { audio_cache->remove_user(); audio_cache = 0; } + if( video_cache ) { video_cache->remove_user(); video_cache = 0; } delete frame_cache; frame_cache = 0; delete wave_cache; wave_cache = 0; delete plugin_guis; plugin_guis = 0; @@ -503,6 +506,13 @@ void MWindow::init_defaults(BC_Hash* &defaults, char *config_path) void MWindow::check_language() { + char pref_locale[BCSTRLEN]; + strcpy(pref_locale, DEFAULT_LOCALE); + defaults->get("LOCALE",pref_locale); +// set LANGUAGE if pref locale != sys + if( strcmp(pref_locale, DEFAULT_LOCALE) ) + setenv("LANGUAGE", pref_locale, 1); + char curr_lang[BCTEXTLEN]; curr_lang[0] = 0; const char *env_lang = getenv("LANGUAGE"); if( !env_lang ) env_lang = getenv("LC_ALL"); @@ -1210,10 +1220,23 @@ ZWindow *MWindow::get_mixer(Mixer *&mixer) return zwindow; } -void MWindow::del_mixer(ZWindow *zwindow) +ZWindow *MWindow::get_mixer(int idx) { - zwindows_lock->lock("MWindow::del_mixer 0"); - edl->mixers.del_mixer(zwindow->idx); + ZWindow *zwindow = 0; + zwindows_lock->lock("MWindow::get_mixer"); + for( int i=0; !zwindow && irunning() ) continue; + if( zwdw->idx != idx ) continue; + zwindow = zwindows[i]; + } + zwindows_lock->unlock(); + return zwindow; +} + +void MWindow::close_mixer(ZWindow *zwindow) +{ + zwindows_lock->lock("MWindow::close_mixer 0"); if( session->selected_zwindow >= 0 ) { int i = zwindows.number_of(zwindow); if( i >= 0 && i < session->selected_zwindow ) @@ -1222,7 +1245,7 @@ void MWindow::del_mixer(ZWindow *zwindow) session->selected_zwindow = -1; } zwindows_lock->unlock(); - gui->lock_window("MWindow::del_mixer 1"); + gui->lock_window("MWindow::close_mixer 1"); gui->update_mixers(0, -1); gui->unlock_window(); } @@ -1297,11 +1320,11 @@ void MWindow::handle_mixers(EDL *edl, int command, int wait_tracking, k = mixer->mixer_ids.size(); while( --k >= 0 && track->get_mixer_id() != mixer->mixer_ids[k] ); if( k >= 0 ) { - track->record = 1; + track->armed = 1; track->play = track->data_type == TRACK_VIDEO ? 1 : 0; } else - track->record = track->play = 0; + track->armed = track->play = 0; } zwindow->change_source(mixer_edl); zwindow->handle_mixer(command, 0, @@ -1356,7 +1379,7 @@ ZWindow *MWindow::create_mixer(Indexable *indexable, double position) Mixer *mixer = 0; ZWindow *zwindow = get_mixer(mixer); while( track ) { - track->play = track->record = 0; + track->play = track->armed = 0; if( track->data_type == TRACK_VIDEO ) { sprintf(track->title, _("Mixer %d"), zwindow->idx); } @@ -1499,6 +1522,14 @@ void MWindow::tile_mixers() } } +void MWindow::set_gang_tracks(int v) +{ + edl->session->gang_tracks = v; + gui->update(1, 1, 0, 0, 1, 0, 0); + gui->flush(); +} + + void MWindow::init_cache() { audio_cache = new CICache(preferences); @@ -1769,7 +1800,7 @@ int MWindow::put_commercial() //check it for(Track *track=tracks->first; track && !errmsg; track=track->next) { if( track->data_type != TRACK_VIDEO ) continue; - if( !track->record ) continue; + if( !track->armed ) continue; if( count > 0 ) { errmsg = _("multiple video tracks"); break; } ++count; int64_t units_start = track->to_units(start,0); @@ -1789,7 +1820,7 @@ int MWindow::put_commercial() //run it for(Track *track=tracks->first; track && !errmsg; track=track->next) { if( track->data_type != TRACK_VIDEO ) continue; - if( !track->record ) continue; + if( !track->armed ) continue; int64_t units_start = track->to_units(start,0); int64_t units_end = track->to_units(end,0); Edits *edits = track->edits; @@ -2260,28 +2291,10 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); // Start examining next batch of index files if(got_indexes) mainindexes->start_build(); +// reload renderengine edl or the plugin guis will flip out + sync_parameters(CHANGE_ALL); // Open plugin GUIs - Track *track = edl->tracks->first; - while( track ) { - for( int j = 0; j < track->plugin_set.size(); j++ ) { - PluginSet *plugins = track->plugin_set[j]; - Plugin *plugin = plugins->get_first_plugin(); - - while(plugin) { - if( load_mode == LOADMODE_REPLACE || - load_mode == LOADMODE_REPLACE_CONCATENATE ) { - if( plugin->plugin_type == PLUGIN_STANDALONE && - plugin->show ) { - show_plugin(plugin); - } - } - - plugin = (Plugin*)plugin->next; - } - } - - track = track->next; - } + show_plugins(); // opening new session if( ( load_mode == LOADMODE_REPLACE || @@ -2489,8 +2502,6 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) for( int i=0,n=edl->nested_edls.size(); inested_edls[i]; char new_path[BCTEXTLEN]; - if( !ProxyRender::from_proxy_path(new_path, orig_nested, proxy_scale) ) - continue; proxy_render.to_proxy_path(new_path, orig_nested, proxy_scale); // test if proxy asset was already added to proxy_assets int got_it = 0; @@ -2669,12 +2680,12 @@ void MWindow::create_objects(int want_gui, init_3d(); if(debug) PRINT_TRACE - show_splash(); if(debug) PRINT_TRACE default_standard = default_std(); init_defaults(defaults, config_path); check_language(); + show_splash(); init_preferences(); if(splash_window) splash_window->update_status(_("Initializing Plugins")); @@ -2957,6 +2968,7 @@ void MWindow::show_cwindow() { session->show_cwindow = 1; cwindow->show_window(); + cwindow->gui->tool_panel->raise_tool(); gui->mainmenu->show_cwindow->set_checked(1); } @@ -2994,6 +3006,7 @@ void MWindow::show_lwindow() void MWindow::restore_windows() { + gui->unlock_window(); if( !session->show_vwindow ) { for( int i=0, n=vwindows.size(); ishow_lwindow && lwindow->gui->is_hidden() ) show_lwindow(); + gui->lock_window("MWindow::restore_windows"); gui->focus(); } @@ -3101,7 +3115,6 @@ void MWindow::set_auto_keyframes(int value) gui->mbuttons->edit_panel->keyframe->update(value); gui->flush(); cwindow->gui->lock_window("MWindow::set_auto_keyframes"); - cwindow->gui->edit_panel->keyframe->update(value); cwindow->gui->flush(); cwindow->gui->unlock_window(); } @@ -3112,7 +3125,6 @@ void MWindow::set_span_keyframes(int value) gui->mbuttons->edit_panel->span_keyframe->update(value); gui->flush(); cwindow->gui->lock_window("MWindow::set_span_keyframes"); - cwindow->gui->edit_panel->span_keyframe->update(value); cwindow->gui->flush(); cwindow->gui->unlock_window(); } @@ -3258,10 +3270,9 @@ void MWindow::show_keyframe_gui(Plugin *plugin) { keyframe_gui_lock->lock("MWindow::show_keyframe_gui"); // Find existing thread - for(int i = 0; i < keyframe_threads->size(); i++) - { - if(keyframe_threads->get(i)->plugin == plugin) - { + for( int i=0; isize(); ++i ) { + int plugin_id = keyframe_threads->get(i)->plugin_id; + if( plugin_id == plugin->orig_id ) { keyframe_threads->get(i)->start_window(plugin, 0); keyframe_gui_lock->unlock(); return; @@ -3269,10 +3280,8 @@ void MWindow::show_keyframe_gui(Plugin *plugin) } // Find unused thread - for(int i = 0; i < keyframe_threads->size(); i++) - { - if(!keyframe_threads->get(i)->plugin) - { + for( int i=0; isize(); ++i ) { + if( keyframe_threads->get(i)->plugin_id < 0 ) { keyframe_threads->get(i)->start_window(plugin, 0); keyframe_gui_lock->unlock(); return; @@ -3283,7 +3292,6 @@ void MWindow::show_keyframe_gui(Plugin *plugin) KeyFrameThread *thread = new KeyFrameThread(this); keyframe_threads->append(thread); thread->start_window(plugin, 0); - keyframe_gui_lock->unlock(); } @@ -3301,14 +3309,12 @@ SET_TRACE //printf("MWindow::show_plugin %d\n", __LINE__); SET_TRACE - plugin_gui_lock->lock("MWindow::show_plugin"); - for(int i = 0; i < plugin_guis->total; i++) - { -// Pointer comparison - if(plugin_guis->get(i)->plugin == plugin) - { - plugin_guis->get(i)->raise_window(); + for( int i=0; itotal; ++i ) { +// Pointer/id comparison + PluginServer *plugin_gui = plugin_guis->get(i); + if( plugin_gui->plugin_id == plugin->orig_id ) { + plugin_gui->raise_window(); done = 1; break; } @@ -3348,23 +3354,26 @@ SET_TRACE void MWindow::hide_plugin(Plugin *plugin, int lock) { plugin->show = 0; + return hide_plugin(plugin->orig_id, lock); +} + +void MWindow::hide_plugin(int plugin_id, int lock) +{ // Update the toggle gui->lock_window("MWindow::hide_plugin"); gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0); gui->unlock_window(); if(lock) plugin_gui_lock->lock("MWindow::hide_plugin"); - for(int i = 0; i < plugin_guis->total; i++) - { - if(plugin_guis->get(i)->plugin == plugin) - { - PluginServer *ptr = plugin_guis->get(i); - plugin_guis->remove(ptr); + for( int i=0; itotal; ++i ) { + PluginServer *plugin_gui = plugin_guis->get(i); + if( plugin_gui->plugin_id == plugin_id ) { + plugin_guis->remove(plugin_gui); if(lock) plugin_gui_lock->unlock(); // Last command executed in client side close // Schedule for deletion - ptr->hide_gui(); - delete_plugin(ptr); + plugin_gui->hide_gui(); + delete_plugin(plugin_gui); //sleep(1); return; } @@ -3413,11 +3422,10 @@ void MWindow::hide_keyframe_guis() void MWindow::hide_keyframe_gui(Plugin *plugin) { keyframe_gui_lock->lock("MWindow::hide_keyframe_gui"); - for(int i = 0; i < keyframe_threads->size(); i++) - { - if(keyframe_threads->get(i)->plugin == plugin) - { - keyframe_threads->get(i)->close_window(); + for( int i = 0; i < keyframe_threads->size(); i++) { + KeyFrameThread *keyframe_gui = keyframe_threads->get(i); + if( keyframe_gui->plugin_id == plugin->orig_id ) { + keyframe_gui->close_window(); break; } } @@ -3432,7 +3440,7 @@ int MWindow::get_hash_color(Edit *edit) char path[BCTEXTLEN]; if( !edit->asset || edit->track->data_type != TRACK_VIDEO || edl->session->proxy_scale == 1 || - ProxyRender::from_proxy_path(path, idxbl, edl->session->proxy_scale) ) + ProxyRender::from_proxy_path(path, (Asset*)idxbl, edl->session->proxy_scale) ) strcpy(path, idxbl->path); char *cp = strrchr(path, '/'); cp = !cp ? path : cp+1; @@ -3491,15 +3499,13 @@ void MWindow::update_keyframe_guis() { // Send new configuration to keyframe GUI's keyframe_gui_lock->lock("MWindow::update_keyframe_guis"); - for(int i = 0; i < keyframe_threads->size(); i++) - { - KeyFrameThread *ptr = keyframe_threads->get(i); - if(edl->tracks->plugin_exists(ptr->plugin)) - ptr->update_gui(1); + for( int i=0; isize(); ++i ) { + KeyFrameThread *keyframe_gui = keyframe_threads->get(i); + Plugin *plugin = edl->tracks->plugin_exists(keyframe_gui->plugin_id); + if( plugin ) + keyframe_gui->update_gui(1); else - { - ptr->close_window(); - } + keyframe_gui->close_window(); } keyframe_gui_lock->unlock(); } @@ -3509,55 +3515,42 @@ void MWindow::update_plugin_guis(int do_keyframe_guis) // Send new configuration to plugin GUI's plugin_gui_lock->lock("MWindow::update_plugin_guis"); - for(int i = 0; i < plugin_guis->size(); i++) - { - PluginServer *ptr = plugin_guis->get(i); - if(edl->tracks->plugin_exists(ptr->plugin)) - ptr->update_gui(); - else - { -// Schedule for deletion if no plugin - plugin_guis->remove_number(i); - i--; - - ptr->hide_gui(); - delete_plugin(ptr); + for( int i=0; isize(); ++i ) { + PluginServer *plugin_gui = plugin_guis->get(i); + Plugin *plugin = edl->tracks->plugin_exists(plugin_gui->plugin_id); + if( plugin && plugin->show ) + plugin_gui->update_gui(); + else { +// Schedule for deletion if no plugin or not shown + plugin_guis->remove_number(i--); + plugin_gui->hide_gui(); + delete_plugin(plugin_gui); } } // Change plugin variable if not visible Track *track = edl->tracks->first; - while(track) - { - for(int i = 0; i < track->plugin_set.size(); i++) - { + for( ; track; track=track->next ) { + for( int i=0; i < track->plugin_set.size(); ++i ) { Plugin *plugin = (Plugin*)track->plugin_set[i]->first; - while(plugin) - { + for( ; plugin; plugin = (Plugin*)plugin->next ) { int got_it = 0; - for(int i = 0; i < plugin_guis->size(); i++) - { + for( int i=0; isize(); ++i ) { PluginServer *server = plugin_guis->get(i); - if(server->plugin == plugin) - { + if( server->plugin_id == plugin->orig_id ) { got_it = 1; break; } } - - if(!got_it) plugin->show = 0; - plugin = (Plugin*)plugin->next; + if( !got_it ) plugin->show = 0; } } - - track = track->next; } plugin_gui_lock->unlock(); - - - if(do_keyframe_guis) update_keyframe_guis(); + if( do_keyframe_guis ) + update_keyframe_guis(); } void MWindow::stop_plugin_guis() @@ -3566,10 +3559,8 @@ void MWindow::stop_plugin_guis() plugin_gui_lock->lock("MWindow::stop_plugin_guis"); for( int i=0; isize(); ++i ) { - PluginServer *ptr = plugin_guis->get(i); - if( edl->tracks->plugin_exists(ptr->plugin) ) { - ptr->render_stop(); - } + PluginServer *plugin_gui = plugin_guis->get(i); + plugin_gui->render_stop(); } plugin_gui_lock->unlock(); } @@ -3643,39 +3634,15 @@ int MWindow::get_tracking_direction() void MWindow::update_plugin_states() { plugin_gui_lock->lock("MWindow::update_plugin_states"); - for(int i = 0; i < plugin_guis->total; i++) - { - int result = 0; + for( int i=0; itotal; ++i ) { // Get a plugin GUI - Plugin *src_plugin = plugin_guis->get(i)->plugin; PluginServer *src_plugingui = plugin_guis->get(i); - -// Search for plugin in EDL. Only the master EDL shows plugin GUIs. - for(Track *track = edl->tracks->first; - track && !result; - track = track->next) - { - for(int j = 0; - j < track->plugin_set.total && !result; - j++) - { - PluginSet *plugin_set = track->plugin_set[j]; - for(Plugin *plugin = (Plugin*)plugin_set->first; - plugin && !result; - plugin = (Plugin*)plugin->next) - { - if(plugin == src_plugin && - !strcmp(plugin->title, src_plugingui->title)) result = 1; - } - } - } - - + int plugin_id = src_plugingui->plugin_id; + Plugin *src_plugin = edl->tracks->plugin_exists(plugin_id); // Doesn't exist anymore - if(!result) - { - hide_plugin(src_plugin, 0); - i--; + if( !src_plugin ) { + hide_plugin(plugin_id, 0); + --i; } } plugin_gui_lock->unlock(); @@ -3684,10 +3651,8 @@ void MWindow::update_plugin_states() void MWindow::update_plugin_titles() { - for(int i = 0; i < plugin_guis->total; i++) - { + for( int i=0; itotal; ++i ) plugin_guis->get(i)->update_title(); - } } int MWindow::asset_to_edl(EDL *new_edl, @@ -3776,8 +3741,8 @@ void MWindow::update_project(int load_mode) if( load_mode == LOADMODE_REPLACE || load_mode == LOADMODE_REPLACE_CONCATENATE ) { - delete gui->keyvalue_popup; - gui->keyvalue_popup = 0; + edl->session->timecode_offset = 0; + gui->close_keyvalue_popup(); gui->load_panes(); } @@ -3819,6 +3784,7 @@ void MWindow::update_project(int load_mode) for( int i=0; imixers.size(); ++i ) { Mixer *mixer = edl->mixers[i]; + if( !mixer->show ) continue; ZWindow *zwindow = get_mixer(mixer); zwindow->set_title(mixer->title); zwindow->start(); @@ -3870,10 +3836,12 @@ void MWindow::stack_push(EDL *new_edl, Indexable *idxbl) gui->lock_window("MWindow::stack_push"); if( stack.size() < 9 ) { save_backup(); + hide_plugins(); undo_before(); StackItem &item = stack.append(); item.edl = edl; item.new_edl = new_edl; + item.duration = new_edl->tracks->total_length(); item.undo = undo; item.idxbl = idxbl; item.mtime = 0; @@ -3892,6 +3860,7 @@ void MWindow::stack_push(EDL *new_edl, Indexable *idxbl) update_project(LOADMODE_REPLACE); } gui->unlock_window(); + show_plugins(); } void MWindow::stack_pop() @@ -3899,22 +3868,50 @@ void MWindow::stack_pop() if( !stack.size() ) return; // writes on config_path/backup%d.xml save_backup(); + hide_plugins(); // already have gui lock StackItem &item = stack.last(); // session edl replaced, overwrite and save clip data if( item.new_edl != edl ) item.new_edl->overwrite_clip(edl); + Indexable *idxbl = item.idxbl; + if( idxbl && idxbl->is_asset && item.mtime ) { + Asset *asset = (Asset *)idxbl; + if( asset->format == FILE_REF ) { + char *path = asset->path; + struct stat st; + if( stat(path, &st) || item.mtime == st.st_mtime ) { + int cw = xS(250), ch = yS(150), px, py; + gui->get_pop_cursor(px, py); + px -= cw/2; py -= ch/2; + ConfirmRefWindow confirm(this, path, px, py, cw, ch); + confirm.create_objects(); + int result = confirm.run_window(); + if( !result ) { + FileXML file; + item.new_edl->save_xml(&file, path); + file.terminate_string(); + if(file.write_to_file(path)) + eprintf(_("Cant write FileREF: %s"), path); + } + } + } + } edl->remove_user(); edl = item.edl; delete undo; undo = item.undo; - Indexable *idxbl = item.idxbl; - int64_t mtime = item.mtime; stack.remove(); if( idxbl ) { +// resize the indexable edits if the new_edl duration changed + double duration = item.new_edl->tracks->total_length(); + double dt = duration - item.duration; + if( fabs(dt) > 1e-4 ) + edl->tracks->update_idxbl_length(idxbl->id, dt); gui->unlock_window(); + gui->resource_thread->close_indexable(idxbl); remove_from_caches(idxbl); - remove_indexfile(idxbl); + IndexFile::delete_index_files(preferences, idxbl); mainindexes->add_indexable(idxbl); mainindexes->start_build(); awindow->gui->async_update_assets(); @@ -3923,16 +3920,78 @@ void MWindow::stack_pop() strcpy(session->filename, edl->path); update_project(LOADMODE_REPLACE); undo_after(_("open edl"), LOAD_ALL); + show_plugins(); gui->stack_button->update(); - if( mtime && idxbl && idxbl->is_asset ) { - struct stat st; - Asset *asset = (Asset *)idxbl; - if( asset->format == FILE_REF && !stat(asset->path, &st) && - item.mtime == st.st_mtime ) { - char text[BCTEXTLEN]; - snprintf(text, sizeof(text), - _("Warning: Asset not updated: %s"), asset->path); - show_warning(&preferences->warn_stack, text); +} + +int MWindow::save(EDL *edl, char *filename, int stat) +{ + FileXML file; + edl->save_xml(&file, filename); + file.terminate_string(); + if( file.write_to_file(filename) ) { + eprintf(_("Couldn't open %s"), filename); + return 1; + } + if( stat ) { + char string[BCTEXTLEN]; + char *filename = stack.size() ? + stack[0].edl->path : session->filename; + sprintf(string, _("\"%s\" %jdC written"), + filename, file.length()); + gui->lock_window("SaveAs::run"); + gui->show_message(string); + gui->unlock_window(); + } + return 0; +} + +int MWindow::save(int save_as) +{ + char new_path[BCTEXTLEN]; new_path[0] = 0; + char *path = stack.size() ? stack[0].edl->path : session->filename; + if( save_as || !path[0] ) { + if( ConfirmSave::get_save_path(this, new_path) ) + return 1; + if( stack.size() ) { + strcpy(path, new_path); + set_titlebar(new_path); + } + else + set_filename(new_path); + gui->mainmenu->add_load(new_path); + path = new_path; + } + for( int i=stack.size(); --i>=0; ) { + StackItem &item = stack[i]; + Indexable *idxbl = item.idxbl; + if( !idxbl ) continue; + if( idxbl->is_asset ) { + Asset *asset = (Asset *)idxbl; + if( asset->format == FILE_REF ) { + if( save(item.new_edl, asset->path, 0) ) + return 1; + } + } + else if( item.new_edl != idxbl ) + item.new_edl->overwrite_clip((EDL*)idxbl); + } + EDL *new_edl = stack.size() ? stack[0].edl : edl; + save(new_edl, path, 1); + return 0; +} + +void MWindow::show_plugins() +{ + for( Track *track=edl->tracks->first; track; track=track->next ) { + for( int i=0; iplugin_set.size(); ++i ) { + PluginSet *plugins = track->plugin_set[i]; + Plugin *plugin = plugins->get_first_plugin(); + for( ; plugin; plugin=(Plugin*)plugin->next ) { + if( plugin->plugin_type == PLUGIN_STANDALONE && + plugin->show ) + show_plugin(plugin); + } } } } @@ -3944,6 +4003,7 @@ void MWindow::clip_to_media() return; } undo_before(); + awindow->gui->stop_vicon_drawing(); int clips_total = session->drag_clips->total; for( int i=0; idrag_clips->values[i]; @@ -3957,7 +4017,7 @@ void MWindow::clip_to_media() char *bp = strrchr(clip->local_session->clip_title, '/'); bp = bp ? bp+1 : clip->local_session->clip_title; cp += snprintf(cp, ep-cp, "%s", bp); - EDL *nested = edl->new_nested_edl(clip, path); + EDL *nested = edl->new_nested_clip(clip, path); edl->clips.remove(clip); clip->remove_user(); mainindexes->add_indexable(nested); @@ -4059,11 +4119,8 @@ void MWindow::update_vwindow() void MWindow::remove_indexfile(Indexable *indexable) { if( !indexable->is_asset ) return; - Asset *asset = (Asset *)indexable; // Erase file - IndexFile::delete_index(preferences, asset, ".toc"); - IndexFile::delete_index(preferences, asset, ".idx"); - IndexFile::delete_index(preferences, asset, ".mkr"); + IndexFile::delete_index_files(preferences, indexable); } void MWindow::rebuild_indices() @@ -4420,29 +4477,28 @@ int MWindow::create_aspect_ratio(float &w, float &h, int width, int height) void MWindow::reset_caches() { - frame_cache->remove_all(); - wave_cache->remove_all(); - audio_cache->remove_all(); - video_cache->remove_all(); - if( cwindow->playback_engine ) { - if( cwindow->playback_engine->audio_cache ) - cwindow->playback_engine->audio_cache->remove_all(); - if( cwindow->playback_engine->video_cache ) - cwindow->playback_engine->video_cache->remove_all(); - } + int locked = gui->get_window_lock(); + if( locked ) gui->unlock_window(); + awindow->gui->stop_vicon_drawing(1); + if( cwindow->playback_engine ) + cwindow->playback_engine->create_cache(); for(int i = 0; i < vwindows.size(); i++) { VWindow *vwindow = vwindows[i]; if( !vwindow->is_running() ) continue; if( !vwindow->playback_engine ) continue; - if( vwindow->playback_engine->audio_cache ) - vwindow->playback_engine->audio_cache->remove_all(); - if( vwindow->playback_engine->video_cache ) - vwindow->playback_engine->video_cache->remove_all(); + vwindow->playback_engine->create_cache(); } + gui->lock_window("MWindow::reset_caches"); + frame_cache->remove_all(); + wave_cache->remove_all(); + audio_cache->remove_all(); + video_cache->remove_all(); + if( !locked ) gui->unlock_window(); } void MWindow::remove_from_caches(Indexable *idxbl) { + awindow->gui->stop_vicon_drawing(1); frame_cache->remove_item(idxbl); wave_cache->remove_item(idxbl); if( gui->render_engine && @@ -4450,11 +4506,7 @@ void MWindow::remove_from_caches(Indexable *idxbl) delete gui->render_engine; gui->render_engine = 0; } - if( gui->resource_thread->render_engine_id == idxbl->id ) { - gui->resource_thread->render_engine_id = -1; - delete gui->resource_thread->render_engine; - gui->resource_thread->render_engine = 0; - } + gui->resource_thread->close_indexable(idxbl); if( !idxbl->is_asset ) return; Asset *asset = (Asset *)idxbl; audio_cache->delete_entry(asset); @@ -4480,12 +4532,13 @@ void MWindow::remove_from_caches(Indexable *idxbl) if( zwindow->zgui->playback_engine->video_cache ) zwindow->zgui->playback_engine->video_cache->delete_entry(asset); } + awindow->gui->start_vicon_drawing(); } void MWindow::remove_assets_from_project(int push_undo, int redraw, int delete_indexes, ArrayList *drag_assets, ArrayList *drag_clips) { - awindow->gui->close_view_popup(); + awindow->gui->stop_vicon_drawing(1); // Remove from VWindow. if( drag_clips ) { @@ -4640,6 +4693,14 @@ void MWindow::dump_exe(FILE *fp) fprintf(fp, "\n"); } +void MWindow::dump_caches(FILE *fp) +{ + fprintf(fp, "audio cache: "); + audio_cache->dump(fp); + fprintf(fp, "video cache: "); + video_cache->dump(fp); +} + void MWindow::trap_hook(FILE *fp, void *vp) { MWindow *mwindow = (MWindow *)vp; @@ -4651,6 +4712,8 @@ void MWindow::trap_hook(FILE *fp, void *vp) mwindow->dump_undo(fp); fprintf(fp, "\nEXE: %s\n", AboutPrefs::build_timestamp); mwindow->dump_exe(fp); + fprintf(fp, "\nCACHES:\n"); + mwindow->dump_caches(fp); } @@ -4721,31 +4784,30 @@ int MWindow::interrupt_indexes() void MWindow::next_time_format() { - switch(edl->session->time_format) - { - case TIME_HMS: edl->session->time_format = TIME_HMSF; break; - case TIME_HMSF: edl->session->time_format = TIME_SAMPLES; break; - case TIME_SAMPLES: edl->session->time_format = TIME_SAMPLES_HEX; break; - case TIME_SAMPLES_HEX: edl->session->time_format = TIME_FRAMES; break; - case TIME_FRAMES: edl->session->time_format = TIME_FEET_FRAMES; break; - case TIME_FEET_FRAMES: edl->session->time_format = TIME_SECONDS; break; - case TIME_SECONDS: edl->session->time_format = TIME_HMS; break; + switch( edl->session->time_format ) { + case TIME_HMS: edl->session->time_format = TIME_HMSF; break; + case TIME_HMSF: edl->session->time_format = TIME_TIMECODE; break; + case TIME_TIMECODE: edl->session->time_format = TIME_FRAMES; break; + case TIME_FRAMES: edl->session->time_format = TIME_SAMPLES; break; + case TIME_SAMPLES: edl->session->time_format = TIME_SAMPLES_HEX; break; + case TIME_SAMPLES_HEX: edl->session->time_format = TIME_SECONDS; break; + case TIME_SECONDS: edl->session->time_format = TIME_FEET_FRAMES; break; + case TIME_FEET_FRAMES: edl->session->time_format = TIME_HMS; break; } - time_format_common(); } void MWindow::prev_time_format() { - switch(edl->session->time_format) - { - case TIME_HMS: edl->session->time_format = TIME_SECONDS; break; - case TIME_SECONDS: edl->session->time_format = TIME_FEET_FRAMES; break; - case TIME_FEET_FRAMES: edl->session->time_format = TIME_FRAMES; break; - case TIME_FRAMES: edl->session->time_format = TIME_SAMPLES_HEX; break; - case TIME_SAMPLES_HEX: edl->session->time_format = TIME_SAMPLES; break; - case TIME_SAMPLES: edl->session->time_format = TIME_HMSF; break; - case TIME_HMSF: edl->session->time_format = TIME_HMS; break; + switch( edl->session->time_format ) { + case TIME_HMS: edl->session->time_format = TIME_FEET_FRAMES; break; + case TIME_HMSF: edl->session->time_format = TIME_HMS; break; + case TIME_TIMECODE: edl->session->time_format = TIME_HMSF; break; + case TIME_FRAMES: edl->session->time_format = TIME_TIMECODE; break; + case TIME_SAMPLES: edl->session->time_format = TIME_FRAMES; break; + case TIME_SAMPLES_HEX: edl->session->time_format = TIME_SAMPLES; break; + case TIME_SECONDS: edl->session->time_format = TIME_SAMPLES_HEX; break; + case TIME_FEET_FRAMES: edl->session->time_format = TIME_SECONDS; break; } time_format_common(); @@ -4771,32 +4833,25 @@ int MWindow::set_filename(const char *filename) strcpy(session->filename, filename); if( filename != edl->path ) strcpy(edl->path, filename); + return set_titlebar(filename); +} - if(gui) - { - if(filename[0] == 0) - { - gui->set_title(PROGRAM_NAME); - } - else - { - FileSystem dir; - char string[BCTEXTLEN], string2[BCTEXTLEN]; - dir.extract_name(string, filename); - sprintf(string2, PROGRAM_NAME ": %s", string); - gui->set_title(string2); - } +int MWindow::set_titlebar(const char *filename) +{ + if( !gui ) return 0; + if( filename[0] ) { + FileSystem dir; + char string[BCTEXTLEN], string2[BCTEXTLEN]; + dir.extract_name(string, filename); + sprintf(string2, PROGRAM_NAME ": %s", string); + gui->set_title(string2); } + else + gui->set_title(PROGRAM_NAME); return 0; } - - - - - - int MWindow::set_loop_boundaries() { double start = edl->local_session->get_selectionstart(); @@ -4966,7 +5021,7 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra track->track_h = edl->session->output_h; } else if( delete_tracks ) - edl->tracks->delete_track(track); + edl->tracks->delete_track(track, 0); } edl->retrack(); edl->resample(old_framerate, session->frame_rate, TRACK_VIDEO); @@ -5002,7 +5057,7 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra delete edit; } if( !track->edits->first ) - edl->tracks->delete_track(track); + edl->tracks->delete_track(track, 0); } } edl->rechannel(); @@ -5084,3 +5139,72 @@ PatchGUI *MWindow::get_patchgui(Track *track) return patchgui; } +int MWindow::get_cpus(int out_w, int out_h) +{ + if( !out_w ) out_w = edl->session->output_w; + if( !out_h ) out_h = edl->session->output_h; + int cpus = out_w*out_h/0x80000 + 1; + if( cpus > preferences->processors ) + cpus = preferences->processors; + return cpus; +} +int MWindow::get_cpus() +{ + return get_cpus(edl->session->output_w, edl->session->output_h); +} + +void MWindow::draw_trackmovement() +{ + if( !redraw_tracks ) + redraw_tracks = new DrawTrackMovement(this); + redraw_tracks->start(); +} + +DrawTrackMovement::DrawTrackMovement(MWindow *mwindow) + : Thread(1, 0, 0) +{ + this->mwindow = mwindow; +} +DrawTrackMovement::~DrawTrackMovement() +{ + join(); +} + +void DrawTrackMovement::run() +{ + mwindow->gui->lock_window("DrawTrackMovement::run"); + mwindow->edl->tracks->update_y_pixels(mwindow->theme); + mwindow->gui->draw_trackmovement(); + mwindow->gui->unlock_window(); +} + + +ConfirmRefWindow::ConfirmRefWindow(MWindow *mwindow, char *path, + int px, int py, int cw, int ch) + : BC_Window(_(PROGRAM_NAME ": Confirm update"), px, py, cw, ch, cw, ch) +{ + this->mwindow = mwindow; + this->path = path; +} + +ConfirmRefWindow::~ConfirmRefWindow() +{ +} + +void ConfirmRefWindow::create_objects() +{ + lock_window("ConfirmRefWindow::create_objects()"); + int x = xS(10), y = yS(10), pad = yS(5); + BC_Title *title; + add_subwindow(title = new BC_Title(x, y, _("FileREF not updated:"))); + y += title->get_h() + pad; + BC_TextBox *text_box; + add_subwindow(text_box = new BC_TextBox(x,y, get_w()-2*x, 1, path)); + y += text_box->get_h() + 2*pad; + add_subwindow(title = new BC_Title(x, y, _("Save file ref changes?"))); + add_subwindow(new BC_OKButton(this)); + add_subwindow(new BC_CancelButton(this)); + show_window(); + unlock_window(); +} +