X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fpreferencesthread.C;h=75d8fe81e5741296b0fdc7c1ee31c4015b09ff55;hp=fbac1848a2f00fa052339c2ec7a44f69ba8793ab;hb=ddfda6a8cc59bda4dc734973c1c5fecaa31ea487;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/cinelerra/preferencesthread.C b/cinelerra-5.1/cinelerra/preferencesthread.C index fbac1848..75d8fe81 100644 --- a/cinelerra-5.1/cinelerra/preferencesthread.C +++ b/cinelerra-5.1/cinelerra/preferencesthread.C @@ -52,7 +52,9 @@ #include "playbackengine.h" #include "playbackprefs.h" #include "preferences.h" +#include "record.h" #include "recordprefs.h" +#include "render.h" #include "shbtnprefs.h" #include "theme.h" #include "trackcanvas.h" @@ -64,8 +66,8 @@ -#define WIDTH 860 -#define HEIGHT 700 +#define WIDTH xS(860) +#define HEIGHT yS(700) PreferencesMenuitem::PreferencesMenuitem(MWindow *mwindow) @@ -122,10 +124,11 @@ BC_Window* PreferencesThread::new_gui() redraw_overlays = 0; close_assets = 0; reload_plugins = 0; + reset_caches = 0; //int need_new_indexes = 0; rerender = 0; - mwindow->gui->lock_window("NewThread::new_gui"); + mwindow->gui->lock_window("NewThread::new_gui"); int scr_x = mwindow->gui->get_screen_x(0, -1); int scr_w = mwindow->gui->get_screen_w(0, -1); int scr_h = mwindow->gui->get_screen_h(0, -1); @@ -174,10 +177,10 @@ int PreferencesThread::update_framerate() { if(thread_running) { - lock_gui("PreferencesThread::update_framerate"); + lock_dialog("PreferencesThread::update_framerate"); PreferencesWindow *window = (PreferencesWindow*)get_gui(); if(window) window->update_framerate(); - unlock_gui(); + unlock_dialog(); } return 0; } @@ -187,10 +190,10 @@ void PreferencesThread::update_rates() { if(thread_running) { - lock_gui("PreferencesThread::update_framerate"); + lock_dialog("PreferencesThread::update_framerate"); PreferencesWindow *window = (PreferencesWindow*)get_gui(); if(window) window->update_rates(); - unlock_gui(); + unlock_dialog(); } } @@ -212,6 +215,9 @@ int PreferencesThread::apply_settings() (*this_aconfig != *aconfig) || (*this_vconfig != *vconfig) || !preferences->brender_asset->equivalent(*mwindow->preferences->brender_asset, 0, 1, edl); + if( preferences->autocolor_assets != mwindow->preferences->autocolor_assets ) + redraw_indexes = 1; + if( preferences->yuv_color_space != mwindow->preferences->yuv_color_space || preferences->yuv_color_range != mwindow->preferences->yuv_color_range ) { YUV::yuv.yuv_set_colors( @@ -231,10 +237,14 @@ int PreferencesThread::apply_settings() mwindow->stop_brender(); if( window ) window->lock_window("PreferencesThread::apply_settings 5"); - if( strcmp(preferences->theme, mwindow->preferences->theme) != 0 ) - mwindow->restart_status = -1; // reload, need new bcresources - if( strcmp(preferences->plugin_icons, mwindow->preferences->plugin_icons) != 0 ) - mwindow->restart_status = -1; + if( strcmp(preferences->theme, mwindow->preferences->theme) || + strcmp(preferences->locale, mwindow->preferences->locale) || + strcmp(preferences->plugin_icons, mwindow->preferences->plugin_icons) || + preferences->awindow_picon_h != mwindow->preferences->awindow_picon_h || + preferences->layout_scale != mwindow->preferences->layout_scale || + preferences->vicon_size != mwindow->preferences->vicon_size || + preferences->vicon_color_mode != mwindow->preferences->vicon_color_mode ) + mwindow->restart_status = -1; // reconstruct/restart program if( strcmp(preferences->lv2_path, mwindow->preferences->lv2_path) != 0 ) reload_plugins = 1; if( reload_plugins ) { @@ -242,9 +252,15 @@ int PreferencesThread::apply_settings() File::setenv_path("LV2_PATH", preferences->lv2_path, 1); mwindow->restart_status = -1; } + if( preferences->cache_size != mwindow->preferences->cache_size || + preferences->cache_transitions != mwindow->preferences->cache_transitions ) + reset_caches = 1; + + if( mwindow->preferences->perpetual_session && !preferences->perpetual_session ) + mwindow->remove_undo_data(); mwindow->edl->copy_session(edl, 1); - mwindow->preferences->copy_from(preferences); + mwindow->update_preferences(preferences); BC_Signals::set_catch_segv(mwindow->preferences->trap_sigsegv); BC_Signals::set_catch_intr(mwindow->preferences->trap_sigintr); @@ -257,18 +273,22 @@ int PreferencesThread::apply_settings() else { BC_Trace::disable_locks(); } + if( reset_caches ) + mwindow->reset_caches(0); mwindow->reset_android_remote(); int ffmpeg_early_probe = mwindow->preferences->get_file_probe_armed("FFMPEG_Early"); + mwindow->gui->lock_window("PreferencesThread::apply_settings 6"); mwindow->gui->ffmpeg_toggle->update(ffmpeg_early_probe); mwindow->gui->ffmpeg_toggle->set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP); + mwindow->gui->unlock_window(); mwindow->gui->mainshbtns->load(mwindow->preferences); mwindow->init_brender(); //edl->session->recording_format->dump(); //mwindow->edl->session->recording_format->dump(); - +#ifdef GLx4 if(((mwindow->edl->session->output_w % 4) || (mwindow->edl->session->output_h % 4)) && mwindow->edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL) @@ -277,7 +297,7 @@ int PreferencesThread::apply_settings() _("This project's dimensions are not multiples of 4 so\n" "it can't be rendered by OpenGL.")); } - +#endif if(redraw_meters) { @@ -327,7 +347,7 @@ int PreferencesThread::apply_settings() if(redraw_times) { mwindow->gui->lock_window("PreferencesThread::apply_settings 3"); - mwindow->gui->update(0, 0, 1, 0, 0, 1, 0); + mwindow->gui->update(0, NO_DRAW, 1, 0, 0, 1, 0); mwindow->gui->redraw_time_dependancies(); mwindow->gui->unlock_window(); } @@ -341,9 +361,16 @@ int PreferencesThread::apply_settings() //printf("PreferencesThread::apply_settings 10\n"); } - if(redraw_times || redraw_overlays) + if(redraw_indexes) { mwindow->gui->lock_window("PreferencesThread::apply_settings 4"); + mwindow->gui->draw_trackmovement(); + mwindow->gui->unlock_window(); + } + + if(redraw_times || redraw_overlays || redraw_indexes) + { + mwindow->gui->lock_window("PreferencesThread::apply_settings 5"); mwindow->gui->flush(); mwindow->gui->unlock_window(); } @@ -351,6 +378,16 @@ int PreferencesThread::apply_settings() return 0; } +const char *PreferencesThread::busy() +{ + if( mwindow->render->thread->running() ) + return _("render"); + Record *record = mwindow->gui->record; + if( record->capturing || record->recording || record->writing_file ) + return _("record"); + return 0; +} + const char* PreferencesThread::category_to_text(int category) { PlaybackConfig *playback_config = edl->session->playback_config; @@ -394,31 +431,23 @@ SET_TRACE } - - - - - - PreferencesWindow::PreferencesWindow(MWindow *mwindow, PreferencesThread *thread, int x, int y, int w, int h) : BC_Window(_(PROGRAM_NAME ": Preferences"), x,y, w,h,w,h, 1) { this->mwindow = mwindow; this->thread = thread; - dialog = 0; category = 0; + dialog = 0; + confirm_dialog = 0; } PreferencesWindow::~PreferencesWindow() { lock_window("PreferencesWindow::~PreferencesWindow"); delete category; - - - if(dialog) delete dialog; - - + delete dialog; + delete confirm_dialog; for(int i = 0; i < categories.total; i++) delete categories.values[i]; unlock_window(); @@ -489,6 +518,13 @@ void PreferencesWindow::update_rates() unlock_window(); } +void PreferencesWindow::confirm_update(const char *reason, int close) +{ + delete confirm_dialog; + confirm_dialog = new PreferencesConfirmDialog(thread, reason, close); + confirm_dialog->start(); +} + int PreferencesWindow::set_current_dialog(int number) { @@ -574,15 +610,6 @@ int PreferencesWindow::set_current_dialog(int number) } - - - - - - - - - PreferencesButton::PreferencesButton(MWindow *mwindow, PreferencesThread *thread, int x, @@ -604,19 +631,11 @@ int PreferencesButton::handle_event() } - - - - - - - PreferencesDialog::PreferencesDialog(MWindow *mwindow, PreferencesWindow *pwindow) - : BC_SubWindow(10, - 40, - pwindow->get_w() - 20, - pwindow->get_h() - BC_GenericButton::calculate_h() - 10 - 40) + : BC_SubWindow(xS(10), yS(40), + pwindow->get_w() - xS(20), + pwindow->get_h() - BC_GenericButton::calculate_h() - yS(10 + 40)) { this->pwindow = pwindow; this->mwindow = mwindow; @@ -627,14 +646,12 @@ PreferencesDialog::~PreferencesDialog() { } -// ============================== category window - - +// ============================== category window PreferencesApply::PreferencesApply(MWindow *mwindow, PreferencesThread *thread) : BC_GenericButton(thread->window->get_w() / 2 - BC_GenericButton::calculate_w(thread->window, _("Apply")) / 2, - thread->window->get_h() - BC_GenericButton::calculate_h() - 10, + thread->window->get_h() - BC_GenericButton::calculate_h() - yS(10), _("Apply")) { this->mwindow = mwindow; @@ -642,53 +659,101 @@ PreferencesApply::PreferencesApply(MWindow *mwindow, PreferencesThread *thread) } int PreferencesApply::handle_event() { - thread->apply_settings(); - mwindow->save_defaults(); + const char *reason = thread->busy(); + if( reason ) + thread->window->confirm_update(reason, 0); + else { + thread->apply_settings(); + mwindow->save_defaults(); + } return 1; } int PreferencesApply::resize_event(int w, int h) { - reposition_window(w/2 - get_w()/2, h-get_h()-10); + reposition_window(w/2 - get_w()/2, h-get_h()-yS(10)); return 1; } - - PreferencesOK::PreferencesOK(MWindow *mwindow, PreferencesThread *thread) - : BC_GenericButton(10, - thread->window->get_h() - BC_GenericButton::calculate_h() - 10, + : BC_GenericButton(xS(10), + thread->window->get_h() - BC_GenericButton::calculate_h() - yS(10), _("OK")) { this->mwindow = mwindow; this->thread = thread; } +PreferencesOK::~PreferencesOK() +{ +} + int PreferencesOK::keypress_event() { - if(get_keypress() == RETURN) - { - thread->window->set_done(0); - return 1; - } + if( get_keypress() == RETURN ) + return handle_event(); return 0; } + int PreferencesOK::handle_event() { - thread->window->set_done(0); + const char *reason = mwindow->restart() ? _("restart") : thread->busy(); + if( reason ) + thread->window->confirm_update(reason, 1); + else + thread->window->set_done(0); return 1; } int PreferencesOK::resize_event(int w, int h) { - reposition_window(10, h-get_h()-10); + reposition_window(xS(10), h-get_h()-yS(10)); return 1; } +PreferencesConfirmDialog::PreferencesConfirmDialog(PreferencesThread *thread, + const char *reason, int close) +{ + this->thread = thread; + this->close = close; + sprintf(query, _("Busy: %s in progress. Are you sure?"), reason); +} +PreferencesConfirmDialog::~PreferencesConfirmDialog() +{ + close_window(); +} +BC_Window *PreferencesConfirmDialog::new_gui() +{ + qwindow = new PreferencesConfirmWindow(this); + qwindow->create_objects(query, 0); + return qwindow; +} +void PreferencesConfirmDialog::handle_done_event(int result) +{ + if( result != 2 ) return; // not yes + if( !close ) { + thread->window->lock_window("PreferencesConfirmDialog::handle_done_event"); + thread->apply_settings(); + thread->mwindow->save_defaults(); + thread->window->unlock_window(); + } + else + thread->window->set_done(0); +} + +PreferencesConfirmWindow::PreferencesConfirmWindow(PreferencesConfirmDialog *dialog) + : QuestionWindow(dialog->thread->mwindow) +{ + this->dialog = dialog; +} +PreferencesConfirmWindow::~PreferencesConfirmWindow() +{ +} + PreferencesCancel::PreferencesCancel(MWindow *mwindow, PreferencesThread *thread) - : BC_GenericButton(thread->window->get_w() - BC_GenericButton::calculate_w(thread->window, _("Cancel")) - 10, - thread->window->get_h() - BC_GenericButton::calculate_h() - 10, - _("Cancel")) + : BC_GenericButton(thread->window->get_w() - BC_GenericButton::calculate_w(thread->window, _("Cancel")) - xS(10), + thread->window->get_h() - BC_GenericButton::calculate_h() - yS(10), + _("Cancel")) { this->mwindow = mwindow; this->thread = thread; @@ -709,27 +774,16 @@ int PreferencesCancel::handle_event() } int PreferencesCancel::resize_event(int w, int h) { - reposition_window(w-get_w()-10, h-get_h()-10); + reposition_window(w-get_w()-xS(10), h-get_h()-yS(10)); return 1; } - - - - - - - - PreferencesCategory::PreferencesCategory(MWindow *mwindow, PreferencesThread *thread, int x, int y) : BC_PopupTextBox(thread->window, &thread->window->categories, thread->category_to_text(thread->current_dialog), - x, - y, - 200, - 150) + x, y, xS(200), yS(150)) { this->mwindow = mwindow; this->thread = thread;