mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-23 14:55:39 +00:00
Added a 'textBackgroundCornerRadius' property to the grid element
Also made the 'backgroundCornerRadius' and 'selectorCornerRadius' properties apply to colored rectangles
This commit is contained in:
parent
8c9d9d51fc
commit
487a842f36
es-core/src
|
@ -251,6 +251,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"selectorGradientType", STRING},
|
{"selectorGradientType", STRING},
|
||||||
{"text", STRING},
|
{"text", STRING},
|
||||||
{"textRelativeScale", FLOAT},
|
{"textRelativeScale", FLOAT},
|
||||||
|
{"textBackgroundCornerRadius", FLOAT},
|
||||||
{"textColor", COLOR},
|
{"textColor", COLOR},
|
||||||
{"textBackgroundColor", COLOR},
|
{"textBackgroundColor", COLOR},
|
||||||
{"textSelectedColor", COLOR},
|
{"textSelectedColor", COLOR},
|
||||||
|
|
|
@ -177,6 +177,7 @@ private:
|
||||||
std::unique_ptr<ImageComponent> mBackgroundImage;
|
std::unique_ptr<ImageComponent> mBackgroundImage;
|
||||||
std::string mBackgroundImagePath;
|
std::string mBackgroundImagePath;
|
||||||
float mBackgroundRelativeScale;
|
float mBackgroundRelativeScale;
|
||||||
|
float mBackgroundCornerRadius;
|
||||||
unsigned int mBackgroundColor;
|
unsigned int mBackgroundColor;
|
||||||
unsigned int mBackgroundColorEnd;
|
unsigned int mBackgroundColorEnd;
|
||||||
bool mBackgroundColorGradientHorizontal;
|
bool mBackgroundColorGradientHorizontal;
|
||||||
|
@ -185,11 +186,13 @@ private:
|
||||||
std::string mSelectorImagePath;
|
std::string mSelectorImagePath;
|
||||||
float mSelectorRelativeScale;
|
float mSelectorRelativeScale;
|
||||||
SelectorLayer mSelectorLayer;
|
SelectorLayer mSelectorLayer;
|
||||||
|
float mSelectorCornerRadius;
|
||||||
unsigned int mSelectorColor;
|
unsigned int mSelectorColor;
|
||||||
unsigned int mSelectorColorEnd;
|
unsigned int mSelectorColorEnd;
|
||||||
bool mSelectorColorGradientHorizontal;
|
bool mSelectorColorGradientHorizontal;
|
||||||
bool mHasSelectorColor;
|
bool mHasSelectorColor;
|
||||||
float mTextRelativeScale;
|
float mTextRelativeScale;
|
||||||
|
float mTextBackgroundCornerRadius;
|
||||||
unsigned int mTextColor;
|
unsigned int mTextColor;
|
||||||
unsigned int mTextBackgroundColor;
|
unsigned int mTextBackgroundColor;
|
||||||
unsigned int mTextSelectedColor;
|
unsigned int mTextSelectedColor;
|
||||||
|
@ -254,17 +257,20 @@ GridComponent<T>::GridComponent()
|
||||||
, mImageBrightness {0.0f}
|
, mImageBrightness {0.0f}
|
||||||
, mImageSaturation {1.0f}
|
, mImageSaturation {1.0f}
|
||||||
, mBackgroundRelativeScale {1.0f}
|
, mBackgroundRelativeScale {1.0f}
|
||||||
|
, mBackgroundCornerRadius {0.0f}
|
||||||
, mBackgroundColor {0xFFFFFFFF}
|
, mBackgroundColor {0xFFFFFFFF}
|
||||||
, mBackgroundColorEnd {0xFFFFFFFF}
|
, mBackgroundColorEnd {0xFFFFFFFF}
|
||||||
, mBackgroundColorGradientHorizontal {true}
|
, mBackgroundColorGradientHorizontal {true}
|
||||||
, mHasBackgroundColor {false}
|
, mHasBackgroundColor {false}
|
||||||
, mSelectorRelativeScale {1.0f}
|
, mSelectorRelativeScale {1.0f}
|
||||||
, mSelectorLayer {SelectorLayer::TOP}
|
, mSelectorLayer {SelectorLayer::TOP}
|
||||||
|
, mSelectorCornerRadius {0.0f}
|
||||||
, mSelectorColor {0xFFFFFFFF}
|
, mSelectorColor {0xFFFFFFFF}
|
||||||
, mSelectorColorEnd {0xFFFFFFFF}
|
, mSelectorColorEnd {0xFFFFFFFF}
|
||||||
, mSelectorColorGradientHorizontal {true}
|
, mSelectorColorGradientHorizontal {true}
|
||||||
, mHasSelectorColor {false}
|
, mHasSelectorColor {false}
|
||||||
, mTextRelativeScale {1.0f}
|
, mTextRelativeScale {1.0f}
|
||||||
|
, mTextBackgroundCornerRadius {0.0f}
|
||||||
, mTextColor {0x000000FF}
|
, mTextColor {0x000000FF}
|
||||||
, mTextBackgroundColor {0xFFFFFF00}
|
, mTextBackgroundColor {0xFFFFFF00}
|
||||||
, mTextSelectedColor {0x000000FF}
|
, mTextSelectedColor {0x000000FF}
|
||||||
|
@ -385,6 +391,7 @@ void GridComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeData>&
|
||||||
0x00000000, mLineSpacing, 1.0f, mTextHorizontalScrolling, mTextHorizontalScrollSpeed,
|
0x00000000, mLineSpacing, 1.0f, mTextHorizontalScrolling, mTextHorizontalScrollSpeed,
|
||||||
mTextHorizontalScrollDelay, mTextHorizontalScrollGap);
|
mTextHorizontalScrollDelay, mTextHorizontalScrollGap);
|
||||||
text->setOrigin(0.5f, 0.5f);
|
text->setOrigin(0.5f, 0.5f);
|
||||||
|
text->setBackgroundCornerRadius(mTextBackgroundCornerRadius);
|
||||||
text->setColor(mTextColor);
|
text->setColor(mTextColor);
|
||||||
text->setBackgroundColor(mTextBackgroundColor);
|
text->setBackgroundColor(mTextBackgroundColor);
|
||||||
text->setRenderBackground(true);
|
text->setRenderBackground(true);
|
||||||
|
@ -777,7 +784,9 @@ template <typename T> void GridComponent<T>::render(const glm::mat4& parentTrans
|
||||||
glm::translate(trans, glm::round(glm::vec3 {position.x, position.y, 0.0f}))};
|
glm::translate(trans, glm::round(glm::vec3 {position.x, position.y, 0.0f}))};
|
||||||
mRenderer->setMatrix(drawTrans);
|
mRenderer->setMatrix(drawTrans);
|
||||||
mRenderer->drawRect(0.0f, 0.0f, sizeX, sizeY, mSelectorColor, mSelectorColorEnd,
|
mRenderer->drawRect(0.0f, 0.0f, sizeX, sizeY, mSelectorColor, mSelectorColorEnd,
|
||||||
mSelectorColorGradientHorizontal, opacity);
|
mSelectorColorGradientHorizontal, opacity, 1.0f,
|
||||||
|
Renderer::BlendFactor::SRC_ALPHA,
|
||||||
|
Renderer::BlendFactor::ONE_MINUS_SRC_ALPHA, mSelectorCornerRadius);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -887,9 +896,13 @@ template <typename T> void GridComponent<T>::render(const glm::mat4& parentTrans
|
||||||
// If a background color is set but no background image, then render a rectangle.
|
// If a background color is set but no background image, then render a rectangle.
|
||||||
const float sizeX {mItemSize.x * scale * mBackgroundRelativeScale};
|
const float sizeX {mItemSize.x * scale * mBackgroundRelativeScale};
|
||||||
const float sizeY {mItemSize.y * scale * mBackgroundRelativeScale};
|
const float sizeY {mItemSize.y * scale * mBackgroundRelativeScale};
|
||||||
mRenderer->setMatrix(trans);
|
const glm::mat4 drawTrans {glm::translate(
|
||||||
mRenderer->drawRect(backgroundPos.x, backgroundPos.y, sizeX, sizeY, mBackgroundColor,
|
trans, glm::round(glm::vec3 {backgroundPos.x, backgroundPos.y, 0.0f}))};
|
||||||
mBackgroundColorEnd, mBackgroundColorGradientHorizontal, opacity);
|
mRenderer->setMatrix(drawTrans);
|
||||||
|
mRenderer->drawRect(
|
||||||
|
0.0f, 0.0f, sizeX, sizeY, mBackgroundColor, mBackgroundColorEnd,
|
||||||
|
mBackgroundColorGradientHorizontal, opacity, 1.0f, Renderer::BlendFactor::SRC_ALPHA,
|
||||||
|
Renderer::BlendFactor::ONE_MINUS_SRC_ALPHA, mBackgroundCornerRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursorEntry && mSelectorLayer == SelectorLayer::MIDDLE)
|
if (cursorEntry && mSelectorLayer == SelectorLayer::MIDDLE)
|
||||||
|
@ -1162,10 +1175,11 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float backgroundCornerRadius {0.0f};
|
float backgroundCornerRadius {0.0f};
|
||||||
if (elem->has("backgroundCornerRadius"))
|
if (elem->has("backgroundCornerRadius")) {
|
||||||
backgroundCornerRadius =
|
backgroundCornerRadius =
|
||||||
glm::clamp(elem->get<float>("backgroundCornerRadius"), 0.0f, 0.5f) *
|
glm::clamp(elem->get<float>("backgroundCornerRadius"), 0.0f, 0.5f) *
|
||||||
(mItemScale >= 1.0f ? mItemScale : 1.0f) * mRenderer->getScreenWidth();
|
(mItemScale >= 1.0f ? mItemScale : 1.0f) * mRenderer->getScreenWidth();
|
||||||
|
}
|
||||||
mBackgroundImage->setCornerRadius(backgroundCornerRadius);
|
mBackgroundImage->setCornerRadius(backgroundCornerRadius);
|
||||||
mBackgroundImage->setImage(elem->get<std::string>("backgroundImage"));
|
mBackgroundImage->setImage(elem->get<std::string>("backgroundImage"));
|
||||||
mBackgroundImagePath = path;
|
mBackgroundImagePath = path;
|
||||||
|
@ -1176,6 +1190,11 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
<< element.substr(5) << "\", image does not exist: \"" << path << "\"";
|
<< element.substr(5) << "\", image does not exist: \"" << path << "\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (elem->has("backgroundCornerRadius")) {
|
||||||
|
mBackgroundCornerRadius =
|
||||||
|
glm::clamp(elem->get<float>("backgroundCornerRadius"), 0.0f, 0.5f) *
|
||||||
|
(mItemScale >= 1.0f ? mItemScale : 1.0f) * mRenderer->getScreenWidth();
|
||||||
|
}
|
||||||
|
|
||||||
if (elem->has("selectorImage")) {
|
if (elem->has("selectorImage")) {
|
||||||
const std::string& path {elem->get<std::string>("selectorImage")};
|
const std::string& path {elem->get<std::string>("selectorImage")};
|
||||||
|
@ -1194,10 +1213,11 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float selectorCornerRadius {0.0f};
|
float selectorCornerRadius {0.0f};
|
||||||
if (elem->has("selectorCornerRadius"))
|
if (elem->has("selectorCornerRadius")) {
|
||||||
selectorCornerRadius =
|
selectorCornerRadius =
|
||||||
glm::clamp(elem->get<float>("selectorCornerRadius"), 0.0f, 0.5f) *
|
glm::clamp(elem->get<float>("selectorCornerRadius"), 0.0f, 0.5f) *
|
||||||
(mItemScale >= 1.0f ? mItemScale : 1.0f) * mRenderer->getScreenWidth();
|
(mItemScale >= 1.0f ? mItemScale : 1.0f) * mRenderer->getScreenWidth();
|
||||||
|
}
|
||||||
mSelectorImage->setCornerRadius(selectorCornerRadius);
|
mSelectorImage->setCornerRadius(selectorCornerRadius);
|
||||||
mSelectorImage->setImage(elem->get<std::string>("selectorImage"));
|
mSelectorImage->setImage(elem->get<std::string>("selectorImage"));
|
||||||
mSelectorImagePath = path;
|
mSelectorImagePath = path;
|
||||||
|
@ -1208,6 +1228,11 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
<< element.substr(5) << "\", image does not exist: \"" << path << "\"";
|
<< element.substr(5) << "\", image does not exist: \"" << path << "\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (elem->has("selectorCornerRadius")) {
|
||||||
|
mSelectorCornerRadius = glm::clamp(elem->get<float>("selectorCornerRadius"), 0.0f, 0.5f) *
|
||||||
|
(mItemScale >= 1.0f ? mItemScale : 1.0f) *
|
||||||
|
mRenderer->getScreenWidth();
|
||||||
|
}
|
||||||
|
|
||||||
if (elem->has("selectorLayer")) {
|
if (elem->has("selectorLayer")) {
|
||||||
const std::string& selectorLayer {elem->get<std::string>("selectorLayer")};
|
const std::string& selectorLayer {elem->get<std::string>("selectorLayer")};
|
||||||
|
@ -1367,6 +1392,12 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (elem->has("textRelativeScale"))
|
if (elem->has("textRelativeScale"))
|
||||||
mTextRelativeScale = glm::clamp(elem->get<float>("textRelativeScale"), 0.2f, 1.0f);
|
mTextRelativeScale = glm::clamp(elem->get<float>("textRelativeScale"), 0.2f, 1.0f);
|
||||||
|
|
||||||
|
if (elem->has("textBackgroundCornerRadius")) {
|
||||||
|
mTextBackgroundCornerRadius =
|
||||||
|
glm::clamp(elem->get<float>("textBackgroundCornerRadius"), 0.0f, 0.5f) *
|
||||||
|
(mItemScale >= 1.0f ? mItemScale : 1.0f) * mRenderer->getScreenWidth();
|
||||||
|
}
|
||||||
|
|
||||||
if (elem->has("textColor"))
|
if (elem->has("textColor"))
|
||||||
mTextColor = elem->get<unsigned int>("textColor");
|
mTextColor = elem->get<unsigned int>("textColor");
|
||||||
if (elem->has("textBackgroundColor"))
|
if (elem->has("textBackgroundColor"))
|
||||||
|
|
Loading…
Reference in a new issue