Left aligned DateTimeEditComponent in the scraper GUI.

This commit is contained in:
Leon Styhre 2021-03-20 11:08:28 +01:00
parent 9d9aaa30d7
commit 552368d2f6
3 changed files with 9 additions and 5 deletions

View file

@ -158,7 +158,7 @@ GuiMetaDataEd::GuiMetaDataEd(
spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0);
row.addElement(spacer, false);
ed = std::make_shared<DateTimeEditComponent>(window);
ed = std::make_shared<DateTimeEditComponent>(window, true);
ed->setOriginalColor(DEFAULT_TEXTCOLOR);
ed->setChangedColor(TEXTCOLOR_USERMARKED);
row.addElement(ed, false);

View file

@ -13,6 +13,7 @@
DateTimeEditComponent::DateTimeEditComponent(
Window* window,
bool alignRight,
DisplayMode dispMode)
: GuiComponent(window),
mEditing(false),
@ -22,7 +23,8 @@ DateTimeEditComponent::DateTimeEditComponent(
mColor(0x777777FF),
mFont(Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)),
mUppercase(false),
mAutoSize(true)
mAutoSize(true),
mAlignRight(alignRight)
{
updateTextCache();
}
@ -170,8 +172,8 @@ void DateTimeEditComponent::render(const Transform4x4f& parentTrans)
// Vertically center.
Vector3f off(0, (mSize.y() - mTextCache->metrics.size.y()) / 2.0f, 0.0f);
// Right align.
off.x() += referenceSize - mTextCache->metrics.size.x();
if (mAlignRight)
off.x() += referenceSize - mTextCache->metrics.size.x();
trans.translate(off);
Renderer::setMatrix(trans);

View file

@ -24,7 +24,8 @@ public:
DISP_RELATIVE_TO_NOW
};
DateTimeEditComponent(Window* window, DisplayMode dispMode = DISP_DATE);
DateTimeEditComponent(Window* window, bool alignRight = false,
DisplayMode dispMode = DISP_DATE);
void setValue(const std::string& val) override;
std::string getValue() const override;
@ -86,6 +87,7 @@ private:
unsigned int mColorChangedValue;
std::shared_ptr<Font> mFont;
bool mAlignRight;
bool mUppercase;
bool mAutoSize;
};