mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-21 21:55:38 +00:00
Added a 'selectedBackgroundMargins' property to the textlist element
This commit is contained in:
parent
f1642393a4
commit
87dc77ceaa
|
@ -265,6 +265,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
|||
{"selectedSecondaryColor", COLOR},
|
||||
{"selectedBackgroundColor", COLOR},
|
||||
{"selectedSecondaryBackgroundColor", COLOR},
|
||||
{"selectedBackgroundMargins", NORMALIZED_PAIR},
|
||||
{"textHorizontalScrolling", BOOLEAN},
|
||||
{"textHorizontalScrollSpeed", FLOAT},
|
||||
{"textHorizontalScrollDelay", FLOAT},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// ES-DE
|
||||
// ES-DE Frontend
|
||||
// TextListComponent.h
|
||||
//
|
||||
// Text list, usable in both the system and gamelist views.
|
||||
|
@ -137,6 +137,7 @@ private:
|
|||
unsigned int mSelectedSecondaryColor;
|
||||
unsigned int mSelectedBackgroundColor;
|
||||
unsigned int mSelectedSecondaryBackgroundColor;
|
||||
glm::vec2 mSelectedBackgroundMargins;
|
||||
bool mHorizontalScrolling;
|
||||
float mHorizontalScrollSpeed;
|
||||
float mHorizontalScrollDelay;
|
||||
|
@ -176,6 +177,7 @@ TextListComponent<T>::TextListComponent()
|
|||
, mSelectedSecondaryColor {0x00FF00FF}
|
||||
, mSelectedBackgroundColor {0x00000000}
|
||||
, mSelectedSecondaryBackgroundColor {0x00000000}
|
||||
, mSelectedBackgroundMargins {0.0f, 0.0f}
|
||||
, mHorizontalScrolling {true}
|
||||
, mHorizontalScrollSpeed {1.0f}
|
||||
, mHorizontalScrollDelay {3000.0f}
|
||||
|
@ -349,10 +351,19 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
|||
dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x;
|
||||
dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y;
|
||||
|
||||
float horizontalOffset {0.0f};
|
||||
if (mAlignment == PrimaryAlignment::ALIGN_LEFT && mSelectorHorizontalOffset < 0.0f)
|
||||
horizontalOffset = mSelectorHorizontalOffset;
|
||||
else if (mAlignment == PrimaryAlignment::ALIGN_RIGHT && mSelectorHorizontalOffset > 0.0f)
|
||||
horizontalOffset = mSelectorHorizontalOffset;
|
||||
|
||||
mRenderer->pushClipRect(
|
||||
glm::ivec2 {static_cast<int>(std::round(trans[3].x + mHorizontalMargin)),
|
||||
glm::ivec2 {static_cast<int>(std::round(trans[3].x + horizontalOffset + mHorizontalMargin +
|
||||
-mSelectedBackgroundMargins.x)),
|
||||
static_cast<int>(std::round(trans[3].y))},
|
||||
glm::ivec2 {static_cast<int>(std::round(dim.x - mHorizontalMargin * 2.0f)),
|
||||
glm::ivec2 {static_cast<int>(std::round((dim.x - mHorizontalMargin * 2.0f) +
|
||||
mSelectedBackgroundMargins.x +
|
||||
mSelectedBackgroundMargins.y)),
|
||||
static_cast<int>(std::round(dim.y))});
|
||||
|
||||
for (int i {startEntry}; i < listCutoff; ++i) {
|
||||
|
@ -409,9 +420,11 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
|||
mRenderer->setMatrix(drawTrans);
|
||||
|
||||
if (i == mCursor && backgroundColor != 0x00000000) {
|
||||
mRenderer->drawRect(mSelectorHorizontalOffset, mSelectorVerticalOffset,
|
||||
entry.data.entryName->getSize().x, mSelectorHeight, backgroundColor,
|
||||
backgroundColor);
|
||||
mRenderer->drawRect(mSelectorHorizontalOffset + -mSelectedBackgroundMargins.x,
|
||||
mSelectorVerticalOffset,
|
||||
entry.data.entryName->getSize().x + mSelectedBackgroundMargins.x +
|
||||
mSelectedBackgroundMargins.y,
|
||||
mSelectorHeight, backgroundColor, backgroundColor);
|
||||
}
|
||||
|
||||
entry.data.entryName->render(drawTrans);
|
||||
|
@ -487,6 +500,12 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
mSelectedSecondaryBackgroundColor = mSelectedBackgroundColor;
|
||||
}
|
||||
|
||||
if (elem->has("selectedBackgroundMargins")) {
|
||||
const glm::vec2 selectedBackgroundMargins {
|
||||
glm::clamp(elem->get<glm::vec2>("selectedBackgroundMargins"), 0.0f, 0.5f)};
|
||||
mSelectedBackgroundMargins = selectedBackgroundMargins * Renderer::getScreenWidth();
|
||||
}
|
||||
|
||||
if (elem->has("textHorizontalScrolling"))
|
||||
mHorizontalScrolling = elem->get<bool>("textHorizontalScrolling");
|
||||
|
||||
|
|
Loading…
Reference in a new issue