mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Added debug overlay support to ButtonComponent, DateTimeEditComponent and TextListComponent.
This commit is contained in:
parent
acef76d791
commit
e96f8b9c0a
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -203,12 +203,19 @@ void TextListComponent<T>::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<int>(trans.translation().x() +
|
||||
mHorizontalMargin), static_cast<int>(trans.translation().y())),
|
||||
Vector2i(static_cast<int>(dim.x() - mHorizontalMargin*2), static_cast<int>(dim.y())));
|
||||
Vector2i(static_cast<int>(dim.x() - mHorizontalMargin * 2.0f),
|
||||
static_cast<int>(dim.y())));
|
||||
|
||||
for (int i = startEntry; i < listCutoff; i++) {
|
||||
typename IList<TextListData, T>::Entry& entry = mEntries.at(static_cast<unsigned int>(i));
|
||||
|
|
Loading…
Reference in a new issue