mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Added text debug overlay to SliderComponent.
Also changed a variable name to align with the standard naming conventions.
This commit is contained in:
parent
71b5c50b85
commit
b83db7d33e
|
|
@ -81,15 +81,23 @@ void SliderComponent::render(const glm::mat4& parentTrans)
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans{parentTrans * getTransform()};
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
// Render suffix.
|
if (Settings::getInstance()->getBool("DebugText")) {
|
||||||
if (mValueCache)
|
Renderer::drawRect(mSize.x - mTextCache->metrics.size.x, 0.0f, mTextCache->metrics.size.x,
|
||||||
mFont->renderTextCache(mValueCache.get());
|
mSize.y, 0x0000FF33, 0x0000FF33);
|
||||||
|
Renderer::drawRect(
|
||||||
|
mSize.x - mTextCache->metrics.size.x, (mSize.y - mTextCache->metrics.size.y) / 2.0f,
|
||||||
|
mTextCache->metrics.size.x, mTextCache->metrics.size.y, 0x0000FF33, 0x0000FF33);
|
||||||
|
}
|
||||||
|
|
||||||
float width{mSize.x - mKnob.getSize().x -
|
float width{mSize.x - mKnob.getSize().x -
|
||||||
(mValueCache ?
|
(mTextCache ?
|
||||||
mValueCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) :
|
mTextCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) :
|
||||||
0.0f)};
|
0.0f)};
|
||||||
|
|
||||||
|
// Render suffix.
|
||||||
|
if (mTextCache)
|
||||||
|
mFont->renderTextCache(mTextCache.get());
|
||||||
|
|
||||||
// Render bar.
|
// Render bar.
|
||||||
Renderer::drawRect(mKnob.getSize().x / 2.0f, mSize.y / 2.0f - mBarHeight / 2.0f, width,
|
Renderer::drawRect(mKnob.getSize().x / 2.0f, mSize.y / 2.0f - mBarHeight / 2.0f, width,
|
||||||
mBarHeight, 0x777777FF, 0x777777FF);
|
mBarHeight, 0x777777FF, 0x777777FF);
|
||||||
|
|
@ -139,17 +147,17 @@ void SliderComponent::onValueChanged()
|
||||||
const std::string max = ss.str();
|
const std::string max = ss.str();
|
||||||
|
|
||||||
glm::vec2 textSize = mFont->sizeText(max);
|
glm::vec2 textSize = mFont->sizeText(max);
|
||||||
mValueCache = std::shared_ptr<TextCache>(mFont->buildTextCache(
|
mTextCache = std::shared_ptr<TextCache>(mFont->buildTextCache(
|
||||||
val, mSize.x - textSize.x, (mSize.y - textSize.y) / 2.0f, 0x777777FF));
|
val, mSize.x - textSize.x, (mSize.y - textSize.y) / 2.0f, 0x777777FF));
|
||||||
mValueCache->metrics.size.x = textSize.x; // Fudge the width.
|
mTextCache->metrics.size.x = textSize.x; // Fudge the width.
|
||||||
}
|
}
|
||||||
|
|
||||||
mKnob.setResize(0.0f, std::round(mSize.y * 0.7f));
|
mKnob.setResize(0.0f, std::round(mSize.y * 0.7f));
|
||||||
|
|
||||||
float barLength =
|
float barLength =
|
||||||
mSize.x - mKnob.getSize().x -
|
mSize.x - mKnob.getSize().x -
|
||||||
(mValueCache ? mValueCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) :
|
(mTextCache ? mTextCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) :
|
||||||
0.0f);
|
0.0f);
|
||||||
|
|
||||||
int barHeight = static_cast<int>(std::round(2.0f * Renderer::getScreenHeightModifier()));
|
int barHeight = static_cast<int>(std::round(2.0f * Renderer::getScreenHeightModifier()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ private:
|
||||||
|
|
||||||
std::string mSuffix;
|
std::string mSuffix;
|
||||||
std::shared_ptr<Font> mFont;
|
std::shared_ptr<Font> mFont;
|
||||||
std::shared_ptr<TextCache> mValueCache;
|
std::shared_ptr<TextCache> mTextCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_CORE_COMPONENTS_SLIDER_COMPONENT_H
|
#endif // ES_CORE_COMPONENTS_SLIDER_COMPONENT_H
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue