Fix wxMSW wxSlider best size calculation and label layout.
The best size calculation was wrong as the min/max labels height was unnecessarily added to the slier total height even if though these labels are positioned alongside the slider itself in horizontal layout case. The slider also managed to position its value label completely outside the space allocated to it (and the bug in DoGetBestSize() might have been an attempt to work around this), don't do this any more. This also fixes the wrongly centered vertical position of the min/max labels. Closes #13291. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68207 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ebcdce46d2
commit
c12d4e1dac
@ -493,8 +493,21 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
||||
((width - (m_minLabelWidth + m_maxLabelWidth)) / 2) -
|
||||
(m_maxLabelWidth / 2);
|
||||
|
||||
int ySlider = y;
|
||||
|
||||
if ( HasFlag(wxSL_BOTTOM) )
|
||||
{
|
||||
if ( HasFlag(wxSL_VALUE_LABEL) )
|
||||
{
|
||||
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
|
||||
xLabelValue,
|
||||
y,
|
||||
maxLabelWidth, labelHeight);
|
||||
|
||||
ySlider += labelHeight;
|
||||
yLabelMinMax += labelHeight;
|
||||
}
|
||||
|
||||
if ( HasFlag(wxSL_MIN_MAX_LABELS) )
|
||||
{
|
||||
holdLeftX = x;
|
||||
@ -515,16 +528,17 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
||||
yLabelMinMax,
|
||||
holdRightWidth, labelHeight);
|
||||
}
|
||||
if ( HasFlag(wxSL_VALUE_LABEL) )
|
||||
{
|
||||
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
|
||||
xLabelValue,
|
||||
y - labelHeight,
|
||||
maxLabelWidth, labelHeight);
|
||||
}
|
||||
}
|
||||
else // wxSL_TOP
|
||||
{
|
||||
if ( HasFlag(wxSL_VALUE_LABEL) )
|
||||
{
|
||||
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
|
||||
xLabelValue,
|
||||
y + THUMB + tickOffset,
|
||||
maxLabelWidth, labelHeight);
|
||||
}
|
||||
|
||||
if ( HasFlag(wxSL_MIN_MAX_LABELS) )
|
||||
{
|
||||
holdLeftX = x;
|
||||
@ -545,11 +559,6 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
||||
yLabelMinMax,
|
||||
holdRightWidth, labelHeight);
|
||||
}
|
||||
if ( HasFlag(wxSL_VALUE_LABEL) )
|
||||
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
|
||||
xLabelValue,
|
||||
y + THUMB + tickOffset,
|
||||
maxLabelWidth, labelHeight);
|
||||
}
|
||||
|
||||
// position the slider itself along the top/bottom edge
|
||||
@ -557,7 +566,7 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
||||
labelOffset = labelHeight;
|
||||
wxSliderBase::DoMoveWindow(
|
||||
x + m_minLabelWidth + VGAP,
|
||||
y,
|
||||
ySlider,
|
||||
width - (m_minLabelWidth + m_maxLabelWidth + (VGAP*2)),
|
||||
THUMB + tickOffset);
|
||||
}
|
||||
@ -597,12 +606,17 @@ wxSize wxSlider::DoGetBestSize() const
|
||||
|
||||
if ( m_labels )
|
||||
{
|
||||
// labels add extra height
|
||||
int labelSize = GetLabelsSize();
|
||||
if ( HasFlag(wxSL_MIN_MAX_LABELS) )
|
||||
|
||||
// Min/max labels are compensated by the ticks so we don't need
|
||||
// extra space for them if we're also showing ticks.
|
||||
if ( HasFlag(wxSL_MIN_MAX_LABELS) && !HasFlag(wxSL_TICKS) )
|
||||
size.y += labelSize;
|
||||
|
||||
// The value label is always on top of the control and so does need
|
||||
// extra space in any case.
|
||||
if ( HasFlag(wxSL_VALUE_LABEL) )
|
||||
size.y += static_cast<int>(labelSize*2.75);
|
||||
size.y += labelSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user