From 62bf33df966c535c1e0e022d4ccc50e7b641693c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 7 Jul 2008 08:33:03 +0000 Subject: [PATCH] Don't reset the window size when playing a new file if it isn't necessary. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26286 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/MainWin.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index 28e2017a50..9766a6e18c 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -122,8 +122,8 @@ MainWin::MainWin() , fNoMenu(false) , fNoBorder(false) , fNoControls(false) - , fSourceWidth(0) - , fSourceHeight(0) + , fSourceWidth(-1) + , fSourceHeight(-1) , fWidthScale(1.0) , fHeightScale(1.0) , fMouseDownTracking(false) @@ -849,10 +849,13 @@ MainWin::_SetupWindow() fVideoMenu->SetEnabled(fHasVideo); fAudioMenu->SetEnabled(fHasAudio); // fDebugMenu->SetEnabled(fHasVideo); + int previousSourceWidth = fSourceWidth; + int previousSourceHeight = fSourceHeight; if (fHasVideo) { fController->GetSize(&fSourceWidth, &fSourceHeight); fWidthScale = 1.0; fHeightScale = 1.0; + // TODO: implement aspect ratio } else { fSourceWidth = 0; fSourceHeight = 0; @@ -861,9 +864,11 @@ MainWin::_SetupWindow() } _UpdateControlsEnabledStatus(); - // TODO: Don't if the video size did not change! Also don't - // exit full screen mode. - _ResizeWindow(100); + // adopt the size and window layout if necessary + if (!fIsFullscreen && (previousSourceWidth != fSourceWidth + || previousSourceHeight != fSourceHeight)) { + _ResizeWindow(100); + } fVideoView->MakeFocus(); } @@ -1024,12 +1029,9 @@ MainWin::_SetWindowSizeLimits() void MainWin::_ResizeWindow(int percent) { - int video_width; - int video_height; - // Get required window size - video_width = lround(fSourceWidth * fWidthScale); - video_height = lround(fSourceHeight * fHeightScale); + int video_width = lround(fSourceWidth * fWidthScale); + int video_height = lround(fSourceHeight * fHeightScale); video_width = (video_width * percent) / 100; video_height = (video_height * percent) / 100;