mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00
Reverted ButtonComponent and SliderComponent to render the debug overlays themselves
This commit is contained in:
parent
8ee7b6f118
commit
b697dc2a52
|
@ -140,6 +140,14 @@ void ButtonComponent::render(const glm::mat4& parentTrans)
|
||||||
(mSize.y - mButtonText->getSize().y) / 2.0f, 0.0f};
|
(mSize.y - mButtonText->getSize().y) / 2.0f, 0.0f};
|
||||||
trans = glm::translate(trans, glm::round(centerOffset));
|
trans = glm::translate(trans, glm::round(centerOffset));
|
||||||
|
|
||||||
|
if (Settings::getInstance()->getBool("DebugText")) {
|
||||||
|
mButtonText->setDebugRendering(false);
|
||||||
|
mRenderer->drawRect(centerOffset.x, 0.0f, mButtonText->getSize().x, mSize.y, 0x00000033,
|
||||||
|
0x00000033);
|
||||||
|
mRenderer->drawRect(mBox.getPosition().x, 0.0f, mBox.getSize().x, mSize.y, 0x0000FF33,
|
||||||
|
0x0000FF33);
|
||||||
|
}
|
||||||
|
|
||||||
mButtonText->setColor(getCurTextColor());
|
mButtonText->setColor(getCurTextColor());
|
||||||
mButtonText->render(trans);
|
mButtonText->render(trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ SliderComponent::SliderComponent(float min, float max, float increment, const st
|
||||||
, mBarLength {0.0f}
|
, mBarLength {0.0f}
|
||||||
, mBarHeight {0.0f}
|
, mBarHeight {0.0f}
|
||||||
, mBarPosY {0.0f}
|
, mBarPosY {0.0f}
|
||||||
|
, mMoveAccumulator {0}
|
||||||
|
, mSliderTextSize {0.0f, 0.f}
|
||||||
, mSuffix {suffix}
|
, mSuffix {suffix}
|
||||||
{
|
{
|
||||||
assert((min - max) != 0.0f);
|
assert((min - max) != 0.0f);
|
||||||
|
@ -94,6 +96,16 @@ void SliderComponent::update(int deltaTime)
|
||||||
void SliderComponent::render(const glm::mat4& parentTrans)
|
void SliderComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans {parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
mRenderer->setMatrix(trans);
|
||||||
|
|
||||||
|
if (Settings::getInstance()->getBool("DebugText")) {
|
||||||
|
mSliderText->setDebugRendering(false);
|
||||||
|
mRenderer->drawRect(mSize.x - mSliderTextSize.x, (mSize.y - mSliderTextSize.y) / 2.0f,
|
||||||
|
mSliderTextSize.x, mSliderTextSize.y, 0x0000FF33, 0x0000FF33);
|
||||||
|
mRenderer->drawRect(mSize.x - mSliderTextSize.x, 0.0f, mSliderTextSize.x, mSize.y,
|
||||||
|
0x00000033, 0x00000033);
|
||||||
|
}
|
||||||
|
|
||||||
mSliderText->render(trans);
|
mSliderText->render(trans);
|
||||||
mRenderer->setMatrix(trans);
|
mRenderer->setMatrix(trans);
|
||||||
|
|
||||||
|
@ -129,8 +141,6 @@ void SliderComponent::onSizeChanged()
|
||||||
|
|
||||||
void SliderComponent::onValueChanged()
|
void SliderComponent::onValueChanged()
|
||||||
{
|
{
|
||||||
glm::vec2 textSize {0.0f, 0.0f};
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::fixed;
|
ss << std::fixed;
|
||||||
|
@ -147,8 +157,8 @@ void SliderComponent::onValueChanged()
|
||||||
ss << mSuffix;
|
ss << mSuffix;
|
||||||
|
|
||||||
mSliderText->setText(val);
|
mSliderText->setText(val);
|
||||||
textSize = mSliderText->getFont()->sizeText(ss.str());
|
mSliderTextSize = mSliderText->getFont()->sizeText(ss.str());
|
||||||
mSliderText->setPosition(mSize.x - textSize.x, (mSize.y - textSize.y) / 2.0f);
|
mSliderText->setPosition(mSize.x - mSliderTextSize.x, (mSize.y - mSliderTextSize.y) / 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
mKnob.setResize(0.0f, std::round(mSize.y * 0.7f));
|
mKnob.setResize(0.0f, std::round(mSize.y * 0.7f));
|
||||||
|
@ -168,8 +178,8 @@ void SliderComponent::onValueChanged()
|
||||||
setSize(getSize().x, getSize().y - 1.0f);
|
setSize(getSize().x, getSize().y - 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
mBarLength =
|
mBarLength = mSize.x - mKnob.getSize().x -
|
||||||
mSize.x - mKnob.getSize().x - (textSize.x + (4.0f * mRenderer->getScreenWidthModifier()));
|
(mSliderTextSize.x + (4.0f * mRenderer->getScreenWidthModifier()));
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -56,6 +56,7 @@ private:
|
||||||
float mBarHeight;
|
float mBarHeight;
|
||||||
float mBarPosY;
|
float mBarPosY;
|
||||||
int mMoveAccumulator;
|
int mMoveAccumulator;
|
||||||
|
glm::vec2 mSliderTextSize;
|
||||||
|
|
||||||
ImageComponent mKnob;
|
ImageComponent mKnob;
|
||||||
ImageComponent mKnobDisabled;
|
ImageComponent mKnobDisabled;
|
||||||
|
|
|
@ -38,6 +38,7 @@ TextComponent::TextComponent()
|
||||||
, mSelectable {false}
|
, mSelectable {false}
|
||||||
, mVerticalAutoSizing {false}
|
, mVerticalAutoSizing {false}
|
||||||
, mHorizontalScrolling {false}
|
, mHorizontalScrolling {false}
|
||||||
|
, mDebugRendering {true}
|
||||||
, mScrollSpeed {0.0f}
|
, mScrollSpeed {0.0f}
|
||||||
, mScrollSpeedMultiplier {1.0f}
|
, mScrollSpeedMultiplier {1.0f}
|
||||||
, mScrollDelay {1500.0f}
|
, mScrollDelay {1500.0f}
|
||||||
|
@ -85,6 +86,7 @@ TextComponent::TextComponent(const std::string& text,
|
||||||
, mSelectable {false}
|
, mSelectable {false}
|
||||||
, mVerticalAutoSizing {false}
|
, mVerticalAutoSizing {false}
|
||||||
, mHorizontalScrolling {horizontalScrolling}
|
, mHorizontalScrolling {horizontalScrolling}
|
||||||
|
, mDebugRendering {true}
|
||||||
, mScrollSpeed {0.0f}
|
, mScrollSpeed {0.0f}
|
||||||
, mScrollSpeedMultiplier {scrollSpeedMultiplier}
|
, mScrollSpeedMultiplier {scrollSpeedMultiplier}
|
||||||
, mScrollDelay {scrollDelay}
|
, mScrollDelay {scrollDelay}
|
||||||
|
@ -300,8 +302,9 @@ void TextComponent::render(const glm::mat4& parentTrans)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the overall textbox area. If we're inside a vertical scrollable container then
|
// Draw the overall textbox area. If we're inside a vertical scrollable container then
|
||||||
// this area is rendered inside that component instead of here.
|
// this area is rendered inside that component instead of here. Some other components
|
||||||
if (!secondPass && Settings::getInstance()->getBool("DebugText")) {
|
// also disable rendering here in a similar fashion.
|
||||||
|
if (mDebugRendering && !secondPass && Settings::getInstance()->getBool("DebugText")) {
|
||||||
if (!mParent || !mParent->isScrollable())
|
if (!mParent || !mParent->isScrollable())
|
||||||
mRenderer->drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0x0000FF33, 0x0000FF33);
|
mRenderer->drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0x0000FF33, 0x0000FF33);
|
||||||
}
|
}
|
||||||
|
@ -309,7 +312,7 @@ void TextComponent::render(const glm::mat4& parentTrans)
|
||||||
trans = glm::translate(trans, glm::vec3 {0.0f, std::round(yOff), 0.0f});
|
trans = glm::translate(trans, glm::vec3 {0.0f, std::round(yOff), 0.0f});
|
||||||
mRenderer->setMatrix(trans);
|
mRenderer->setMatrix(trans);
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DebugText")) {
|
if (mDebugRendering && Settings::getInstance()->getBool("DebugText")) {
|
||||||
const float relativeScaleOffset {(mSize.x - (mSize.x * mRelativeScale)) / 2.0f};
|
const float relativeScaleOffset {(mSize.x - (mSize.x * mRelativeScale)) / 2.0f};
|
||||||
if (mHorizontalScrolling && !secondPass) {
|
if (mHorizontalScrolling && !secondPass) {
|
||||||
if (mScrollOffset1 <= mTextCache->metrics.size.x) {
|
if (mScrollOffset1 <= mTextCache->metrics.size.x) {
|
||||||
|
|
|
@ -54,6 +54,8 @@ public:
|
||||||
void setRenderBackground(bool render) { mRenderBackground = render; }
|
void setRenderBackground(bool render) { mRenderBackground = render; }
|
||||||
void setBackgroundMargins(const glm::vec2 margins) { mBackgroundMargins = margins; }
|
void setBackgroundMargins(const glm::vec2 margins) { mBackgroundMargins = margins; }
|
||||||
void setBackgroundCornerRadius(const float radius) { mBackgroundCornerRadius = radius; }
|
void setBackgroundCornerRadius(const float radius) { mBackgroundCornerRadius = radius; }
|
||||||
|
// Used by some components that render the debug overlay themselves.
|
||||||
|
void setDebugRendering(bool state) { mDebugRendering = state; }
|
||||||
|
|
||||||
void render(const glm::mat4& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
void onFocusLost() override { resetComponent(); }
|
void onFocusLost() override { resetComponent(); }
|
||||||
|
@ -177,8 +179,8 @@ private:
|
||||||
bool mNoTopMargin;
|
bool mNoTopMargin;
|
||||||
bool mSelectable;
|
bool mSelectable;
|
||||||
bool mVerticalAutoSizing;
|
bool mVerticalAutoSizing;
|
||||||
|
|
||||||
bool mHorizontalScrolling;
|
bool mHorizontalScrolling;
|
||||||
|
bool mDebugRendering;
|
||||||
float mScrollSpeed;
|
float mScrollSpeed;
|
||||||
float mScrollSpeedMultiplier;
|
float mScrollSpeedMultiplier;
|
||||||
float mScrollDelay;
|
float mScrollDelay;
|
||||||
|
|
Loading…
Reference in a new issue