diff --git a/es-core/src/components/ButtonComponent.cpp b/es-core/src/components/ButtonComponent.cpp index 0a153876d..caa82ad4b 100644 --- a/es-core/src/components/ButtonComponent.cpp +++ b/es-core/src/components/ButtonComponent.cpp @@ -10,6 +10,7 @@ #include "resources/Font.h" #include "utils/StringUtil.h" +#include "Settings.h" ButtonComponent::ButtonComponent( Window* window, const std::string& text, @@ -101,11 +102,19 @@ void ButtonComponent::render(const Transform4x4f& parentTrans) mBox.render(trans); if (mTextCache) { - Vector3f centerOffset((mSize.x() - mTextCache->metrics.size.x()) / 2, - (mSize.y() - mTextCache->metrics.size.y()) / 2, 0); + Vector3f centerOffset((mSize.x() - mTextCache->metrics.size.x()) / 2.0f, + (mSize.y() - mTextCache->metrics.size.y()) / 2.0f, 0); trans = trans.translate(centerOffset); + if (Settings::getInstance()->getBool("DebugText")) { + Renderer::drawRect(centerOffset.x(), 0.0f, mTextCache->metrics.size.x(), + mSize.y(), 0x00000033, 0x00000033); + Renderer::drawRect(mBox.getPosition().x(), 0.0f, mBox.getSize().x(), + mSize.y(), 0x0000FF33, 0x0000FF33); + } + Renderer::setMatrix(trans); + mTextCache->setColor(getCurTextColor()); mFont->renderTextCache(mTextCache.get()); trans = trans.translate(-centerOffset); diff --git a/es-core/src/components/DateTimeEditComponent.cpp b/es-core/src/components/DateTimeEditComponent.cpp index adc9280c3..119d256ee 100644 --- a/es-core/src/components/DateTimeEditComponent.cpp +++ b/es-core/src/components/DateTimeEditComponent.cpp @@ -10,6 +10,7 @@ #include "resources/Font.h" #include "utils/StringUtil.h" +#include "Settings.h" DateTimeEditComponent::DateTimeEditComponent( Window* window, @@ -174,12 +175,23 @@ void DateTimeEditComponent::render(const Transform4x4f& parentTrans) // Vertically center. Vector3f off(0, (mSize.y() - mTextCache->metrics.size.y()) / 2.0f, 0.0f); + if (mAlignRight) off.x() += referenceSize - mTextCache->metrics.size.x(); trans.translate(off); Renderer::setMatrix(trans); + if (Settings::getInstance()->getBool("DebugText")) { + Renderer::setMatrix(trans); + if (mTextCache->metrics.size.x() > 0) { + Renderer::drawRect(0.0f, 0.0f - off.y(), + mSize.x() - off.x(), mSize.y(), 0x0000FF33, 0x0000FF33); + } + Renderer::drawRect(0.0f, 0.0f, mTextCache->metrics.size.x(), + mTextCache->metrics.size.y(), 0x00000033, 0x00000033); + } + mTextCache->setColor((mColor & 0xFFFFFF00) | getOpacity()); font->renderTextCache(mTextCache.get()); diff --git a/es-core/src/components/TextListComponent.h b/es-core/src/components/TextListComponent.h index 3f38a7fae..0185a47cd 100644 --- a/es-core/src/components/TextListComponent.h +++ b/es-core/src/components/TextListComponent.h @@ -203,12 +203,19 @@ void TextListComponent::render(const Transform4x4f& parentTrans) } } + if (Settings::getInstance()->getBool("DebugText")) { + Renderer::drawRect(mHorizontalMargin, 0.0f, mSize.x() - mHorizontalMargin * 2.0f, + mSize.y(), 0x00000033, 0x00000033); + Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x0000FF33, 0x0000FF33); + } + // Clip to inside margins. Vector3f dim(mSize.x(), mSize.y(), 0); dim = trans * dim - trans.translation(); Renderer::pushClipRect(Vector2i(static_cast(trans.translation().x() + mHorizontalMargin), static_cast(trans.translation().y())), - Vector2i(static_cast(dim.x() - mHorizontalMargin*2), static_cast(dim.y()))); + Vector2i(static_cast(dim.x() - mHorizontalMargin * 2.0f), + static_cast(dim.y()))); for (int i = startEntry; i < listCutoff; i++) { typename IList::Entry& entry = mEntries.at(static_cast(i));