mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Added a 'selectedBackgroundCornerRadius' property to the textlist element
This commit is contained in:
parent
c8c601bcc9
commit
5dd7a371fe
|
@ -266,6 +266,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"selectedBackgroundColor", COLOR},
|
{"selectedBackgroundColor", COLOR},
|
||||||
{"selectedSecondaryBackgroundColor", COLOR},
|
{"selectedSecondaryBackgroundColor", COLOR},
|
||||||
{"selectedBackgroundMargins", NORMALIZED_PAIR},
|
{"selectedBackgroundMargins", NORMALIZED_PAIR},
|
||||||
|
{"selectedBackgroundCornerRadius", FLOAT},
|
||||||
{"textHorizontalScrolling", BOOLEAN},
|
{"textHorizontalScrolling", BOOLEAN},
|
||||||
{"textHorizontalScrollSpeed", FLOAT},
|
{"textHorizontalScrollSpeed", FLOAT},
|
||||||
{"textHorizontalScrollDelay", FLOAT},
|
{"textHorizontalScrollDelay", FLOAT},
|
||||||
|
|
|
@ -138,6 +138,7 @@ private:
|
||||||
unsigned int mSelectedBackgroundColor;
|
unsigned int mSelectedBackgroundColor;
|
||||||
unsigned int mSelectedSecondaryBackgroundColor;
|
unsigned int mSelectedSecondaryBackgroundColor;
|
||||||
glm::vec2 mSelectedBackgroundMargins;
|
glm::vec2 mSelectedBackgroundMargins;
|
||||||
|
float mSelectedBackgroundCornerRadius;
|
||||||
bool mHorizontalScrolling;
|
bool mHorizontalScrolling;
|
||||||
float mHorizontalScrollSpeed;
|
float mHorizontalScrollSpeed;
|
||||||
float mHorizontalScrollDelay;
|
float mHorizontalScrollDelay;
|
||||||
|
@ -178,6 +179,7 @@ TextListComponent<T>::TextListComponent()
|
||||||
, mSelectedBackgroundColor {0x00000000}
|
, mSelectedBackgroundColor {0x00000000}
|
||||||
, mSelectedSecondaryBackgroundColor {0x00000000}
|
, mSelectedSecondaryBackgroundColor {0x00000000}
|
||||||
, mSelectedBackgroundMargins {0.0f, 0.0f}
|
, mSelectedBackgroundMargins {0.0f, 0.0f}
|
||||||
|
, mSelectedBackgroundCornerRadius {0.0f}
|
||||||
, mHorizontalScrolling {true}
|
, mHorizontalScrolling {true}
|
||||||
, mHorizontalScrollSpeed {1.0f}
|
, mHorizontalScrollSpeed {1.0f}
|
||||||
, mHorizontalScrollDelay {3000.0f}
|
, mHorizontalScrollDelay {3000.0f}
|
||||||
|
@ -420,11 +422,27 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
||||||
mRenderer->setMatrix(drawTrans);
|
mRenderer->setMatrix(drawTrans);
|
||||||
|
|
||||||
if (i == mCursor && backgroundColor != 0x00000000) {
|
if (i == mCursor && backgroundColor != 0x00000000) {
|
||||||
mRenderer->drawRect(mSelectorHorizontalOffset + -mSelectedBackgroundMargins.x,
|
if (mSelectorHorizontalOffset != 0.0f || mSelectedBackgroundMargins.x != 0.0f) {
|
||||||
mSelectorVerticalOffset,
|
drawTrans = glm::translate(
|
||||||
|
drawTrans, glm::vec3 {mSelectorHorizontalOffset - mSelectedBackgroundMargins.x,
|
||||||
|
0.0f, 0.0f});
|
||||||
|
mRenderer->setMatrix(drawTrans);
|
||||||
|
}
|
||||||
|
|
||||||
|
mRenderer->drawRect(0.0f, mSelectorVerticalOffset,
|
||||||
entry.data.entryName->getSize().x + mSelectedBackgroundMargins.x +
|
entry.data.entryName->getSize().x + mSelectedBackgroundMargins.x +
|
||||||
mSelectedBackgroundMargins.y,
|
mSelectedBackgroundMargins.y,
|
||||||
mSelectorHeight, backgroundColor, backgroundColor);
|
mSelectorHeight, backgroundColor, backgroundColor, false, 1.0f,
|
||||||
|
1.0f, Renderer::BlendFactor::SRC_ALPHA,
|
||||||
|
Renderer::BlendFactor::ONE_MINUS_SRC_ALPHA,
|
||||||
|
mSelectedBackgroundCornerRadius);
|
||||||
|
|
||||||
|
if (mSelectorHorizontalOffset != 0.0f || mSelectedBackgroundMargins.x != 0.0f) {
|
||||||
|
drawTrans = glm::translate(
|
||||||
|
drawTrans, glm::vec3 {-mSelectorHorizontalOffset + mSelectedBackgroundMargins.x,
|
||||||
|
0.0f, 0.0f});
|
||||||
|
mRenderer->setMatrix(drawTrans);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.data.entryName->render(drawTrans);
|
entry.data.entryName->render(drawTrans);
|
||||||
|
@ -506,6 +524,12 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
mSelectedBackgroundMargins = selectedBackgroundMargins * Renderer::getScreenWidth();
|
mSelectedBackgroundMargins = selectedBackgroundMargins * Renderer::getScreenWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elem->has("selectedBackgroundCornerRadius")) {
|
||||||
|
mSelectedBackgroundCornerRadius =
|
||||||
|
glm::clamp(elem->get<float>("selectedBackgroundCornerRadius"), 0.0f, 0.5f) *
|
||||||
|
mRenderer->getScreenWidth();
|
||||||
|
}
|
||||||
|
|
||||||
if (elem->has("textHorizontalScrolling"))
|
if (elem->has("textHorizontalScrolling"))
|
||||||
mHorizontalScrolling = elem->get<bool>("textHorizontalScrolling");
|
mHorizontalScrolling = elem->get<bool>("textHorizontalScrolling");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue