From ed57a9ab7b2ffa8b3ec4dabc40a00d06e8b86901 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 22 Oct 2019 19:28:02 +0200 Subject: [PATCH] Fix wxSlider::SetSize(-1, -1, -1, -1) under Mac Instead of doing basically nothing, this call completely mislaid out the control as -1 were used used literally instead of meaning "use the current geometry", as they're supposed to. Fix this by handling arguments with the value of -1 specially. Such call was done by wxCompositeWindow::SetLayoutDirection() used by the widgets sample and explained why the slider couldn't be seen when switching to its page in this sample. Closes #18442. --- src/osx/slider_osx.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/osx/slider_osx.cpp b/src/osx/slider_osx.cpp index d0bcc264f3..1d58526aa4 100644 --- a/src/osx/slider_osx.cpp +++ b/src/osx/slider_osx.cpp @@ -401,6 +401,24 @@ wxSize wxSlider::DoGetBestSize() const void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags) { + if ( w == -1 || h == -1 || + (!(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) && (x == -1 || y == -1)) ) + { + const wxRect currentRect = GetRect(); + if ( !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) + { + if ( x == -1 ) + x = currentRect.x; + if ( y == -1 ) + y = currentRect.y; + } + + if ( w == -1 ) + w = currentRect.width; + if ( h == -1 ) + h = currentRect.height; + } + int minValWidth, maxValWidth, textheight; int width = w;