Disabled double rendering of the debug overlay rectangle in ImageComponent if the maxSize property has not been used.

This commit is contained in:
Leon Styhre 2023-01-17 18:03:00 +01:00
parent f35fbd21c5
commit 8ec39e6eac

View file

@ -18,7 +18,7 @@
ImageComponent::ImageComponent(bool forceLoad, bool dynamic) ImageComponent::ImageComponent(bool forceLoad, bool dynamic)
: mRenderer {Renderer::getInstance()} : mRenderer {Renderer::getInstance()}
, mTargetSize {0, 0} , mTargetSize {0.0f, 0.0f}
, mFlipX {false} , mFlipX {false}
, mFlipY {false} , mFlipY {false}
, mTargetIsMax {false} , mTargetIsMax {false}
@ -370,10 +370,12 @@ void ImageComponent::render(const glm::mat4& parentTrans)
if (mTexture && mOpacity > 0.0f) { if (mTexture && mOpacity > 0.0f) {
if (Settings::getInstance()->getBool("DebugImage")) { if (Settings::getInstance()->getBool("DebugImage")) {
glm::vec2 targetSizePos { if (mTargetIsMax) {
glm::round((mTargetSize - mSize) * mOrigin * glm::vec2 {-1.0f})}; const glm::vec2 targetSizePos {
mRenderer->drawRect(targetSizePos.x, targetSizePos.y, mTargetSize.x, mTargetSize.y, glm::round((mTargetSize - mSize) * mOrigin * glm::vec2 {-1.0f})};
0xFF000033, 0xFF000033); mRenderer->drawRect(targetSizePos.x, targetSizePos.y, mTargetSize.x, mTargetSize.y,
0xFF000033, 0xFF000033);
}
if (mClipRegion == glm::vec4 {0.0f, 0.0f, 0.0f, 0.0f}) if (mClipRegion == glm::vec4 {0.0f, 0.0f, 0.0f, 0.0f})
mRenderer->drawRect(0.0f, 0.0f, std::round(mSize.x), std::round(mSize.y), mRenderer->drawRect(0.0f, 0.0f, std::round(mSize.x), std::round(mSize.y),
0xFF000033, 0xFF000033); 0xFF000033, 0xFF000033);
@ -438,9 +440,9 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
if (!elem) if (!elem)
return; return;
glm::vec2 scale {getParent() ? const glm::vec2 scale {getParent() ?
getParent()->getSize() : getParent()->getSize() :
glm::vec2(Renderer::getScreenWidth(), Renderer::getScreenHeight())}; glm::vec2(Renderer::getScreenWidth(), Renderer::getScreenHeight())};
if (properties & ThemeFlags::SIZE) { if (properties & ThemeFlags::SIZE) {
if (elem->has("size")) { if (elem->has("size")) {