implement debug rects for images similar to text components

This commit is contained in:
jrassa 2018-01-22 19:31:18 -05:00
parent 96a0fa3a14
commit b41118fe92
3 changed files with 12 additions and 0 deletions

View file

@ -13,6 +13,7 @@ std::vector<const char*> settings_dont_save {
{ "Debug" },
{ "DebugGrid" },
{ "DebugText" },
{ "DebugImage" },
{ "ForceKid" },
{ "ForceKiosk" },
{ "IgnoreGamelist" },

View file

@ -168,6 +168,11 @@ void Window::input(InputConfig* config, Input input)
// toggle TextComponent debug view with Ctrl-T
Settings::getInstance()->setBool("DebugText", !Settings::getInstance()->getBool("DebugText"));
}
else if(config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_i && SDL_GetModState() & KMOD_LCTRL && Settings::getInstance()->getBool("Debug"))
{
// toggle TextComponent debug view with Ctrl-I
Settings::getInstance()->setBool("DebugImage", !Settings::getInstance()->getBool("DebugImage"));
}
else
{
if (peekGui())

View file

@ -3,6 +3,7 @@
#include "resources/TextureResource.h"
#include "Log.h"
#include "Renderer.h"
#include "Settings.h"
#include "ThemeData.h"
Vector2i ImageComponent::getTextureSize() const
@ -229,6 +230,11 @@ void ImageComponent::render(const Transform4x4f& parentTrans)
if(mTexture && mOpacity > 0)
{
if(Settings::getInstance()->getBool("DebugImage")) {
Vector2f targetSizePos = (mTargetSize - mSize) * mOrigin * -1;
Renderer::drawRect(targetSizePos.x(), targetSizePos.y(), mTargetSize.x(), mTargetSize.y(), 0xFF000033);
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x00000033);
}
if(mTexture->isInitialized())
{
// actually draw the image