mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00
Right aligned DateTimeEditComponent and made some minor adjustments in GuiMetaDataEd.
This commit is contained in:
parent
d65ecd6a50
commit
9d9aaa30d7
|
@ -144,6 +144,10 @@ GuiMetaDataEd::GuiMetaDataEd(
|
|||
ed->setSize(0, height);
|
||||
row.addElement(ed, false, true);
|
||||
|
||||
auto ratingSpacer = std::make_shared<GuiComponent>(mWindow);
|
||||
ratingSpacer->setSize(Renderer::getScreenWidth() * 0.001f, 0);
|
||||
row.addElement(ratingSpacer, false);
|
||||
|
||||
// Pass input to the actual RatingComponent instead of the spacer.
|
||||
row.input_handler = std::bind(&GuiComponent::input,
|
||||
ed.get(), std::placeholders::_1, std::placeholders::_2);
|
||||
|
@ -159,6 +163,10 @@ GuiMetaDataEd::GuiMetaDataEd(
|
|||
ed->setChangedColor(TEXTCOLOR_USERMARKED);
|
||||
row.addElement(ed, false);
|
||||
|
||||
auto dateSpacer = std::make_shared<GuiComponent>(mWindow);
|
||||
dateSpacer->setSize(Renderer::getScreenWidth() * 0.0035f, 0);
|
||||
row.addElement(dateSpacer, false);
|
||||
|
||||
// Pass input to the actual DateTimeEditComponent instead of the spacer.
|
||||
row.input_handler = std::bind(&GuiComponent::input, ed.get(),
|
||||
std::placeholders::_1, std::placeholders::_2);
|
||||
|
|
|
@ -160,14 +160,22 @@ void DateTimeEditComponent::render(const Transform4x4f& parentTrans)
|
|||
Transform4x4f trans = parentTrans * getTransform();
|
||||
|
||||
if (mTextCache) {
|
||||
std::shared_ptr<Font> font = getFont();
|
||||
float referenceSize;
|
||||
|
||||
if (mTime != 0)
|
||||
referenceSize = font->sizeText("ABCDEFG").x();
|
||||
else
|
||||
referenceSize = font->sizeText("ABCDEIJ").x();
|
||||
|
||||
// Vertically center.
|
||||
Vector3f off(0, (mSize.y() - mTextCache->metrics.size.y()) / 2, 0);
|
||||
Vector3f off(0, (mSize.y() - mTextCache->metrics.size.y()) / 2.0f, 0.0f);
|
||||
// Right align.
|
||||
off.x() += referenceSize - mTextCache->metrics.size.x();
|
||||
trans.translate(off);
|
||||
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
std::shared_ptr<Font> font = getFont();
|
||||
|
||||
mTextCache->setColor((mColor & 0xFFFFFF00) | getOpacity());
|
||||
font->renderTextCache(mTextCache.get());
|
||||
|
||||
|
@ -211,15 +219,13 @@ std::string DateTimeEditComponent::getDisplayString(DisplayMode mode) const
|
|||
switch (mode) {
|
||||
case DISP_DATE: {
|
||||
if (mTime.getTime() == 0)
|
||||
// The extra blankspaces are for visual alignment.
|
||||
return "unknown ";
|
||||
return "unknown";
|
||||
fmt = "%Y-%m-%d";
|
||||
break;
|
||||
}
|
||||
case DISP_DATE_TIME: {
|
||||
if (mTime.getTime() == 0)
|
||||
// The extra blankspaces are for visual alignment.
|
||||
return "unknown ";
|
||||
return "unknown";
|
||||
fmt = "%Y-%m-%d %H:%M:%S";
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue