mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 16:15:39 +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},
|
{"verticalAlignment", STRING},
|
||||||
{"color", COLOR},
|
{"color", COLOR},
|
||||||
{"backgroundColor", COLOR},
|
{"backgroundColor", COLOR},
|
||||||
|
{"backgroundMargins", NORMALIZED_PAIR},
|
||||||
|
{"backgroundCornerRadius", FLOAT},
|
||||||
{"letterCase", STRING},
|
{"letterCase", STRING},
|
||||||
{"lineSpacing", FLOAT},
|
{"lineSpacing", FLOAT},
|
||||||
{"format", STRING},
|
{"format", STRING},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
// ES-DE
|
// ES-DE Frontend
|
||||||
// DateTimeComponent.cpp
|
// DateTimeComponent.cpp
|
||||||
//
|
//
|
||||||
// Provides the date and time, in absolute (actual date) or relative
|
// Provides the date and time, in absolute (actual date) or relative
|
||||||
|
@ -29,6 +29,7 @@ DateTimeComponent::DateTimeComponent(const std::string& text,
|
||||||
glm::vec2 size,
|
glm::vec2 size,
|
||||||
unsigned int bgcolor)
|
unsigned int bgcolor)
|
||||||
: TextComponent {text, font, color, horizontalAlignment, ALIGN_CENTER, pos, size, bgcolor}
|
: TextComponent {text, font, color, horizontalAlignment, ALIGN_CENTER, pos, size, bgcolor}
|
||||||
|
, mRenderer {Renderer::getInstance()}
|
||||||
, mDisplayRelative {false}
|
, mDisplayRelative {false}
|
||||||
{
|
{
|
||||||
// ISO 8601 date format.
|
// ISO 8601 date format.
|
||||||
|
@ -153,6 +154,17 @@ void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
setRenderBackground(true);
|
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")) {
|
if (properties & ALIGNMENT && elem->has("horizontalAlignment")) {
|
||||||
const std::string& horizontalAlignment {elem->get<std::string>("horizontalAlignment")};
|
const std::string& horizontalAlignment {elem->get<std::string>("horizontalAlignment")};
|
||||||
if (horizontalAlignment == "left")
|
if (horizontalAlignment == "left")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
// ES-DE
|
// ES-DE Frontend
|
||||||
// DateTimeComponent.h
|
// DateTimeComponent.h
|
||||||
//
|
//
|
||||||
// Provides the date and time, in absolute (actual date) or relative
|
// Provides the date and time, in absolute (actual date) or relative
|
||||||
|
@ -48,6 +48,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
std::string getDisplayString() const;
|
std::string getDisplayString() const;
|
||||||
|
|
||||||
|
Renderer* mRenderer;
|
||||||
std::string mDefaultValue;
|
std::string mDefaultValue;
|
||||||
Utils::Time::DateTime mTime;
|
Utils::Time::DateTime mTime;
|
||||||
std::string mFormat;
|
std::string mFormat;
|
||||||
|
|
|
@ -52,6 +52,8 @@ public:
|
||||||
void setNoTopMargin(bool margin);
|
void setNoTopMargin(bool margin);
|
||||||
void setBackgroundColor(unsigned int color) override;
|
void setBackgroundColor(unsigned int color) override;
|
||||||
void setRenderBackground(bool render) { mRenderBackground = render; }
|
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 render(const glm::mat4& parentTrans) override;
|
||||||
void onFocusLost() override { resetComponent(); }
|
void onFocusLost() override { resetComponent(); }
|
||||||
|
|
Loading…
Reference in a new issue