Fix layout of wxSlider with wxSL_VALUE_LABEL only in wxMSW

Correct the slider geometry calculations to work correctly when the label is
used but min/max labels are not.

Closes #17377.
This commit is contained in:
gafatoa
2016-02-21 14:51:25 +01:00
committed by Vadim Zeitlin
parent e4fce9089e
commit c20739313a
2 changed files with 14 additions and 4 deletions

View File

@@ -213,6 +213,7 @@ wxMSW:
- Fix strike-through support in wxFont with GDI+ (David Vanderson). - Fix strike-through support in wxFont with GDI+ (David Vanderson).
- Fix UTF-32 conversion for non-BMP characters (ARATA Mizuki). - Fix UTF-32 conversion for non-BMP characters (ARATA Mizuki).
- Use correct parent for the native modal dialogs (Andreas Falkenhahn). - Use correct parent for the native modal dialogs (Andreas Falkenhahn).
- Fix layout of wxSlider with wxSL_VALUE_LABEL only (gafatoa).
wxOSX/Cocoa: wxOSX/Cocoa:

View File

@@ -431,6 +431,8 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
labelOffset = longestLabelWidth + HGAP; labelOffset = longestLabelWidth + HGAP;
} }
int labelHeightUsed = 0 ;
if ( HasFlag(wxSL_MIN_MAX_LABELS) ) if ( HasFlag(wxSL_MIN_MAX_LABELS) )
{ {
if ( HasFlag(wxSL_INVERSE) ) if ( HasFlag(wxSL_INVERSE) )
@@ -446,6 +448,8 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
holdBottomX, holdBottomX,
y + height - labelHeight, y + height - labelHeight,
maxLabelWidth, labelHeight); maxLabelWidth, labelHeight);
labelHeightUsed = labelHeight ;
} }
if ( HasFlag(wxSL_VALUE_LABEL) ) if ( HasFlag(wxSL_VALUE_LABEL) )
@@ -459,9 +463,9 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
// position the slider itself along the left/right edge // position the slider itself along the left/right edge
wxSliderBase::DoMoveWindow( wxSliderBase::DoMoveWindow(
x + labelOffset, x + labelOffset,
y + labelHeight, y + labelHeightUsed,
THUMB + tickOffset + HGAP, THUMB + tickOffset + HGAP,
height - (labelHeight * 2)); height - (labelHeightUsed * 2));
} }
else // horizontal else // horizontal
{ {
@@ -473,6 +477,8 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
(longestLabelWidth / 2); (longestLabelWidth / 2);
int ySlider = y; int ySlider = y;
int minLabelWidthUsed = 0 ;
int maxLabelWidthUsed = 0 ;
if ( HasFlag(wxSL_VALUE_LABEL) ) if ( HasFlag(wxSL_VALUE_LABEL) )
{ {
@@ -498,13 +504,16 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
x + width - maxLabelWidth, x + width - maxLabelWidth,
yLabelMinMax, yLabelMinMax,
maxLabelWidth, labelHeight); maxLabelWidth, labelHeight);
minLabelWidthUsed = minLabelWidth + VGAP ;
maxLabelWidthUsed = maxLabelWidth + VGAP ;
} }
// position the slider itself along the top/bottom edge // position the slider itself along the top/bottom edge
wxSliderBase::DoMoveWindow( wxSliderBase::DoMoveWindow(
x + minLabelWidth + VGAP, x + minLabelWidthUsed,
ySlider, ySlider,
width - (minLabelWidth + maxLabelWidth + (VGAP*2)), width - (minLabelWidthUsed + maxLabelWidthUsed),
THUMB + tickOffset); THUMB + tickOffset);
} }
} }