X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmwindow.C;h=70bacd313752d684a959fd080acabe2473d071f3;hp=bb04335f118e6b85f9bac7a95ad323fa65c5ce93;hb=486223dd047c71613c4b4fa7a84c4f57bf06c5ce;hpb=45a8ba3455cf252332c03533a7590df5267ce9aa diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index bb04335f..70bacd31 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -1469,6 +1469,27 @@ int MWindow::select_zwindow(ZWindow *zwindow) void MWindow::tile_mixers() { + int x1 = session->tile_mixers_x; + int y1 = session->tile_mixers_y; + int x2 = x1 + session->tile_mixers_w; + int y2 = y1 + session->tile_mixers_h; + tile_mixers(x1, y1, x2, y2); +} + +void MWindow::tile_mixers(int x1, int y1, int x2, int y2) +{ + if( x1 == x2 || y1 == y2 ) { +// use top left quadrent + int sw = gui->get_screen_w(1, -1); + int sh = gui->get_screen_w(1, -1); + x1 = 1; y1 = 1; + x2 = sw/2; y2 = sh/2; + } + else { + if( x1 > x2 ) { int t = x1; x1 = x2; x2 = t; } + if( y1 > y2 ) { int t = y1; y1 = y2; y2 = t; } + } + int ow = edl->session->output_w, oh = edl->session->output_h; int nz = 0; for( int i=0; iget_x(), x2 = cwindow->gui->get_x(); - int y1 = 1, y2 = gui->get_y(); - int rw = gui->get_root_w(0), rh = gui->get_root_h(0); - if( x1 < 0 ) x1 = 0; - if( y1 < 0 ) y1 = 0; - if( x2 > rw ) x2 = rw; - if( y2 > rh ) y2 = rh; - int dx = x2 - x1, dy = y2 - y1; - int zw = dx / zn; int lt = BC_DisplayInfo::get_left_border(); int top = BC_DisplayInfo::get_top_border(); int bw = lt + BC_DisplayInfo::get_right_border(); // borders int bh = top + BC_DisplayInfo::get_bottom_border(); - int zx = 0, zy = 0; // window origins int mw = xS(10+10), mh = yS(10+10); // canvas margins - int rsz = 0, n = 0, dz = 0; - int ow = edl->session->output_w, oh = edl->session->output_h; + int dx = x2 - x1, dy = y2 - y1; + int64_t sz = dx * dy, best_r = sz; + int bx = 1, by = nz; + for( int nx=1; nx<=nz; ++nx ) { + int ny = ceil((double)nz / nx); + int zw = dx / nx; + int ww = zw - bw; + int hh = (ww - mw) * oh / ow + mh; + int zh = hh + bh; + int64_t za = zw*nx * zh*ny; + int64_t r = sz - za; + if( r < 0 ) continue; + if( r >= best_r ) continue; + best_r = r; + bx = nx; by = ny; + } + for( int ny=1; ny<=nz; ++ny ) { + int nx = ceil((double)nz / ny); + int zh = dy / ny; + int hh = zh - bh; + int ww = (hh - mh) * ow / oh + mw; + int zw = ww + bw; + int64_t za = zw*nx * zh*ny; + int64_t r = sz - za; + if( r < 0 ) continue; + if( r >= best_r ) continue; + best_r = r; + bx = nx; by = ny; + } + int zw, zh, ww, hh; + if( bx < by ) { + zh = dy / by; + hh = zh - bh; + ww = (hh - mh) * ow / oh + mw; + zw = ww + bw; + } + else { + zw = dx / bx; + ww = zw - bw; + hh = (ww - mw) * oh / ow + mh; + zh = hh + bh; + } + + int zx = 0, zy = 0; // window origins + int n = 0; for( int i=0; iidx < 0 ) continue; - int ww = zw - bw, hh = (ww - mw) * oh / ow + mh, zh = hh + bh; - if( rsz < hh ) rsz = hh; int xx = zx + x1, yy = zy + y1; int mx = x2 - zw, my = y2 - zh; if( xx > mx ) xx = mx; if( yy > my ) yy = my; - xx += lt + xS(dz); yy += top + yS(dz); zwindow->reposition(xx,yy, ww,hh); if( zwindow->running() ) { ZWindowGUI *gui = (ZWindowGUI *)zwindow->get_gui(); @@ -1511,11 +1561,9 @@ void MWindow::tile_mixers() gui->BC_WindowBase::reposition_window(xx,yy, ww,hh); gui->unlock_window(); } - if( ++n >= zn ) { - n = 0; rsz += bh; - if( (zy += rsz) > (dy - rsz) ) dz += 10; - rsz = 0; - zx = 0; + if( ++n >= bx ) { + zx = 0; zy += zh; + n = 0; } else zx += zw; @@ -1524,7 +1572,8 @@ void MWindow::tile_mixers() void MWindow::set_gang_tracks(int v) { - edl->session->gang_tracks = v; + edl->local_session->gang_tracks = v; + sync_parameters(CHANGE_PARAMS); gui->update(1, 1, 0, 0, 1, 0, 0); gui->flush(); } @@ -2301,6 +2350,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); load_mode == LOADMODE_REPLACE_CONCATENATE ) && (ftype != FILE_IS_XML || edl_mode != LOADMODE_EDL_CLIP) ) { select_asset(0, 0); + edl->session->proxy_state = PROXY_INACTIVE; edl->session->proxy_scale = 1; edl->session->proxy_disabled_scale = 1; edl->session->proxy_use_scaler = 0; @@ -2318,8 +2368,8 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); goto_start(); } - if( ( edl->session->proxy_auto_scale && edl->session->proxy_scale != 1 ) && - ( load_mode != LOADMODE_REPLACE && load_mode != LOADMODE_REPLACE_CONCATENATE ) ) { + if( edl->session->proxy_state != PROXY_INACTIVE && edl->session->proxy_auto_scale && + load_mode != LOADMODE_REPLACE && load_mode != LOADMODE_REPLACE_CONCATENATE ) { ArrayList orig_idxbls; for( int i=0; i &new_idxbls) int MWindow::enable_proxy() { int ret = 0; - if( edl->session->proxy_scale == 1 && - edl->session->proxy_disabled_scale != 1 ) { + if( edl->session->proxy_state == PROXY_DISABLED ) { int new_scale = edl->session->proxy_disabled_scale; int new_use_scaler = edl->session->proxy_use_scaler; Asset *asset = new Asset; @@ -2438,6 +2487,7 @@ int MWindow::enable_proxy() beep(2000., 1.5, gain); } edl->session->proxy_disabled_scale = 1; + edl->session->proxy_state = PROXY_ACTIVE; gui->lock_window("MWindow::to_proxy"); update_project(LOADMODE_REPLACE); gui->unlock_window(); @@ -2447,15 +2497,15 @@ int MWindow::enable_proxy() int MWindow::disable_proxy() { - if( edl->session->proxy_scale != 1 && - edl->session->proxy_disabled_scale == 1 ) { - int old_scale = edl->session->proxy_scale, new_scale = 1; + if( edl->session->proxy_state == PROXY_ACTIVE ) { + int old_scale = edl->session->proxy_scale, new_scale = 0; int new_use_scaler = edl->session->proxy_use_scaler; Asset *asset = new Asset; asset->format = FILE_FFMPEG; asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0); to_proxy(asset, new_scale, new_use_scaler); asset->remove_user(); + edl->session->proxy_state = PROXY_DISABLED; edl->session->proxy_disabled_scale = old_scale; gui->lock_window("MWindow::to_proxy"); update_project(LOADMODE_REPLACE); @@ -2472,7 +2522,7 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) edl->Garbage::add_user(); save_backup(); undo_before(_("proxy"), this); - int asset_scale = new_scale == 1 ? 0 : + int asset_scale = !new_scale ? 0 : !new_use_scaler ? 1 : new_scale; ProxyRender proxy_render(this, asset, asset_scale); @@ -2480,7 +2530,7 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) // remove all session proxy assets at the at the current proxy_scale int proxy_scale = edl->session->proxy_scale; - if( proxy_scale > 1 ) { + if( edl->session->proxy_state == PROXY_ACTIVE ) { Asset *orig_asset = edl->assets->first; for( ; orig_asset; orig_asset=orig_asset->next ) { char new_path[BCTEXTLEN]; @@ -2519,7 +2569,7 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) } // convert from the proxy assets to the original assets - edl->set_proxy(1, 0, &proxy_assets, &orig_idxbls); + edl->set_proxy(0, 0, &proxy_assets, &orig_idxbls); // remove the references for( int i=0; iassets->first; for( ; orig; orig=orig->next ) { @@ -2568,7 +2618,10 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) proxy_render.add_needed(orig_nested, proxy); } } + edl->session->proxy_state = PROXY_ACTIVE; } + else + edl->session->proxy_state = PROXY_INACTIVE; int result = 0; // test for existing files @@ -2577,13 +2630,13 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) confirm_paths.remove_all_objects(); } - if( !result ) + if( !result && new_scale ) result = proxy_render.create_needed_proxies(new_scale); - if( !result ) // resize project + if( !result ) { // resize project edl->set_proxy(new_scale, new_use_scaler, &proxy_render.orig_idxbls, &proxy_render.orig_proxies); - + } undo_after(_("proxy"), LOAD_ALL); edl->Garbage::remove_user(); restart_brender(); @@ -2919,7 +2972,7 @@ void MWindow::run() run_lock->unlock(); } -void MWindow::show_vwindow() +void MWindow::show_vwindow(int raise) { int total_running = 0; session->show_vwindow = 1; @@ -2929,23 +2982,40 @@ void MWindow::show_vwindow() for(int j = 0; j < vwindows.size(); j++) { VWindow *vwindow = vwindows[j]; if( !vwindow->is_running() ) continue; + total_running++; + if( !raise && !vwindow->gui->is_hidden() ) continue; vwindow->gui->lock_window("MWindow::show_vwindow"); vwindow->gui->show_window(0); vwindow->gui->raise_window(); vwindow->gui->flush(); vwindow->gui->unlock_window(); - total_running++; } - // If no windows visible - if(!total_running) - { + if( !total_running ) get_viewer(1, DEFAULT_VWINDOW); - } gui->mainmenu->show_vwindow->set_checked(1); } + +void MWindow::hide_vwindow() +{ + session->show_vwindow = 0; + int total_running = 0; + + for(int j = 0; j < vwindows.size(); j++) { + VWindow *vwindow = vwindows[j]; + if( !vwindow->is_running() ) continue; + total_running++; + if( !raise && !vwindow->gui->is_hidden() ) continue; + vwindow->gui->lock_window("MWindow::show_vwindow"); + vwindow->gui->hide_window(0); + vwindow->gui->unlock_window(); + } + gui->mainmenu->show_vwindow->set_checked(0); +} + + void MWindow::show_awindow() { session->show_awindow = 1; @@ -2957,6 +3027,17 @@ void MWindow::show_awindow() gui->mainmenu->show_awindow->set_checked(1); } +void MWindow::hide_awindow() +{ + session->show_awindow = 0; + + awindow->gui->lock_window("MWindow::show_awindow"); + awindow->gui->hide_window(); + awindow->gui->unlock_window(); + gui->mainmenu->show_awindow->set_checked(0); +} + + char *MWindow::get_cwindow_display() { char *x11_host = screens < 2 || session->window_config == 0 ? @@ -2972,6 +3053,18 @@ void MWindow::show_cwindow() gui->mainmenu->show_cwindow->set_checked(1); } + +void MWindow::hide_cwindow() +{ + session->show_cwindow = 0; + + cwindow->gui->lock_window("MWindow::show_cwindow"); + cwindow->gui->hide_window(); + cwindow->gui->unlock_window(); + gui->mainmenu->show_cwindow->set_checked(0); +} + + void MWindow::show_gwindow() { session->show_gwindow = 1; @@ -2984,6 +3077,7 @@ void MWindow::show_gwindow() gui->mainmenu->show_gwindow->set_checked(1); } + void MWindow::hide_gwindow() { session->show_gwindow = 0; @@ -2991,6 +3085,7 @@ void MWindow::hide_gwindow() gwindow->gui->lock_window("MWindow::show_gwindow"); gwindow->gui->hide_window(); gwindow->gui->unlock_window(); + gui->mainmenu->show_gwindow->set_checked(0); } void MWindow::show_lwindow() @@ -3004,6 +3099,17 @@ void MWindow::show_lwindow() gui->mainmenu->show_lwindow->set_checked(1); } +void MWindow::hide_lwindow() +{ + session->show_lwindow = 0; + + lwindow->gui->lock_window("MWindow::show_lwindow"); + lwindow->gui->hide_window(); + lwindow->gui->unlock_window(); + gui->mainmenu->show_lwindow->set_checked(0); +} + + void MWindow::restore_windows() { gui->unlock_window(); @@ -3016,8 +3122,8 @@ void MWindow::restore_windows() vwindow->gui->unlock_window(); } } - else - show_vwindow(); + else + show_vwindow(0); if( !session->show_awindow && !awindow->gui->is_hidden() ) { awindow->gui->lock_window("MWindow::restore_windows"); @@ -3051,6 +3157,7 @@ void MWindow::restore_windows() else if( session->show_lwindow && lwindow->gui->is_hidden() ) show_lwindow(); + tile_mixers(); gui->lock_window("MWindow::restore_windows"); gui->focus(); } @@ -3438,8 +3545,9 @@ int MWindow::get_hash_color(Edit *edit) (Indexable*)edit->asset : (Indexable*)edit->nested_edl; if( !idxbl ) return 0; char path[BCTEXTLEN]; - if( !edit->asset || edit->track->data_type != TRACK_VIDEO || - edl->session->proxy_scale == 1 || +// map proxy colors to unproxy colors + if( edl->session->proxy_state != PROXY_ACTIVE || + !edit->asset || edit->track->data_type != TRACK_VIDEO || ProxyRender::from_proxy_path(path, (Asset*)idxbl, edl->session->proxy_scale) ) strcpy(path, idxbl->path); char *cp = strrchr(path, '/'); @@ -4440,11 +4548,14 @@ 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; + double ar; + if(!width || !height) return 1; if( width == 720 && (height == 480 || height == 576) ) { w = 4; h = 3; return 0; // for NTSC and PAL } - double ar = (double)width / height; + + 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; } @@ -4452,6 +4563,8 @@ int MWindow::create_aspect_ratio(float &w, float &h, int width, int height) 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; } + if( EQUIV(ar, 2.37037) ) { w = 64; h = 27; return 0; } + int ww = width, hh = height; // numerator, denominator must be under mx int mx = 255, n = gcd(ww, hh); @@ -4995,12 +5108,26 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra session->output_w = width; session->output_h = height; session->frame_rate = framerate; + session->interlace_mode = asset->interlace_mode; // not, asset->actual_width/actual_height asset->width = session->output_w; asset->height = session->output_h; asset->frame_rate = session->frame_rate; + create_aspect_ratio(session->aspect_w, session->aspect_h, session->output_w, session->output_h); + float ar = asset->aspect_ratio; + if (ar) { + //printf ("Aspect ratio from asset: %f \n", ar); + if( EQUIV(ar, 1.3333) ) { session->aspect_w = 4; session->aspect_h = 3; } + if( EQUIV(ar, 1.7777) ) { session->aspect_w = 16; session->aspect_h = 9; } + if( EQUIV(ar, 2.1111) ) { session->aspect_w = 19; session->aspect_h = 9; } + if( EQUIV(ar, 2.2222) ) { session->aspect_w = 20; session->aspect_h = 9; } + if( EQUIV(ar, 2.3333) ) { session->aspect_w = 21; session->aspect_h = 9; } + if( EQUIV(ar, 2.370370) ) { session->aspect_w = 64; session->aspect_h = 27; } + } + + Track *track = edl->tracks->first; for( Track *next_track=0; track; track=next_track ) { next_track = track->next;