[haiku-commits] r34078 - haiku/trunk/src/apps/mediaplayer

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 16 Nov 2009 19:40:46 +0100 (CET)

Author: stippi
Date: 2009-11-16 19:40:45 +0100 (Mon, 16 Nov 2009)
New Revision: 34078
Changeset: http://dev.haiku-os.org/changeset/34078/haiku

Modified:
   haiku/trunk/src/apps/mediaplayer/MainWin.cpp
   haiku/trunk/src/apps/mediaplayer/MainWin.h
Log:
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.


Modified: haiku/trunk/src/apps/mediaplayer/MainWin.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/MainWin.cpp        2009-11-16 18:13:27 UTC 
(rev 34077)
+++ haiku/trunk/src/apps/mediaplayer/MainWin.cpp        2009-11-16 18:40:45 UTC 
(rev 34078)
@@ -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 @@
        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 @@
 //     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 @@
                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 @@
 
 
 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 @@
        _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) {

Modified: haiku/trunk/src/apps/mediaplayer/MainWin.h
===================================================================
--- haiku/trunk/src/apps/mediaplayer/MainWin.h  2009-11-16 18:13:27 UTC (rev 
34077)
+++ haiku/trunk/src/apps/mediaplayer/MainWin.h  2009-11-16 18:40:45 UTC (rev 
34078)
@@ -86,7 +86,7 @@
                                                                        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 @@
                        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 @@
                        int                                     fMenuBarHeight;
                        int                                     fControlsHeight;
                        int                                     fControlsWidth;
+                       int                                     fNoVideoWidth;
                        BRect                           fSavedFrame;
                        bool                            fMouseDownTracking;
                        BPoint                          fMouseDownMousePos;
@@ -161,6 +162,8 @@
                        ListenerAdapter         fGlobalSettingsListener;
                        bool                            
fCloseWhenDonePlayingMovie;
                        bool                            
fCloseWhenDonePlayingSound;
+
+       static  int                                     sNoVideoWidth;
 };
 
 #endif // __MAIN_WIN_H


Other related posts: