mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 22:25:38 +00:00
Added support for two new 'scrollFadeIn' and 'defaultImage' properties.
Also fixed some issues with theming ScrollableContainer.
This commit is contained in:
parent
6676e9c353
commit
3bf46c3fb0
|
@ -129,25 +129,22 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
}
|
}
|
||||||
else if (element.second.type == "text") {
|
else if (element.second.type == "text") {
|
||||||
if (element.second.has("container") && element.second.get<bool>("container")) {
|
if (element.second.has("container") && element.second.get<bool>("container")) {
|
||||||
mContainerTextComponents.push_back(std::make_unique<TextComponent>());
|
|
||||||
mContainerTextComponents.back()->setDefaultZIndex(40.0f);
|
|
||||||
mContainerComponents.push_back(std::make_unique<ScrollableContainer>());
|
mContainerComponents.push_back(std::make_unique<ScrollableContainer>());
|
||||||
mContainerComponents.back()->setAutoScroll(true);
|
mContainerComponents.back()->setAutoScroll(true);
|
||||||
|
mContainerComponents.back()->setDefaultZIndex(40.0f);
|
||||||
|
addChild(mContainerComponents.back().get());
|
||||||
|
mContainerTextComponents.push_back(std::make_unique<TextComponent>());
|
||||||
|
mContainerTextComponents.back()->setDefaultZIndex(40.0f);
|
||||||
mContainerComponents.back()->addChild(mContainerTextComponents.back().get());
|
mContainerComponents.back()->addChild(mContainerTextComponents.back().get());
|
||||||
mContainerComponents.back()->applyTheme(theme, "gamelist", element.first,
|
mContainerComponents.back()->applyTheme(theme, "gamelist", element.first,
|
||||||
POSITION | ThemeFlags::SIZE | Z_INDEX |
|
POSITION | ThemeFlags::SIZE | Z_INDEX |
|
||||||
VISIBLE);
|
VISIBLE);
|
||||||
mContainerTextComponents.back()->applyTheme(theme, "gamelist", element.first,
|
|
||||||
ALL ^ POSITION ^ Z_INDEX ^
|
|
||||||
ThemeFlags::SIZE ^ VISIBLE);
|
|
||||||
mContainerTextComponents.back()->setSize(
|
mContainerTextComponents.back()->setSize(
|
||||||
mContainerComponents.back()->getSize().x, 0.0f);
|
mContainerComponents.back()->getSize().x, 0.0f);
|
||||||
mContainerComponents.back()->setDefaultZIndex(
|
mContainerTextComponents.back()->applyTheme(
|
||||||
mContainerTextComponents.back()->getDefaultZIndex());
|
theme, "gamelist", element.first,
|
||||||
mContainerComponents.back()->setZIndex(
|
(ALL ^ POSITION ^ Z_INDEX ^ ThemeFlags::SIZE ^ VISIBLE ^ ROTATION) | COLOR);
|
||||||
mContainerTextComponents.back()->getZIndex());
|
|
||||||
mContainerComponents.back()->setScrollHide(true);
|
mContainerComponents.back()->setScrollHide(true);
|
||||||
addChild(mContainerComponents.back().get());
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mTextComponents.push_back(std::make_unique<TextComponent>());
|
mTextComponents.push_back(std::make_unique<TextComponent>());
|
||||||
|
@ -551,7 +548,7 @@ void GamelistView::updateInfoPanel()
|
||||||
|
|
||||||
// Fade in the game image.
|
// Fade in the game image.
|
||||||
for (auto& image : mImageComponents) {
|
for (auto& image : mImageComponents) {
|
||||||
if (image->getMetadataField() == "md_image") {
|
if (image->getScrollFadeIn()) {
|
||||||
auto func = [&image](float t) {
|
auto func = [&image](float t) {
|
||||||
image->setOpacity(static_cast<unsigned char>(
|
image->setOpacity(static_cast<unsigned char>(
|
||||||
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
|
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
|
||||||
|
@ -562,7 +559,7 @@ void GamelistView::updateInfoPanel()
|
||||||
|
|
||||||
// Fade in the static image.
|
// Fade in the static image.
|
||||||
for (auto& video : mVideoComponents) {
|
for (auto& video : mVideoComponents) {
|
||||||
if (video->getMetadataField() == "md_video") {
|
if (video->getScrollFadeIn()) {
|
||||||
auto func = [&video](float t) {
|
auto func = [&video](float t) {
|
||||||
video->setOpacity(static_cast<unsigned char>(
|
video->setOpacity(static_cast<unsigned char>(
|
||||||
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
|
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
|
||||||
|
|
|
@ -26,6 +26,7 @@ GuiComponent::GuiComponent()
|
||||||
, mColorShiftEnd {0}
|
, mColorShiftEnd {0}
|
||||||
, mColorOriginalValue {0}
|
, mColorOriginalValue {0}
|
||||||
, mColorChangedValue {0}
|
, mColorChangedValue {0}
|
||||||
|
, mComponentThemeFlags {0}
|
||||||
, mPosition {0.0f, 0.0f, 0.0f}
|
, mPosition {0.0f, 0.0f, 0.0f}
|
||||||
, mOrigin {0.0f, 0.0f}
|
, mOrigin {0.0f, 0.0f}
|
||||||
, mRotationOrigin {0.5f, 0.5f}
|
, mRotationOrigin {0.5f, 0.5f}
|
||||||
|
@ -34,7 +35,6 @@ GuiComponent::GuiComponent()
|
||||||
, mScale {1.0f}
|
, mScale {1.0f}
|
||||||
, mDefaultZIndex {0.0f}
|
, mDefaultZIndex {0.0f}
|
||||||
, mZIndex {0.0f}
|
, mZIndex {0.0f}
|
||||||
, mScrollHide {false}
|
|
||||||
, mIsProcessing {false}
|
, mIsProcessing {false}
|
||||||
, mVisible {true}
|
, mVisible {true}
|
||||||
, mEnabled {true}
|
, mEnabled {true}
|
||||||
|
|
|
@ -112,8 +112,32 @@ public:
|
||||||
const bool isVisible() const { return mVisible; }
|
const bool isVisible() const { return mVisible; }
|
||||||
void setVisible(bool visible) { mVisible = visible; }
|
void setVisible(bool visible) { mVisible = visible; }
|
||||||
|
|
||||||
const bool getScrollHide() { return mScrollHide; }
|
// clang-format off
|
||||||
void setScrollHide(bool state) { mScrollHide = state; }
|
enum ComponentThemeFlags : unsigned int {
|
||||||
|
SCROLL_HIDE = 0x00000001,
|
||||||
|
SCROLL_FADE_IN = 0x00000002
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
const bool getScrollHide() { return mComponentThemeFlags & ComponentThemeFlags::SCROLL_HIDE; }
|
||||||
|
void setScrollHide(bool state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
mComponentThemeFlags |= ComponentThemeFlags::SCROLL_HIDE;
|
||||||
|
else
|
||||||
|
mComponentThemeFlags ^= ComponentThemeFlags::SCROLL_HIDE;
|
||||||
|
}
|
||||||
|
const bool getScrollFadeIn()
|
||||||
|
{
|
||||||
|
return mComponentThemeFlags & ComponentThemeFlags::SCROLL_FADE_IN;
|
||||||
|
}
|
||||||
|
void setScrollFadeIn(bool state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
mComponentThemeFlags |= ComponentThemeFlags::SCROLL_FADE_IN;
|
||||||
|
else
|
||||||
|
mComponentThemeFlags ^= ComponentThemeFlags::SCROLL_FADE_IN;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the center point of the image (takes origin into account).
|
// Returns the center point of the image (takes origin into account).
|
||||||
const glm::vec2 getCenter() const;
|
const glm::vec2 getCenter() const;
|
||||||
|
@ -265,6 +289,7 @@ protected:
|
||||||
unsigned int mColorShiftEnd;
|
unsigned int mColorShiftEnd;
|
||||||
unsigned int mColorOriginalValue;
|
unsigned int mColorOriginalValue;
|
||||||
unsigned int mColorChangedValue;
|
unsigned int mColorChangedValue;
|
||||||
|
unsigned int mComponentThemeFlags;
|
||||||
|
|
||||||
glm::vec3 mPosition;
|
glm::vec3 mPosition;
|
||||||
glm::vec2 mOrigin;
|
glm::vec2 mOrigin;
|
||||||
|
@ -276,7 +301,6 @@ protected:
|
||||||
float mDefaultZIndex;
|
float mDefaultZIndex;
|
||||||
float mZIndex;
|
float mZIndex;
|
||||||
|
|
||||||
bool mScrollHide;
|
|
||||||
bool mIsProcessing;
|
bool mIsProcessing;
|
||||||
bool mVisible;
|
bool mVisible;
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
|
|
|
@ -85,6 +85,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"color", COLOR},
|
{"color", COLOR},
|
||||||
{"colorEnd", COLOR},
|
{"colorEnd", COLOR},
|
||||||
{"gradientType", STRING},
|
{"gradientType", STRING},
|
||||||
|
{"scrollFadeIn", BOOLEAN},
|
||||||
{"visible", BOOLEAN},
|
{"visible", BOOLEAN},
|
||||||
{"zIndex", FLOAT}}},
|
{"zIndex", FLOAT}}},
|
||||||
{"video",
|
{"video",
|
||||||
|
@ -96,8 +97,10 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
{"path", PATH},
|
{"path", PATH},
|
||||||
{"default", PATH},
|
{"default", PATH},
|
||||||
|
{"defaultImage", PATH},
|
||||||
{"imageMetadata", STRING},
|
{"imageMetadata", STRING},
|
||||||
{"delay", FLOAT},
|
{"delay", FLOAT},
|
||||||
|
{"scrollFadeIn", BOOLEAN},
|
||||||
{"visible", BOOLEAN},
|
{"visible", BOOLEAN},
|
||||||
{"zIndex", FLOAT},
|
{"zIndex", FLOAT},
|
||||||
{"showSnapshotNoVideo", BOOLEAN}, // For backward compatibility with legacy themes.
|
{"showSnapshotNoVideo", BOOLEAN}, // For backward compatibility with legacy themes.
|
||||||
|
|
|
@ -516,6 +516,9 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
setColorGradientHorizontal(
|
setColorGradientHorizontal(
|
||||||
!(elem->get<std::string>("gradientType").compare("horizontal")));
|
!(elem->get<std::string>("gradientType").compare("horizontal")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elem->has("scrollFadeIn") && elem->get<bool>("scrollFadeIn"))
|
||||||
|
mComponentThemeFlags |= ComponentThemeFlags::SCROLL_FADE_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<HelpPrompt> ImageComponent::getHelpPrompts()
|
std::vector<HelpPrompt> ImageComponent::getHelpPrompts()
|
||||||
|
|
|
@ -244,6 +244,11 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (elem->has("default"))
|
if (elem->has("default"))
|
||||||
mConfig.defaultVideoPath = elem->get<std::string>("default");
|
mConfig.defaultVideoPath = elem->get<std::string>("default");
|
||||||
|
|
||||||
|
if (elem->has("defaultImage")) {
|
||||||
|
mStaticImage.setDefaultImage(elem->get<std::string>("defaultImage"));
|
||||||
|
mStaticImage.setImage(mStaticImagePath);
|
||||||
|
}
|
||||||
|
|
||||||
if (elem->has("path"))
|
if (elem->has("path"))
|
||||||
mConfig.staticVideoPath = elem->get<std::string>("path");
|
mConfig.staticVideoPath = elem->get<std::string>("path");
|
||||||
|
|
||||||
|
@ -262,6 +267,9 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
|
|
||||||
if (properties & METADATA && elem->has("imageMetadata"))
|
if (properties & METADATA && elem->has("imageMetadata"))
|
||||||
setMetadataField(elem->get<std::string>("imageMetadata"));
|
setMetadataField(elem->get<std::string>("imageMetadata"));
|
||||||
|
|
||||||
|
if (elem->has("scrollFadeIn") && elem->get<bool>("scrollFadeIn"))
|
||||||
|
mComponentThemeFlags |= ComponentThemeFlags::SCROLL_FADE_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<HelpPrompt> VideoComponent::getHelpPrompts()
|
std::vector<HelpPrompt> VideoComponent::getHelpPrompts()
|
||||||
|
|
Loading…
Reference in a new issue