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:
@@ -57,6 +57,10 @@
|
|||||||
#define MIN_WIDTH 250
|
#define MIN_WIDTH 250
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
MainWin::sNoVideoWidth = MIN_WIDTH;
|
||||||
|
|
||||||
|
|
||||||
// XXX TODO: why is lround not defined?
|
// XXX TODO: why is lround not defined?
|
||||||
#define lround(a) ((int)(0.99999 + (a)))
|
#define lround(a) ((int)(0.99999 + (a)))
|
||||||
|
|
||||||
@@ -127,18 +131,26 @@ MainWin::MainWin(bool isFirstWindow)
|
|||||||
fMouseDownTracking(false),
|
fMouseDownTracking(false),
|
||||||
fGlobalSettingsListener(this)
|
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;
|
static int pos = 0;
|
||||||
MoveBy(pos * 25, pos * 25);
|
MoveBy(pos * 25, pos * 25);
|
||||||
pos = (pos + 1) % 15;
|
pos = (pos + 1) % 15;
|
||||||
|
|
||||||
if (isFirstWindow) {
|
BRect frame = Settings::Default()->CurrentSettings()
|
||||||
BRect frame = Settings::Default()
|
.audioPlayerWindowFrame;
|
||||||
->CurrentSettings().audioPlayerWindowFrame;
|
if (frame.IsValid()) {
|
||||||
if (frame.IsValid()) {
|
if (isFirstWindow) {
|
||||||
MoveTo(frame.LeftTop());
|
MoveTo(frame.LeftTop());
|
||||||
ResizeTo(frame.Width(), frame.Height());
|
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();
|
BRect rect = Bounds();
|
||||||
|
|
||||||
@@ -260,6 +272,9 @@ MainWin::FrameResized(float newWidth, float newHeight)
|
|||||||
// printf("FrameResized enter: newWidth %.0f, newHeight %.0f\n",
|
// printf("FrameResized enter: newWidth %.0f, newHeight %.0f\n",
|
||||||
// newWidth, newHeight);
|
// newWidth, newHeight);
|
||||||
|
|
||||||
|
if (!fHasVideo)
|
||||||
|
sNoVideoWidth = fNoVideoWidth = (int)newWidth;
|
||||||
|
|
||||||
int maxVideoWidth = int(newWidth) + 1;
|
int maxVideoWidth = int(newWidth) + 1;
|
||||||
int maxVideoHeight = int(newHeight) + 1
|
int maxVideoHeight = int(newHeight) + 1
|
||||||
- (noMenu ? 0 : fMenuBarHeight)
|
- (noMenu ? 0 : fMenuBarHeight)
|
||||||
@@ -719,7 +734,7 @@ MainWin::QuitRequested()
|
|||||||
BAutolock controllerLocker(fController);
|
BAutolock controllerLocker(fController);
|
||||||
playlistArchive.AddInt64("position", fController->TimePosition());
|
playlistArchive.AddInt64("position", fController->TimePosition());
|
||||||
controllerLocker.Unlock();
|
controllerLocker.Unlock();
|
||||||
|
|
||||||
BAutolock playlistLocker(fPlaylist);
|
BAutolock playlistLocker(fPlaylist);
|
||||||
if (fPlaylist->Archive(&playlistArchive) != B_OK
|
if (fPlaylist->Archive(&playlistArchive) != B_OK
|
||||||
|| message.AddMessage("playlist", &playlistArchive) != B_OK) {
|
|| message.AddMessage("playlist", &playlistArchive) != B_OK) {
|
||||||
@@ -1210,7 +1225,7 @@ MainWin::_CurrentVideoSizeInPercent() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainWin::_ResizeWindow(int percent, bool keepWidth, bool stayOnScreen)
|
MainWin::_ResizeWindow(int percent, bool useNoVideoWidth, bool stayOnScreen)
|
||||||
{
|
{
|
||||||
// Get required window size
|
// Get required window size
|
||||||
int videoWidth;
|
int videoWidth;
|
||||||
@@ -1226,8 +1241,8 @@ MainWin::_ResizeWindow(int percent, bool keepWidth, bool stayOnScreen)
|
|||||||
_GetMinimumWindowSize(width, height);
|
_GetMinimumWindowSize(width, height);
|
||||||
|
|
||||||
width = max_c(width, videoWidth) - 1;
|
width = max_c(width, videoWidth) - 1;
|
||||||
if (keepWidth)
|
if (useNoVideoWidth)
|
||||||
width = max_c(width, (int)Frame().Width());
|
width = max_c(width, fNoVideoWidth);
|
||||||
height = height + videoHeight - 1;
|
height = height + videoHeight - 1;
|
||||||
|
|
||||||
if (stayOnScreen) {
|
if (stayOnScreen) {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ private:
|
|||||||
int& videoHeight) const;
|
int& videoHeight) const;
|
||||||
int _CurrentVideoSizeInPercent() const;
|
int _CurrentVideoSizeInPercent() const;
|
||||||
void _ResizeWindow(int percent,
|
void _ResizeWindow(int percent,
|
||||||
bool keepWidth = false,
|
bool useNoVideoWidth = false,
|
||||||
bool stayOnScreen = false);
|
bool stayOnScreen = false);
|
||||||
void _ResizeVideoView(int x, int y, int width,
|
void _ResizeVideoView(int x, int y, int width,
|
||||||
int height);
|
int height);
|
||||||
@@ -142,9 +142,9 @@ private:
|
|||||||
PlaylistObserver* fPlaylistObserver;
|
PlaylistObserver* fPlaylistObserver;
|
||||||
Controller* fController;
|
Controller* fController;
|
||||||
ControllerObserver* fControllerObserver;
|
ControllerObserver* fControllerObserver;
|
||||||
volatile bool fIsFullscreen;
|
volatile bool fIsFullscreen;
|
||||||
volatile bool fAlwaysOnTop;
|
volatile bool fAlwaysOnTop;
|
||||||
volatile bool fNoInterface;
|
volatile bool fNoInterface;
|
||||||
int fSourceWidth;
|
int fSourceWidth;
|
||||||
int fSourceHeight;
|
int fSourceHeight;
|
||||||
int fWidthAspect;
|
int fWidthAspect;
|
||||||
@@ -153,6 +153,7 @@ private:
|
|||||||
int fMenuBarHeight;
|
int fMenuBarHeight;
|
||||||
int fControlsHeight;
|
int fControlsHeight;
|
||||||
int fControlsWidth;
|
int fControlsWidth;
|
||||||
|
int fNoVideoWidth;
|
||||||
BRect fSavedFrame;
|
BRect fSavedFrame;
|
||||||
bool fMouseDownTracking;
|
bool fMouseDownTracking;
|
||||||
BPoint fMouseDownMousePos;
|
BPoint fMouseDownMousePos;
|
||||||
@@ -161,6 +162,8 @@ private:
|
|||||||
ListenerAdapter fGlobalSettingsListener;
|
ListenerAdapter fGlobalSettingsListener;
|
||||||
bool fCloseWhenDonePlayingMovie;
|
bool fCloseWhenDonePlayingMovie;
|
||||||
bool fCloseWhenDonePlayingSound;
|
bool fCloseWhenDonePlayingSound;
|
||||||
|
|
||||||
|
static int sNoVideoWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __MAIN_WIN_H
|
#endif // __MAIN_WIN_H
|
||||||
|
|||||||
Reference in New Issue
Block a user