X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmwindow.C;h=3213969abbb21afeba816719a41d982a8ab848fa;hb=52c715cbb159b61590b95182eedbadac84bbdfe6;hp=e81b4574387016109e21385ac5fd73b8b2a9b796;hpb=6853a2c0b04cc5ff4e87a2022c914227f925cb7f;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index e81b4574..3213969a 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -28,6 +28,7 @@ #include "awindow.h" #include "batchrender.h" #include "bcdisplayinfo.h" +#include "bcprogressbox.h" #include "bcsignals.h" #include "bctimer.h" #include "bctrace.h" @@ -98,6 +99,7 @@ #include "removefile.h" #include "render.h" #include "resourcethread.h" +#include "savefile.inc" #include "samplescroll.h" #include "sha1.h" #include "sighandler.h" @@ -1307,6 +1309,7 @@ void MWindow::stop_mixers() void MWindow::close_mixers(int destroy) { + ArrayList closed; zwindows_lock->lock("MWindow::close_mixers"); for( int i=zwindows.size(); --i>=0; ) { ZWindow *zwindow = zwindows[i]; @@ -1316,12 +1319,12 @@ void MWindow::close_mixers(int destroy) zgui->lock_window("MWindow::select_zwindow 0"); zgui->set_done(0); zgui->unlock_window(); + closed.append(zwindow); } zwindows_lock->unlock(); - for( int i=0; iidx < 0 ) continue; - zwindow->close_window(); + for( int i=0; ijoin(); } } @@ -1554,9 +1557,7 @@ void MWindow::init_indexes() void MWindow::init_gui() { gui = new MWindowGUI(this); - gui->lock_window("MWindow::init_gui"); gui->create_objects(); - gui->unlock_window(); gui->load_defaults(defaults); } @@ -1840,7 +1841,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); char string[BCTEXTLEN]; new_edl->create_objects(); - new_edl->copy_session(edl); + new_edl->copy_session(edl, -1); new_file->set_program(edl->session->program_no); sprintf(string, _("Loading %s"), new_asset->path); @@ -2176,7 +2177,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); edl->session->proxy_auto_scale = 0; edl->session->proxy_beep = 0; edl->local_session->preview_start = 0; - edl->local_session->preview_end = 0; + edl->local_session->preview_end = -1; edl->local_session->loop_playback = 0; edl->local_session->set_selectionstart(0); edl->local_session->set_selectionend(0); @@ -2295,11 +2296,12 @@ int MWindow::enable_proxy() if( edl->session->proxy_scale == 1 && edl->session->proxy_disabled_scale != 1 ) { int new_scale = edl->session->proxy_disabled_scale; + int new_use_scaler = edl->session->proxy_use_scaler; edl->session->proxy_disabled_scale = 1; Asset *asset = new Asset; asset->format = FILE_FFMPEG; asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0); - ret = to_proxy(asset, new_scale); + ret = to_proxy(asset, new_scale, new_use_scaler); asset->remove_user(); if( ret > 0 ) beep(2000., 1.5, 0.5); @@ -2311,17 +2313,19 @@ int MWindow::disable_proxy() { if( edl->session->proxy_scale != 1 && edl->session->proxy_disabled_scale == 1 ) { + int new_scale = 1; + int new_use_scaler = edl->session->proxy_use_scaler; edl->session->proxy_disabled_scale = edl->session->proxy_scale; Asset *asset = new Asset; asset->format = FILE_FFMPEG; asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0); - to_proxy(asset, 1); + to_proxy(asset, new_scale, new_use_scaler); asset->remove_user(); } return 1; } -int MWindow::to_proxy(Asset *asset, int new_scale) +int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) { ArrayList orig_idxbls; ArrayList proxy_assets; @@ -2334,7 +2338,6 @@ int MWindow::to_proxy(Asset *asset, int new_scale) // revert project to original size from current size // remove all session proxy assets at the at the current proxy_scale int proxy_scale = edl->session->proxy_scale; - int proxy_use_scaler = edl->session->proxy_use_scaler; if( proxy_scale > 1 ) { Asset *orig_asset = edl->assets->first; @@ -2439,7 +2442,7 @@ int MWindow::to_proxy(Asset *asset, int new_scale) result = proxy_render.create_needed_proxies(new_scale); if( !result ) // resize project - edl->set_proxy(new_scale, proxy_use_scaler, + edl->set_proxy(new_scale, new_use_scaler, &proxy_render.orig_idxbls, &proxy_render.orig_proxies); undo->update_undo_after(_("proxy"), LOAD_ALL); @@ -2550,14 +2553,14 @@ void MWindow::create_objects(int want_gui, check_language(); init_preferences(); if(splash_window) - splash_window->operation->update(_("Initializing Plugins")); + splash_window->update_status(_("Initializing Plugins")); init_plugins(this, preferences); if(debug) PRINT_TRACE init_ladspa_plugins(this, preferences); if(debug) PRINT_TRACE init_plugin_tips(*plugindb, cin_lang); if(splash_window) - splash_window->operation->update(_("Initializing GUI")); + splash_window->update_status(_("Initializing GUI")); if(debug) PRINT_TRACE init_theme(); @@ -2565,7 +2568,7 @@ void MWindow::create_objects(int want_gui, init_error(); if(splash_window) - splash_window->operation->update(_("Initializing Fonts")); + splash_window->update_status(_("Initializing Fonts")); char string[BCTEXTLEN]; strcpy(string, preferences->plugin_dir); strcat(string, "/" FONT_SEARCHPATH); @@ -2877,12 +2880,6 @@ void MWindow::toggle_loop_playback() sync_parameters(CHANGE_PARAMS); } -//void MWindow::set_titles(int value) -//{ -// edl->session->show_titles = value; -// trackmovement(edl->local_session->track_start); -//} - void MWindow::set_screens(int value) { screens = value; @@ -2952,6 +2949,19 @@ void MWindow::toggle_editing_mode() set_editing_mode(EDITING_ARROW, 0, 1); } +void MWindow::toggle_camera_xyz() +{ + gwindow->gui->lock_window("MWindow::toggle_camera_xyz"); + gwindow->gui->toggle_camera_xyz(); + gwindow->gui->unlock_window(); +} + +void MWindow::toggle_projector_xyz() +{ + gwindow->gui->lock_window("MWindow::toggle_projector_xyz"); + gwindow->gui->toggle_projector_xyz(); + gwindow->gui->unlock_window(); +} void MWindow::set_labels_follow_edits(int value) { @@ -3648,6 +3658,187 @@ void MWindow::load_undo_data() fclose(fp); } + +int MWindow::copy_target(const char *path, const char *target) +{ + int ifd = ::open(path, O_RDONLY); + if( ifd < 0 ) { + eprintf("Cannot open asset: %s", path); + return 1; + } + int ret = 0; + int ofd = ::open(target, O_CREAT+O_TRUNC+O_WRONLY, 0777); + if( ofd >= 0 ) { + struct stat st; + int64_t total_bytes = !fstat(ifd, &st) ? st.st_size : 0; + char progress_title[BCTEXTLEN]; + sprintf(progress_title, _("Copying: %s\n"), target); + BC_ProgressBox progress(-1, -1, progress_title, total_bytes); + + int64_t count = 0, len = -1; + int bfrsz = 0x100000; + uint8_t *bfr = new uint8_t[bfrsz]; + while( (len=::read(ifd, bfr, bfrsz)) > 0 ) { + if( len != ::write(ofd, bfr, len) ) { + eprintf("Error writing: %s", target); + break; + } + if( progress.is_cancelled() ) { + ret = 1; + break; + } + progress.update(count += len, 1); + } + delete [] bfr; + ::close(ofd); + + progress.stop_progress(); + if( len < 0 ) { + eprintf("Error reading: %s", path); + ret = 1; + } + } + else + eprintf("Cannot create asset target: %s", target); + ::close(ifd); + return ret; +} + +int MWindow::link_target(const char *real_path, const char *link_path, int relative) +{ + char target[BCTEXTLEN]; + if( relative ) { + const char *bp = real_path, *cp = bp; + const char *lp = link_path, *np = lp; + char *tp = target, *ep = tp+sizeof(target)-1, lch; + while( *lp && *bp && (lch=*lp++) == *bp++ ) { + if( lch == '/' ) { np = lp; cp = bp; } + } + while( tpcreate_objects(); + save_edl->copy_all(edl); + + char progress_title[BCTEXTLEN]; + sprintf(progress_title, _("Saving to %s:\n"), dir); + int total_assets = save_edl->assets->total(); + MainProgressBar *progress = mainprogress->start_progress(progress_title, total_assets); + int ret = 0; + Asset *current = save_edl->assets->first; + for( int i=0; !ret && current; ++i, current=NEXT ) { + char *path = current->path; + if( ::stat(path, &st) ) { + eprintf("Asset not found: %s", path); + continue; + } + char *real_path = realpath(path, 0); + const char *cp = strrchr(path, '/'), *bp = !cp ? path : cp+1; + char link_path[BCTEXTLEN]; + snprintf(link_path, sizeof(link_path), "%s/%s", dir_path, bp); + int skip = 0; + if( strcmp(real_path, link_path) ) { + if( !::lstat(link_path, &st) ) { + if( overwrite ) + ::remove(link_path); + else + skip = 1; + } + } + else { + eprintf("copy/link to self, skippped: %s", path); + skip = 1; + } + if( !skip ) { + if( save_mode == SAVE_PROJECT_COPY ) { + if( copy_target(real_path, link_path) ) + ret = 1; + } + else { + link_target(real_path, link_path, + save_mode == SAVE_PROJECT_RELLINK ? 1 : 0); + } + } + free(real_path); + strcpy(path, link_path); + + if( progress->is_cancelled() ) break; + progress->update(i); + } + + progress->stop_progress(); + delete progress; + + char *cp = strrchr(dir_path,'/'); + char *bp = cp ? cp+1 : dir_path; + char filename[BCTEXTLEN]; + snprintf(filename, sizeof(filename), "%s/%s.xml", dir_path, bp); + save_edl->set_path(filename); + FileXML file; + save_edl->save_xml(&file, filename); + file.terminate_string(); + + if( !file.write_to_file(filename) ) { + char string[BCTEXTLEN]; + sprintf(string, _("\"%s\" %dC written"), filename, (int)strlen(file.string())); + gui->lock_window("SaveProject::run 2"); + gui->show_message(string); + gui->unlock_window(); + gui->mainmenu->add_load(filename); + } + else + eprintf(_("Couldn't open %s."), filename); + + save_edl->remove_user(); + + if( reload ) { + gui->lock_window("MWindow::save_project"); + ArrayList filenames; + filenames.append(filename); + load_filenames(&filenames, LOADMODE_REPLACE); + gui->unlock_window(); + } +} + + static inline int gcd(int m, int n) { int r;