mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Added 'backgroundMargins' and 'backgroundCornerRadius' properties to the datetime element
This commit is contained in:
parent
1898a161b4
commit
990e26369d
|
@ -468,6 +468,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
|||
{"verticalAlignment", STRING},
|
||||
{"color", COLOR},
|
||||
{"backgroundColor", COLOR},
|
||||
{"backgroundMargins", NORMALIZED_PAIR},
|
||||
{"backgroundCornerRadius", FLOAT},
|
||||
{"letterCase", STRING},
|
||||
{"lineSpacing", FLOAT},
|
||||
{"format", STRING},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// ES-DE
|
||||
// ES-DE Frontend
|
||||
// DateTimeComponent.cpp
|
||||
//
|
||||
// Provides the date and time, in absolute (actual date) or relative
|
||||
|
@ -29,6 +29,7 @@ DateTimeComponent::DateTimeComponent(const std::string& text,
|
|||
glm::vec2 size,
|
||||
unsigned int bgcolor)
|
||||
: TextComponent {text, font, color, horizontalAlignment, ALIGN_CENTER, pos, size, bgcolor}
|
||||
, mRenderer {Renderer::getInstance()}
|
||||
, mDisplayRelative {false}
|
||||
{
|
||||
// ISO 8601 date format.
|
||||
|
@ -153,6 +154,17 @@ void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
setRenderBackground(true);
|
||||
}
|
||||
|
||||
if (elem->has("backgroundMargins")) {
|
||||
setBackgroundMargins(glm::clamp(elem->get<glm::vec2>("backgroundMargins"), 0.0f, 0.5f) *
|
||||
mRenderer->getScreenWidth());
|
||||
}
|
||||
|
||||
if (elem->has("backgroundCornerRadius")) {
|
||||
setBackgroundCornerRadius(
|
||||
glm::clamp(elem->get<float>("backgroundCornerRadius"), 0.0f, 0.5f) *
|
||||
mRenderer->getScreenWidth());
|
||||
}
|
||||
|
||||
if (properties & ALIGNMENT && elem->has("horizontalAlignment")) {
|
||||
const std::string& horizontalAlignment {elem->get<std::string>("horizontalAlignment")};
|
||||
if (horizontalAlignment == "left")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// ES-DE
|
||||
// ES-DE Frontend
|
||||
// DateTimeComponent.h
|
||||
//
|
||||
// Provides the date and time, in absolute (actual date) or relative
|
||||
|
@ -48,6 +48,7 @@ protected:
|
|||
private:
|
||||
std::string getDisplayString() const;
|
||||
|
||||
Renderer* mRenderer;
|
||||
std::string mDefaultValue;
|
||||
Utils::Time::DateTime mTime;
|
||||
std::string mFormat;
|
||||
|
|
|
@ -52,6 +52,8 @@ public:
|
|||
void setNoTopMargin(bool margin);
|
||||
void setBackgroundColor(unsigned int color) override;
|
||||
void setRenderBackground(bool render) { mRenderBackground = render; }
|
||||
void setBackgroundMargins(const glm::vec2 margins) { mBackgroundMargins = margins; }
|
||||
void setBackgroundCornerRadius(const float radius) { mBackgroundCornerRadius = radius; }
|
||||
|
||||
void render(const glm::mat4& parentTrans) override;
|
||||
void onFocusLost() override { resetComponent(); }
|
||||
|
|
Loading…
Reference in a new issue