mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 15:15:37 +00:00
ScrollableContainer parameters are now themeable.
This commit is contained in:
parent
788c9a3f58
commit
28a3beb9ce
|
@ -135,7 +135,6 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
|||
else if (element.second.type == "text") {
|
||||
if (element.second.has("container") && element.second.get<bool>("container")) {
|
||||
mContainerComponents.push_back(std::make_unique<ScrollableContainer>());
|
||||
mContainerComponents.back()->setAutoScroll(true);
|
||||
mContainerComponents.back()->setDefaultZIndex(40.0f);
|
||||
addChild(mContainerComponents.back().get());
|
||||
mContainerTextComponents.push_back(std::make_unique<TextComponent>());
|
||||
|
@ -144,11 +143,12 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
|||
mContainerComponents.back()->applyTheme(theme, "gamelist", element.first,
|
||||
POSITION | ThemeFlags::SIZE | Z_INDEX |
|
||||
VISIBLE);
|
||||
mContainerComponents.back()->setAutoScroll(true);
|
||||
mContainerTextComponents.back()->setSize(
|
||||
mContainerComponents.back()->getSize().x, 0.0f);
|
||||
mContainerTextComponents.back()->applyTheme(
|
||||
theme, "gamelist", element.first,
|
||||
(ALL ^ POSITION ^ Z_INDEX ^ ThemeFlags::SIZE ^ VISIBLE ^ ROTATION) | COLOR);
|
||||
ALL ^ POSITION ^ Z_INDEX ^ ThemeFlags::SIZE ^ VISIBLE ^ ROTATION);
|
||||
mContainerComponents.back()->setScrollHide(true);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -145,6 +145,9 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
|||
{"text", STRING},
|
||||
{"metadata", STRING},
|
||||
{"container", BOOLEAN},
|
||||
{"containerScrollSpeed", FLOAT},
|
||||
{"containerStartDelay", FLOAT},
|
||||
{"containerResetDelay", FLOAT},
|
||||
{"fontPath", PATH},
|
||||
{"fontSize", FLOAT},
|
||||
{"alignment", STRING},
|
||||
|
|
|
@ -77,6 +77,34 @@ void ScrollableContainer::reset()
|
|||
}
|
||||
}
|
||||
|
||||
void ScrollableContainer::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||
const std::string& view,
|
||||
const std::string& element,
|
||||
unsigned int properties)
|
||||
{
|
||||
using namespace ThemeFlags;
|
||||
GuiComponent::applyTheme(theme, view, element, properties);
|
||||
|
||||
const ThemeData::ThemeElement* elem {theme->getElement(view, element, "text")};
|
||||
if (!elem || !elem->has("container"))
|
||||
return;
|
||||
|
||||
if (elem->has("containerScrollSpeed")) {
|
||||
mAutoScrollSpeedConstant =
|
||||
AUTO_SCROLL_SPEED / glm::clamp(elem->get<float>("containerScrollSpeed"), 0.1f, 10.0f);
|
||||
}
|
||||
|
||||
if (elem->has("containerStartDelay")) {
|
||||
mAutoScrollDelayConstant =
|
||||
glm::clamp(elem->get<float>("containerStartDelay"), 0.0f, 10.0f) * 1000.0f;
|
||||
}
|
||||
|
||||
if (elem->has("containerResetDelay")) {
|
||||
mAutoScrollResetDelayConstant =
|
||||
glm::clamp(elem->get<float>("containerResetDelay"), 0.0f, 20.0f) * 1000.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollableContainer::update(int deltaTime)
|
||||
{
|
||||
if (mSize == glm::vec2 {0.0f, 0.0f})
|
||||
|
|
|
@ -33,6 +33,11 @@ public:
|
|||
float autoScrollSpeedConstant) override;
|
||||
void reset();
|
||||
|
||||
void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||
const std::string& view,
|
||||
const std::string& element,
|
||||
unsigned int properties) override;
|
||||
|
||||
void update(int deltaTime) override;
|
||||
void render(const glm::mat4& parentTrans) override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue