Fixed an issue where the slider knob was sometimes not correctly positioned horizontally

This commit is contained in:
Leon Styhre 2023-10-20 17:37:16 +02:00
parent d6f4c40a38
commit b43e466175

View file

@ -165,11 +165,6 @@ void SliderComponent::onValueChanged()
mKnob.setResize(0.0f, std::round(mSize.y * 0.7f)); mKnob.setResize(0.0f, std::round(mSize.y * 0.7f));
float barLength {
mSize.x - mKnob.getSize().x -
(mTextCache ? mTextCache->metrics.size.x + (4.0f * mRenderer->getScreenWidthModifier()) :
0.0f)};
if (mRenderer->getScreenWidth() > mRenderer->getScreenHeight()) if (mRenderer->getScreenWidth() > mRenderer->getScreenHeight())
mBarHeight = std::round(2.0f * mRenderer->getScreenHeightModifier()); mBarHeight = std::round(2.0f * mRenderer->getScreenHeightModifier());
else else
@ -185,6 +180,11 @@ void SliderComponent::onValueChanged()
setSize(getSize().x, getSize().y - 1.0f); setSize(getSize().x, getSize().y - 1.0f);
} }
float barLength {
mSize.x - mKnob.getSize().x -
(mTextCache ? mTextCache->metrics.size.x + (4.0f * mRenderer->getScreenWidthModifier()) :
0.0f)};
// Likewise for the bar. // Likewise for the bar.
if (static_cast<int>(mSize.y) % 2 != static_cast<int>(mBarHeight) % 2) { if (static_cast<int>(mSize.y) % 2 != static_cast<int>(mBarHeight) % 2) {
if (mBarHeight > 1.0f && mSize.y / mBarHeight < 5.0f) if (mBarHeight > 1.0f && mSize.y / mBarHeight < 5.0f)