Don't apply gravity before requested sash position was set in wxSplitterWindow.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 30 Oct 2011 19:48:40 +0000 (19:48 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 30 Oct 2011 19:48:40 +0000 (19:48 +0000)
Gravity should take effect only after the originally requested sash position
is set as otherwise it's not really taken into account.

Closes #13508.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69598 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/splitter.cpp

index 1b8025182f3fa9c051ee6a719b09a7f25b5a83d0..5b0bd620a8acfa861b7928ec98a6e3e079aae8ea 100644 (file)
@@ -435,7 +435,12 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event)
         return;
     }
 
-    if ( m_windowTwo )
+    // Update the sash position if needed.
+    //
+    // Notice that we shouldn't do this if the sash position requested by user
+    // couldn't be set yet as it would never be taken into account at all if we
+    // modified it before this happens.
+    if ( m_windowTwo && m_requestedSashPosition == INT_MAX )
     {
         int w, h;
         GetClientSize(&w, &h);
@@ -444,13 +449,10 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event)
 
         int old_size = m_splitMode == wxSPLIT_VERTICAL ? m_lastSize.x : m_lastSize.y;
 
-        // Don't do anything if the size didn't really change. In particular,
-        // it is important that we don't reset our sash position because it's
-        // out of current range in this case as otherwise the really requested
-        // position would be lost and never set. Wait until we get a real size
-        // event with our non-initial size to do it.
+        // Don't do anything if the size didn't really change.
         if ( size != old_size )
         {
+            // Apply gravity if we use it.
             int delta = (int) ( (size - old_size)*m_sashGravity );
             if ( delta != 0 )
             {