X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.0%2Fcinelerra%2Fmwindow.C;h=a53bd4c8c898c1bf18e8c9b17d67f5edd239e540;hb=f9d0d999e813ae19965e07ae2f7da690b4e6fe45;hp=7ad079b382fba0341bb98dd34ed51c8aad5fca49;hpb=2d99bb8ce591f05a31464b517d85dc2bc35b2abe;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.0/cinelerra/mwindow.C b/cinelerra-5.0/cinelerra/mwindow.C index 7ad079b3..a53bd4c8 100644 --- a/cinelerra-5.0/cinelerra/mwindow.C +++ b/cinelerra-5.0/cinelerra/mwindow.C @@ -27,13 +27,14 @@ #include "bcdisplayinfo.h" #include "bcsignals.h" #include "bctimer.h" +#include "bdcreate.h" #include "brender.h" #include "cache.h" #include "channel.h" #include "channeldb.h" #include "channelinfo.h" #include "clip.h" -#include "colormodels.h" +#include "bccmodels.h" #include "commercials.h" #include "cplayback.h" #include "ctimebar.h" @@ -41,6 +42,7 @@ #include "cwindow.h" #include "bchash.h" #include "devicedvbinput.inc" +#include "dvdcreate.h" #include "editpanel.h" #include "edl.h" #include "edlsession.h" @@ -109,6 +111,7 @@ #include "vwindowgui.h" #include "vwindow.h" #include "wavecache.h" +#include "wwindow.h" #include "zoombar.h" #include @@ -191,6 +194,7 @@ MWindow::MWindow() plugin_guis = 0; dead_plugins = 0; keyframe_threads = 0; + create_bd = 0; create_dvd = 0; batch_render = 0; render = 0; @@ -200,6 +204,7 @@ MWindow::MWindow() awindow = 0; gwindow = 0; twindow = 0; + wwindow = 0; lwindow = 0; sighandler = 0; reload_status = 0; @@ -220,6 +225,7 @@ MWindow::~MWindow() brender_lock->lock("MWindow::quit"); delete brender; brender = 0; brender_lock->unlock(); + delete create_bd; create_bd = 0; delete create_dvd; create_dvd = 0; delete batch_render; batch_render = 0; commit_commercial(); @@ -235,7 +241,6 @@ MWindow::~MWindow() hide_keyframe_guis(); clean_indexes(); save_defaults(); - // Give up and go to a movie // cant run valgrind if this is used // if( !reload_status ) exit(0); @@ -250,12 +255,14 @@ MWindow::~MWindow() if( lwindow && lwindow->gui ) lwindow->gui->close(0); if( gwindow && gwindow->gui ) gwindow->gui->close(0); if( twindow && twindow->is_running() ) twindow->close_window(); + if( wwindow && wwindow->is_running() ) wwindow->close_window(); vwindows.remove_all_objects(); gui->close(0); if( awindow ) awindow->join(); if( cwindow ) cwindow->join(); if( lwindow ) lwindow->join(); if( twindow ) twindow->join(); + if( wwindow ) wwindow->join(); if( gwindow ) gwindow->join(); join(); #else @@ -268,6 +275,7 @@ MWindow::~MWindow() close_gui(lwindow); close_gui(gwindow); close_gui(twindow); + close_gui(wwindow); vwindows.remove_all_objects(); gui->close(0); join(); @@ -284,6 +292,7 @@ MWindow::~MWindow() delete awindow; awindow = 0; delete lwindow; lwindow = 0; delete twindow; twindow = 0; + delete wwindow; wwindow = 0; delete gwindow; gwindow = 0; // must be last or nouveau chokes delete cwindow; cwindow = 0; @@ -330,8 +339,7 @@ void MWindow::quit(int unlock) interrupt_indexes(); clean_indexes(); save_defaults(); -// This is the last thread to exit - playback_3d->quit(); + gui->set_done(0); if(unlock) gui->lock_window("MWindow::quit"); } @@ -463,8 +471,8 @@ int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences) if( !load_plugin_index(mwindow, index_path) ) return 1; FILE *fp = fopen(index_path,"w"); if( !fp ) { - fprintf(stderr," MWindow::init_plugins: " - "can't create plugin index: %s\n", index_path); + fprintf(stderr,_("MWindow::init_plugins: " + "can't create plugin index: %s\n"), index_path); return 1; } fprintf(fp, "%d\n", PLUGIN_FILE_VERSION); @@ -658,10 +666,19 @@ void MWindow::init_gwindow() void MWindow::init_tipwindow() { - twindow = new TipWindow(this); + if( !twindow ) + twindow = new TipWindow(this); twindow->start(); } +void MWindow::show_warning(int *do_warning, const char *text) +{ + if( do_warning && !*do_warning ) return; + if( !wwindow ) + wwindow = new WWindow(this); + wwindow->show_warning(do_warning, text); +} + void MWindow::init_theme() { Timer timer; @@ -671,27 +688,44 @@ void MWindow::init_theme() if(!strcasecmp(preferences->theme, "Blond")) strcpy(preferences->theme, DEFAULT_THEME); - for(int i = 0; i < plugindb->total; i++) - { - if(plugindb->values[i]->theme && - !strcasecmp(preferences->theme, plugindb->values[i]->title)) - { - PluginServer plugin = *plugindb->values[i]; - plugin.open_plugin(0, preferences, 0, 0); - theme = plugin.new_theme(); - theme->mwindow = this; - strcpy(theme->path, plugin.path); - plugin.close_plugin(); - break; + PluginServer *theme_plugin = 0; + for(int i = 0; i < plugindb->total && !theme_plugin; i++) { + if( plugindb->values[i]->theme && + !strcasecmp(preferences->theme, plugindb->values[i]->title) ) + theme_plugin = plugindb->values[i]; + } + + if( !theme_plugin ) + fprintf(stderr, _("MWindow::init_theme: prefered theme %s not found.\n"), + preferences->theme); + + if( !theme_plugin && strcasecmp(preferences->theme, DEFAULT_THEME) ) { + fprintf(stderr, _("MWindow::init_theme: trying default theme %s\n"), + DEFAULT_THEME); + for(int i = 0; i < plugindb->total && !theme_plugin; i++) { + if( plugindb->values[i]->theme && + !strcasecmp(DEFAULT_THEME, plugindb->values[i]->title) ) + theme_plugin = plugindb->values[i]; } } - if(!theme) - { - fprintf(stderr, _("MWindow::init_theme: theme %s not found.\n"), preferences->theme); + if(!theme_plugin) { + fprintf(stderr, _("MWindow::init_theme: theme_plugin not found.\n")); exit(1); } + PluginServer plugin = *theme_plugin; + if( plugin.open_plugin(0, preferences, 0, 0) ) { + fprintf(stderr, _("MWindow::init_theme: unable to load theme %s\n"), + theme_plugin->title); + exit(1); + } + + theme = plugin.new_theme(); + theme->mwindow = this; + strcpy(theme->path, plugin.path); + plugin.close_plugin(); + // Load default images & settings theme->Theme::initialize(); // Load user images & settings @@ -770,25 +804,25 @@ void MWindow::init_channeldb() void MWindow::init_menus() { char string[BCTEXTLEN]; - cmodel_to_text(string, BC_RGB888); + BC_CModels::to_text(string, BC_RGB888); colormodels.append(new ColormodelItem(string, BC_RGB888)); - cmodel_to_text(string, BC_RGBA8888); + BC_CModels::to_text(string, BC_RGBA8888); colormodels.append(new ColormodelItem(string, BC_RGBA8888)); -// cmodel_to_text(string, BC_RGB161616); +// BC_CModels::to_text(string, BC_RGB161616); // colormodels.append(new ColormodelItem(string, BC_RGB161616)); -// cmodel_to_text(string, BC_RGBA16161616); +// BC_CModels::to_text(string, BC_RGBA16161616); // colormodels.append(new ColormodelItem(string, BC_RGBA16161616)); - cmodel_to_text(string, BC_RGB_FLOAT); + BC_CModels::to_text(string, BC_RGB_FLOAT); colormodels.append(new ColormodelItem(string, BC_RGB_FLOAT)); - cmodel_to_text(string, BC_RGBA_FLOAT); + BC_CModels::to_text(string, BC_RGBA_FLOAT); colormodels.append(new ColormodelItem(string, BC_RGBA_FLOAT)); - cmodel_to_text(string, BC_YUV888); + BC_CModels::to_text(string, BC_YUV888); colormodels.append(new ColormodelItem(string, BC_YUV888)); - cmodel_to_text(string, BC_YUVA8888); + BC_CModels::to_text(string, BC_YUVA8888); colormodels.append(new ColormodelItem(string, BC_YUVA8888)); -// cmodel_to_text(string, BC_YUV161616); +// BC_CModels::to_text(string, BC_YUV161616); // colormodels.append(new ColormodelItem(string, BC_YUV161616)); -// cmodel_to_text(string, BC_YUVA16161616); +// BC_CModels::to_text(string, BC_YUVA16161616); // colormodels.append(new ColormodelItem(string, BC_YUVA16161616)); } @@ -817,6 +851,7 @@ ENABLE_BUFFER void MWindow::init_render() { render = new Render(this); + create_bd = new CreateBD_Thread(this); create_dvd = new CreateDVD_Thread(this); batch_render = new BatchRenderThread(this); } @@ -930,7 +965,7 @@ int MWindow::put_commercial() for(Track *track=tracks->first; track && !errmsg; track=track->next) { if( track->data_type != TRACK_VIDEO ) continue; if( !track->record ) continue; - if( count > 0 ) { errmsg = "multiple video tracks"; break; } + if( count > 0 ) { errmsg = _("multiple video tracks"); break; } ++count; int64_t units_start = track->to_units(start,0); int64_t units_end = track->to_units(end,0); @@ -942,9 +977,9 @@ int MWindow::put_commercial() edit2 = edits->last; units_end = edits->length(); } - if(edit1 != edit2) { errmsg = "crosses edits"; break; } + if(edit1 != edit2) { errmsg = _("crosses edits"); break; } Indexable *indexable = edit1->get_source(); - if( !indexable->is_asset ) { errmsg = "not asset"; break; } + if( !indexable->is_asset ) { errmsg = _("not asset"); break; } } //run it for(Track *track=tracks->first; track && !errmsg; track=track->next) { @@ -963,17 +998,17 @@ int MWindow::put_commercial() Indexable *indexable = edit1->get_source(); Asset *asset = (Asset *)indexable; File *file = video_cache->check_out(asset, edl); - if( !file ) { errmsg = "no file"; break; } + if( !file ) { errmsg = _("no file"); break; } int64_t edit_length = units_end - units_start; int64_t edit_start = units_start - edit1->startproject + edit1->startsource; result = commercials->put_clip(file, edit1->channel, track->from_units(edit_start), track->from_units(edit_length)); video_cache->check_in(asset); - if( result ) { errmsg = "db failed"; break; } + if( result ) { errmsg = _("db failed"); break; } } if( errmsg ) { char string[BCTEXTLEN]; - sprintf(string, "put_commercial: %s", errmsg); + sprintf(string, _("put_commercial: %s"), errmsg); MainError::show_error(string); undo_commercial(); result = 1; @@ -1043,7 +1078,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); new_edl->copy_session(edl); new_file->set_program(edl->session->program_no); - sprintf(string, "Loading %s", new_asset->path); + sprintf(string, _("Loading %s"), new_asset->path); gui->show_message(string); if(debug) printf("MWindow::load_filenames %d\n", __LINE__); @@ -1061,7 +1096,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); (new_asset->height % 2))) { char string[BCTEXTLEN]; - sprintf(string, "%s's resolution is %dx%d.\nImages with odd dimensions may not decode properly.", + sprintf(string, _("%s's resolution is %dx%d.\nImages with odd dimensions may not decode properly."), new_asset->path, new_asset->width, new_asset->height); @@ -1072,8 +1107,8 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); edl->session->program_no != new_asset->program) { char string[BCTEXTLEN]; - sprintf(string, "%s's index was built for program number %d\n" - "Playback preference is %d.\n Using program %d.", + sprintf(string, _("%s's index was built for program number %d\n" + "Playback preference is %d.\n Using program %d."), new_asset->path, new_asset->program, edl->session->program_no, new_asset->program); MainError::show_error(string); @@ -1407,6 +1442,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); select_asset(0, 0); edl->local_session->preview_start = 0; edl->local_session->preview_end = edl->tracks->total_playable_length(); + edl->local_session->loop_playback = 0; edl->local_session->set_selectionstart(0); edl->local_session->set_selectionend(0); fit_selection(); @@ -1489,9 +1525,9 @@ void MWindow::test_plugins(EDL *new_edl, char *path) if (!plugin_found) { sprintf(string, - "The effect '%s' in file '%s' is not part of your installation of Cinelerra.\n" - "The project won't be rendered as it was meant and Cinelerra might crash.\n", - plugin->title, + _("The %s '%s' in file '%s' is not part of your installation of Cinelerra.\n" + "The project won't be rendered as it was meant and Cinelerra might crash.\n"), + "effect", plugin->title, path); MainError::show_error(string); } @@ -1522,9 +1558,9 @@ void MWindow::test_plugins(EDL *new_edl, char *path) if (!transition_found) { sprintf(string, - "The transition '%s' in file '%s' is not part of your installation of Cinelerra.\n" - "The project won't be rendered as it was meant and Cinelerra might crash.\n", - edit->transition->title, + _("The %s '%s' in file '%s' is not part of your installation of Cinelerra.\n" + "The project won't be rendered as it was meant and Cinelerra might crash.\n"), + "transition", edit->transition->title, path); MainError::show_error(string); } @@ -1556,11 +1592,11 @@ void MWindow::init_shm() fd = 0; if(result < 0x7fffffff) { char string[BCTEXTLEN]; - sprintf(string, "MWindow::init_shm: /proc/sys/kernel/shmmax is 0x" _LX ".\n" + sprintf(string, _("MWindow::init_shm: /proc/sys/kernel/shmmax is 0x" _LX ".\n" "you probably need to be root, or:\n" "as root, run: echo 0x7fffffff > /proc/sys/kernel/shmmax\n" "before trying to start cinelerra.\n" - "It should be at least 0x7fffffff for Cinelerra.\n", result); + "It should be at least 0x7fffffff for Cinelerra.\n"), result); MainError::show_error(string); } } @@ -1593,7 +1629,6 @@ void MWindow::create_objects(int want_gui, if(debug) PRINT_TRACE // show_splash(); - init_error(); if(debug) PRINT_TRACE init_defaults(defaults, config_path); init_preferences(); @@ -1603,6 +1638,7 @@ void MWindow::create_objects(int want_gui, if(debug) PRINT_TRACE init_theme(); if(debug) PRINT_TRACE + init_error(); char string[BCTEXTLEN]; strcpy(string, preferences->plugin_dir); @@ -1790,7 +1826,7 @@ ENABLE_BUFFER //PRINT_TRACE gwindow->start(); //PRINT_TRACE - Thread::start(); +// Thread::start(); //PRINT_TRACE playback_3d->start(); //PRINT_TRACE @@ -1959,6 +1995,7 @@ int MWindow::set_editing_mode(int new_editing_mode, int lock_mwindow, int lock_c void MWindow::sync_parameters(int change_type) { + if( in_destructor ) return; // Sync engines which are playing back if(cwindow->playback_engine->is_playing_back) @@ -2646,8 +2683,16 @@ static inline int gcd(int m, int n) int MWindow::create_aspect_ratio(float &w, float &h, int width, int height) { + w = 1; h = 1; if(!width || !height) return 1; double ar = (double)width / height; +// square-ish pixels + if( EQUIV(ar, 1.0000) ) return 0; + if( EQUIV(ar, 1.3333) ) { w = 4; h = 3; return 0; } + if( EQUIV(ar, 1.7777) ) { w = 16; h = 9; return 0; } + if( EQUIV(ar, 2.1111) ) { w = 19; h = 9; return 0; } + if( EQUIV(ar, 2.2222) ) { w = 20; h = 9; return 0; } + if( EQUIV(ar, 2.3333) ) { w = 21; h = 9; return 0; } int ww = width, hh = height; // numerator, denominator must be under mx int mx = 255, n = gcd(ww, hh); @@ -2763,6 +2808,13 @@ void MWindow::remove_assets_from_project(int push_undo) } } + for(int i = 0; i < session->drag_assets->size(); i++) + { + Indexable *indexable = session->drag_assets->values[i]; + remove_indexfile(indexable); + } + +//printf("MWindow::rebuild_indices 1 %s\n", indexable->path); if(push_undo) undo->update_undo_before(); edl->remove_from_project(session->drag_assets); edl->remove_from_project(session->drag_clips);