X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c79d40fe1e07a2bbb9aa92b6978a6271b269fbf4..8a31648287be0ef976f133de2786b137f1e98340:/src/generic/splitter.cpp diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 5b0bd620a8..dee38940af 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -435,6 +435,8 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event) return; } + const wxSize curSize = event.GetSize(); + // Update the sash position if needed. // // Notice that we shouldn't do this if the sash position requested by user @@ -442,32 +444,35 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event) // modified it before this happens. if ( m_windowTwo && m_requestedSashPosition == INT_MAX ) { - int w, h; - GetClientSize(&w, &h); - - int size = m_splitMode == wxSPLIT_VERTICAL ? w : h; + int size = m_splitMode == wxSPLIT_VERTICAL ? curSize.x : curSize.y; int old_size = m_splitMode == wxSPLIT_VERTICAL ? m_lastSize.x : m_lastSize.y; // Don't do anything if the size didn't really change. if ( size != old_size ) { + int newPosition = -1; + // Apply gravity if we use it. int delta = (int) ( (size - old_size)*m_sashGravity ); if ( delta != 0 ) { - int newPosition = m_sashPosition + delta; + newPosition = m_sashPosition + delta; if( newPosition < m_minimumPaneSize ) newPosition = m_minimumPaneSize; - SetSashPositionAndNotify(newPosition); } - if ( m_sashPosition >= size - 5 ) - SetSashPositionAndNotify(wxMax(10, size - 40)); - m_lastSize = wxSize(w,h); + // Also check if the second window became too small. + newPosition = AdjustSashPosition(newPosition == -1 + ? m_sashPosition + : newPosition); + if ( newPosition != m_sashPosition ) + SetSashPositionAndNotify(newPosition); } } + m_lastSize = curSize; + SizeWindows(); }