X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmwindow.C;h=8319bfbdead591e94afdb0a1e3ae7f79c87b36d2;hb=22c6251d37911a11e322bf7518e6a992ea0bb6c7;hp=c4e7a7cbf1fe22118a12034cffddcfe47ed2c114;hpb=48a6854a1ca58aa291ffc6fe3a48807492dfbef7;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index c4e7a7cb..8319bfbd 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -349,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; @@ -505,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"); @@ -2283,6 +2291,8 @@ 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 show_plugins(); @@ -2492,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; @@ -2672,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")); @@ -2960,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); } @@ -3431,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; @@ -3732,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(); } @@ -3805,7 +3814,7 @@ void MWindow::update_project(int load_mode) if(debug) PRINT_TRACE } -void MWindow::stack_push(EDL *new_edl, Indexable *idxbl, Edit *edit) +void MWindow::stack_push(EDL *new_edl, Indexable *idxbl) { int got_indexes = 0; for( int i=0; inested_edls.size(); ++i ) { @@ -3831,7 +3840,6 @@ void MWindow::stack_push(EDL *new_edl, Indexable *idxbl, Edit *edit) undo_before(); StackItem &item = stack.append(); item.edl = edl; - item.edit = edit; item.new_edl = new_edl; item.duration = new_edl->tracks->total_length(); item.undo = undo; @@ -3866,29 +3874,44 @@ void MWindow::stack_pop() // session edl replaced, overwrite and save clip data if( item.new_edl != edl ) item.new_edl->overwrite_clip(edl); - Edit *edit = item.edit; -// resize the referring edit if the edl duration changed - if( edit ) { - double duration = item.new_edl->tracks->total_length(); - double dt = duration - item.duration; - if( fabs(dt) > 1e-4 ) { - int64_t du = edit->track->to_units(dt,0); - if( (edit->length+=du) < 0 ) - edit->length = 0; + 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(); @@ -3899,17 +3922,6 @@ void MWindow::stack_pop() 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) @@ -3953,6 +3965,7 @@ int MWindow::save(int save_as) 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 ) { @@ -3960,8 +3973,8 @@ int MWindow::save(int save_as) return 1; } } - else if( item.new_edl != item.idxbl ) - item.new_edl->overwrite_clip((EDL*)item.idxbl); + 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); @@ -4004,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); @@ -4106,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() @@ -4467,31 +4477,28 @@ int MWindow::create_aspect_ratio(float &w, float &h, int width, int height) void MWindow::reset_caches() { - awindow->gui->stop_vicon_drawing(); - 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(); + awindow->gui->stop_vicon_drawing(1); frame_cache->remove_item(idxbl); wave_cache->remove_item(idxbl); if( gui->render_engine && @@ -4531,7 +4538,7 @@ void MWindow::remove_from_caches(Indexable *idxbl) void MWindow::remove_assets_from_project(int push_undo, int redraw, int delete_indexes, ArrayList *drag_assets, ArrayList *drag_clips) { - awindow->gui->stop_vicon_drawing(); + awindow->gui->stop_vicon_drawing(1); // Remove from VWindow. if( drag_clips ) { @@ -4777,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(); @@ -5015,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); @@ -5051,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(); @@ -5172,3 +5178,33 @@ void DrawTrackMovement::run() 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(); +} +