Window size handling is now a bit more robust (all this affects audio only

and empty windows only):
* New windows use the width from the window that was last resized by the user.
* The first window uses the stored window position and size.
* When switching from video content to audio content, the last window width
  from previous audio-only content is restored.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34078 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-11-16 18:40:45 +00:00
parent 88b38f2901
commit 9a7463857a
2 changed files with 30 additions and 12 deletions
+23 -8
View File
@@ -57,6 +57,10 @@
#define MIN_WIDTH 250
int
MainWin::sNoVideoWidth = MIN_WIDTH;
// XXX TODO: why is lround not defined?
#define lround(a) ((int)(0.99999 + (a)))
@@ -127,18 +131,26 @@ MainWin::MainWin(bool isFirstWindow)
fMouseDownTracking(false),
fGlobalSettingsListener(this)
{
// Handle window position and size depending on whether this is the
// first window or not. Use the window size from the window that was
// last resized by the user.
static int pos = 0;
MoveBy(pos * 25, pos * 25);
pos = (pos + 1) % 15;
if (isFirstWindow) {
BRect frame = Settings::Default()
->CurrentSettings().audioPlayerWindowFrame;
if (frame.IsValid()) {
BRect frame = Settings::Default()->CurrentSettings()
.audioPlayerWindowFrame;
if (frame.IsValid()) {
if (isFirstWindow) {
MoveTo(frame.LeftTop());
ResizeTo(frame.Width(), frame.Height());
}
if (sNoVideoWidth == MIN_WIDTH)
sNoVideoWidth = frame.IntegerWidth();
} else if (sNoVideoWidth > MIN_WIDTH) {
ResizeTo(sNoVideoWidth, Bounds().Height());
}
fNoVideoWidth = sNoVideoWidth;
BRect rect = Bounds();
@@ -260,6 +272,9 @@ MainWin::FrameResized(float newWidth, float newHeight)
// printf("FrameResized enter: newWidth %.0f, newHeight %.0f\n",
// newWidth, newHeight);
if (!fHasVideo)
sNoVideoWidth = fNoVideoWidth = (int)newWidth;
int maxVideoWidth = int(newWidth) + 1;
int maxVideoHeight = int(newHeight) + 1
- (noMenu ? 0 : fMenuBarHeight)
@@ -719,7 +734,7 @@ MainWin::QuitRequested()
BAutolock controllerLocker(fController);
playlistArchive.AddInt64("position", fController->TimePosition());
controllerLocker.Unlock();
BAutolock playlistLocker(fPlaylist);
if (fPlaylist->Archive(&playlistArchive) != B_OK
|| message.AddMessage("playlist", &playlistArchive) != B_OK) {
@@ -1210,7 +1225,7 @@ MainWin::_CurrentVideoSizeInPercent() const
void
MainWin::_ResizeWindow(int percent, bool keepWidth, bool stayOnScreen)
MainWin::_ResizeWindow(int percent, bool useNoVideoWidth, bool stayOnScreen)
{
// Get required window size
int videoWidth;
@@ -1226,8 +1241,8 @@ MainWin::_ResizeWindow(int percent, bool keepWidth, bool stayOnScreen)
_GetMinimumWindowSize(width, height);
width = max_c(width, videoWidth) - 1;
if (keepWidth)
width = max_c(width, (int)Frame().Width());
if (useNoVideoWidth)
width = max_c(width, fNoVideoWidth);
height = height + videoHeight - 1;
if (stayOnScreen) {
+7 -4
View File
@@ -86,7 +86,7 @@ private:
int& videoHeight) const;
int _CurrentVideoSizeInPercent() const;
void _ResizeWindow(int percent,
bool keepWidth = false,
bool useNoVideoWidth = false,
bool stayOnScreen = false);
void _ResizeVideoView(int x, int y, int width,
int height);
@@ -142,9 +142,9 @@ private:
PlaylistObserver* fPlaylistObserver;
Controller* fController;
ControllerObserver* fControllerObserver;
volatile bool fIsFullscreen;
volatile bool fAlwaysOnTop;
volatile bool fNoInterface;
volatile bool fIsFullscreen;
volatile bool fAlwaysOnTop;
volatile bool fNoInterface;
int fSourceWidth;
int fSourceHeight;
int fWidthAspect;
@@ -153,6 +153,7 @@ private:
int fMenuBarHeight;
int fControlsHeight;
int fControlsWidth;
int fNoVideoWidth;
BRect fSavedFrame;
bool fMouseDownTracking;
BPoint fMouseDownMousePos;
@@ -161,6 +162,8 @@ private:
ListenerAdapter fGlobalSettingsListener;
bool fCloseWhenDonePlayingMovie;
bool fCloseWhenDonePlayingSound;
static int sNoVideoWidth;
};
#endif // __MAIN_WIN_H