Elements set as not visible are now completely disabled in SystemView and GamelistView.

This commit is contained in:
Leon Styhre 2023-01-11 18:37:00 +01:00
parent ce08b31352
commit 7ce6cd4c50
3 changed files with 143 additions and 59 deletions

View file

@ -189,32 +189,47 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
mImageComponents.push_back(std::make_unique<ImageComponent>()); mImageComponents.push_back(std::make_unique<ImageComponent>());
mImageComponents.back()->setDefaultZIndex(30.0f); mImageComponents.back()->setDefaultZIndex(30.0f);
mImageComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); mImageComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
if (mImageComponents.back()->getThemeImageTypes().size() != 0) if (mImageComponents.back()->getThemeOpacity() != 0.0f) {
mImageComponents.back()->setScrollHide(true); if (mImageComponents.back()->getThemeImageTypes().size() != 0)
else if (mImageComponents.back()->getMetadataElement()) mImageComponents.back()->setScrollHide(true);
mImageComponents.back()->setScrollHide(true); else if (mImageComponents.back()->getMetadataElement())
addChild(mImageComponents.back().get()); mImageComponents.back()->setScrollHide(true);
addChild(mImageComponents.back().get());
}
else {
mImageComponents.pop_back();
}
} }
else if (element.second.type == "video") { else if (element.second.type == "video") {
if (element.second.has("path")) { if (element.second.has("path")) {
mStaticVideoComponents.push_back(std::make_unique<VideoFFmpegComponent>()); mStaticVideoComponents.push_back(std::make_unique<VideoFFmpegComponent>());
mStaticVideoComponents.back()->setDefaultZIndex(30.0f); mStaticVideoComponents.back()->setDefaultZIndex(30.0f);
addChild(mStaticVideoComponents.back().get());
mStaticVideoComponents.back()->applyTheme(theme, "gamelist", element.first, mStaticVideoComponents.back()->applyTheme(theme, "gamelist", element.first,
ALL); ALL);
if (mStaticVideoComponents.back()->getMetadataElement()) if (mStaticVideoComponents.back()->getThemeOpacity() != 0.0f) {
mStaticVideoComponents.back()->setScrollHide(true); if (mStaticVideoComponents.back()->getMetadataElement())
mStaticVideoComponents.back()->setGeneralFade(true); mStaticVideoComponents.back()->setScrollHide(true);
if (element.second.has("audio")) mStaticVideoComponents.back()->setGeneralFade(true);
mStaticVideoAudio = element.second.get<bool>("audio"); if (element.second.has("audio"))
mStaticVideoAudio = element.second.get<bool>("audio");
addChild(mStaticVideoComponents.back().get());
}
else {
mStaticVideoComponents.pop_back();
}
} }
else { else {
mVideoComponents.push_back(std::make_unique<VideoFFmpegComponent>()); mVideoComponents.push_back(std::make_unique<VideoFFmpegComponent>());
mVideoComponents.back()->setDefaultZIndex(30.0f); mVideoComponents.back()->setDefaultZIndex(30.0f);
addChild(mVideoComponents.back().get());
mVideoComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); mVideoComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
if (mVideoComponents.back()->getThemeImageTypes().size() != 0) if (mVideoComponents.back()->getThemeOpacity() != 0.0f) {
mVideoComponents.back()->setScrollHide(true); if (mVideoComponents.back()->getThemeImageTypes().size() != 0)
mVideoComponents.back()->setScrollHide(true);
addChild(mVideoComponents.back().get());
}
else {
mVideoComponents.pop_back();
}
} }
} }
else if (element.second.type == "animation" && element.second.has("path")) { else if (element.second.type == "animation" && element.second.has("path")) {
@ -224,17 +239,27 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
mLottieAnimComponents.push_back(std::make_unique<LottieAnimComponent>()); mLottieAnimComponents.push_back(std::make_unique<LottieAnimComponent>());
mLottieAnimComponents.back()->setDefaultZIndex(35.0f); mLottieAnimComponents.back()->setDefaultZIndex(35.0f);
mLottieAnimComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); mLottieAnimComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
if (mLottieAnimComponents.back()->getMetadataElement()) if (mLottieAnimComponents.back()->getThemeOpacity() != 0.0f) {
mLottieAnimComponents.back()->setScrollHide(true); if (mLottieAnimComponents.back()->getMetadataElement())
addChild(mLottieAnimComponents.back().get()); mLottieAnimComponents.back()->setScrollHide(true);
addChild(mLottieAnimComponents.back().get());
}
else {
mLottieAnimComponents.pop_back();
}
} }
else if (extension == ".gif") { else if (extension == ".gif") {
mGIFAnimComponents.push_back(std::make_unique<GIFAnimComponent>()); mGIFAnimComponents.push_back(std::make_unique<GIFAnimComponent>());
mGIFAnimComponents.back()->setDefaultZIndex(35.0f); mGIFAnimComponents.back()->setDefaultZIndex(35.0f);
mGIFAnimComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); mGIFAnimComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
if (mGIFAnimComponents.back()->getMetadataElement()) if (mGIFAnimComponents.back()->getThemeOpacity() != 0.0f) {
mGIFAnimComponents.back()->setScrollHide(true); if (mGIFAnimComponents.back()->getMetadataElement())
addChild(mGIFAnimComponents.back().get()); mGIFAnimComponents.back()->setScrollHide(true);
addChild(mGIFAnimComponents.back().get());
}
else {
mGIFAnimComponents.pop_back();
}
} }
else if (extension == ".") { else if (extension == ".") {
LOG(LogWarning) LOG(LogWarning)
@ -252,65 +277,92 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
mBadgeComponents.push_back(std::make_unique<BadgeComponent>()); mBadgeComponents.push_back(std::make_unique<BadgeComponent>());
mBadgeComponents.back()->setDefaultZIndex(35.0f); mBadgeComponents.back()->setDefaultZIndex(35.0f);
mBadgeComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); mBadgeComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
mBadgeComponents.back()->setScrollHide(true); if (mBadgeComponents.back()->getThemeOpacity() != 0.0f) {
addChild(mBadgeComponents.back().get()); mBadgeComponents.back()->setScrollHide(true);
addChild(mBadgeComponents.back().get());
}
else {
mBadgeComponents.pop_back();
}
} }
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")) {
mContainerComponents.push_back(std::make_unique<ScrollableContainer>()); mContainerComponents.push_back(std::make_unique<ScrollableContainer>());
mContainerComponents.back()->setDefaultZIndex(40.0f); mContainerComponents.back()->setDefaultZIndex(40.0f);
addChild(mContainerComponents.back().get());
mContainerTextComponents.push_back(std::make_unique<TextComponent>()); mContainerTextComponents.push_back(std::make_unique<TextComponent>());
mContainerTextComponents.back()->setDefaultZIndex(40.0f); 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);
mContainerComponents.back()->setAutoScroll(true); if (mContainerComponents.back()->getThemeOpacity() != 0.0f) {
mContainerTextComponents.back()->setSize( mContainerComponents.back()->setAutoScroll(true);
mContainerComponents.back()->getSize().x, 0.0f); mContainerTextComponents.back()->setSize(
mContainerTextComponents.back()->applyTheme( mContainerComponents.back()->getSize().x, 0.0f);
theme, "gamelist", element.first, mContainerTextComponents.back()->applyTheme(
ALL ^ POSITION ^ ORIGIN ^ Z_INDEX ^ ThemeFlags::SIZE ^ VISIBLE ^ ROTATION); theme, "gamelist", element.first,
if (mContainerTextComponents.back()->getThemeMetadata() != "") ALL ^ POSITION ^ ORIGIN ^ Z_INDEX ^ ThemeFlags::SIZE ^ VISIBLE ^
mContainerComponents.back()->setScrollHide(true); ROTATION);
else if (mContainerTextComponents.back()->getMetadataElement()) if (mContainerTextComponents.back()->getThemeMetadata() != "")
mContainerComponents.back()->setScrollHide(true); mContainerComponents.back()->setScrollHide(true);
else if (mContainerTextComponents.back()->getMetadataElement())
mContainerComponents.back()->setScrollHide(true);
addChild(mContainerComponents.back().get());
}
else {
mContainerComponents.pop_back();
}
} }
else { else {
mTextComponents.push_back(std::make_unique<TextComponent>()); mTextComponents.push_back(std::make_unique<TextComponent>());
mTextComponents.back()->setDefaultZIndex(40.0f); mTextComponents.back()->setDefaultZIndex(40.0f);
mTextComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); mTextComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
if (mTextComponents.back()->getThemeMetadata() != "") { if (mTextComponents.back()->getThemeOpacity() != 0.0f) {
mTextComponents.back()->setScrollHide(true); if (mTextComponents.back()->getThemeMetadata() != "")
mTextComponents.back()->setScrollHide(true);
else if (mTextComponents.back()->getMetadataElement())
mTextComponents.back()->setScrollHide(true);
addChild(mTextComponents.back().get());
} }
else if (mTextComponents.back()->getMetadataElement()) { else {
mTextComponents.back()->setScrollHide(true); mTextComponents.pop_back();
} }
addChild(mTextComponents.back().get());
} }
} }
else if (element.second.type == "datetime") { else if (element.second.type == "datetime") {
mDateTimeComponents.push_back(std::make_unique<DateTimeComponent>()); mDateTimeComponents.push_back(std::make_unique<DateTimeComponent>());
mDateTimeComponents.back()->setDefaultZIndex(40.0f); mDateTimeComponents.back()->setDefaultZIndex(40.0f);
mDateTimeComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); mDateTimeComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
if (mDateTimeComponents.back()->getThemeMetadata() != "") if (mDateTimeComponents.back()->getThemeOpacity() != 0.0f) {
mDateTimeComponents.back()->setScrollHide(true); if (mDateTimeComponents.back()->getThemeMetadata() != "")
addChild(mDateTimeComponents.back().get()); mDateTimeComponents.back()->setScrollHide(true);
addChild(mDateTimeComponents.back().get());
}
else {
mDateTimeComponents.pop_back();
}
} }
else if (element.second.type == "gamelistinfo") { else if (element.second.type == "gamelistinfo") {
mGamelistInfoComponents.push_back(std::make_unique<TextComponent>()); mGamelistInfoComponents.push_back(std::make_unique<TextComponent>());
mGamelistInfoComponents.back()->setDefaultZIndex(45.0f); mGamelistInfoComponents.back()->setDefaultZIndex(45.0f);
mGamelistInfoComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); mGamelistInfoComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
addChild(mGamelistInfoComponents.back().get()); if (mGamelistInfoComponents.back()->getThemeOpacity() != 0.0f)
addChild(mGamelistInfoComponents.back().get());
else
mGamelistInfoComponents.pop_back();
} }
else if (element.second.type == "rating") { else if (element.second.type == "rating") {
mRatingComponents.push_back(std::make_unique<RatingComponent>()); mRatingComponents.push_back(std::make_unique<RatingComponent>());
mRatingComponents.back()->setDefaultZIndex(45.0f); mRatingComponents.back()->setDefaultZIndex(45.0f);
mRatingComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); mRatingComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
mRatingComponents.back()->setScrollHide(true); if (mRatingComponents.back()->getThemeOpacity() != 0.0f) {
mRatingComponents.back()->setOpacity(mRatingComponents.back()->getOpacity()); mRatingComponents.back()->setScrollHide(true);
addChild(mRatingComponents.back().get()); mRatingComponents.back()->setOpacity(mRatingComponents.back()->getOpacity());
addChild(mRatingComponents.back().get());
}
else {
mRatingComponents.pop_back();
}
} }
} }

View file

@ -604,7 +604,10 @@ void SystemView::populate()
elements.imageComponents.back()->setDefaultZIndex(30.0f); elements.imageComponents.back()->setDefaultZIndex(30.0f);
elements.imageComponents.back()->applyTheme(theme, "system", element.first, elements.imageComponents.back()->applyTheme(theme, "system", element.first,
ThemeFlags::ALL); ThemeFlags::ALL);
elements.children.emplace_back(elements.imageComponents.back().get()); if (elements.imageComponents.back()->getThemeOpacity() != 0.0f)
elements.children.emplace_back(elements.imageComponents.back().get());
else
elements.imageComponents.pop_back();
} }
else if (element.second.type == "video") { else if (element.second.type == "video") {
elements.videoComponents.emplace_back( elements.videoComponents.emplace_back(
@ -613,7 +616,10 @@ void SystemView::populate()
elements.videoComponents.back()->setStaticVideo(); elements.videoComponents.back()->setStaticVideo();
elements.videoComponents.back()->applyTheme(theme, "system", element.first, elements.videoComponents.back()->applyTheme(theme, "system", element.first,
ThemeFlags::ALL); ThemeFlags::ALL);
elements.children.emplace_back(elements.videoComponents.back().get()); if (elements.videoComponents.back()->getThemeOpacity() != 0.0f)
elements.children.emplace_back(elements.videoComponents.back().get());
else
elements.videoComponents.pop_back();
} }
else if (element.second.type == "animation" && element.second.has("path")) { else if (element.second.type == "animation" && element.second.has("path")) {
const std::string extension {Utils::FileSystem::getExtension( const std::string extension {Utils::FileSystem::getExtension(
@ -624,8 +630,11 @@ void SystemView::populate()
elements.lottieAnimComponents.back()->setDefaultZIndex(35.0f); elements.lottieAnimComponents.back()->setDefaultZIndex(35.0f);
elements.lottieAnimComponents.back()->applyTheme( elements.lottieAnimComponents.back()->applyTheme(
theme, "system", element.first, ThemeFlags::ALL); theme, "system", element.first, ThemeFlags::ALL);
elements.children.emplace_back( if (elements.lottieAnimComponents.back()->getThemeOpacity() != 0.0f)
elements.lottieAnimComponents.back().get()); elements.children.emplace_back(
elements.lottieAnimComponents.back().get());
else
elements.lottieAnimComponents.pop_back();
} }
else if (extension == ".gif") { else if (extension == ".gif") {
elements.GIFAnimComponents.emplace_back( elements.GIFAnimComponents.emplace_back(
@ -633,7 +642,11 @@ void SystemView::populate()
elements.GIFAnimComponents.back()->setDefaultZIndex(35.0f); elements.GIFAnimComponents.back()->setDefaultZIndex(35.0f);
elements.GIFAnimComponents.back()->applyTheme( elements.GIFAnimComponents.back()->applyTheme(
theme, "system", element.first, ThemeFlags::ALL); theme, "system", element.first, ThemeFlags::ALL);
elements.children.emplace_back(elements.GIFAnimComponents.back().get()); if (elements.GIFAnimComponents.back()->getThemeOpacity() != 0.0f)
elements.children.emplace_back(
elements.GIFAnimComponents.back().get());
else
elements.GIFAnimComponents.pop_back();
} }
else if (extension == ".") { else if (extension == ".") {
LOG(LogWarning) LOG(LogWarning)
@ -657,8 +670,11 @@ void SystemView::populate()
elements.gameCountComponents.back()->setDefaultZIndex(40.0f); elements.gameCountComponents.back()->setDefaultZIndex(40.0f);
elements.gameCountComponents.back()->applyTheme( elements.gameCountComponents.back()->applyTheme(
theme, "system", element.first, ThemeFlags::ALL); theme, "system", element.first, ThemeFlags::ALL);
elements.children.emplace_back( if (elements.gameCountComponents.back()->getThemeOpacity() != 0.0f)
elements.gameCountComponents.back().get()); elements.children.emplace_back(
elements.gameCountComponents.back().get());
else
elements.gameCountComponents.pop_back();
} }
} }
else { else {
@ -666,7 +682,11 @@ void SystemView::populate()
elements.textComponents.back()->setDefaultZIndex(40.0f); elements.textComponents.back()->setDefaultZIndex(40.0f);
elements.textComponents.back()->applyTheme( elements.textComponents.back()->applyTheme(
theme, "system", element.first, ThemeFlags::ALL); theme, "system", element.first, ThemeFlags::ALL);
elements.children.emplace_back(elements.textComponents.back().get()); if (elements.textComponents.back()->getThemeOpacity() != 0.0f)
elements.children.emplace_back(
elements.textComponents.back().get());
else
elements.textComponents.pop_back();
} }
} }
else if (element.second.type == "datetime") { else if (element.second.type == "datetime") {
@ -675,18 +695,29 @@ void SystemView::populate()
elements.dateTimeComponents.back()->setDefaultZIndex(40.0f); elements.dateTimeComponents.back()->setDefaultZIndex(40.0f);
elements.dateTimeComponents.back()->applyTheme( elements.dateTimeComponents.back()->applyTheme(
theme, "system", element.first, ThemeFlags::ALL); theme, "system", element.first, ThemeFlags::ALL);
elements.dateTimeComponents.back()->setVisible(false); if (elements.dateTimeComponents.back()->getThemeOpacity() != 0.0f) {
elements.children.emplace_back(elements.dateTimeComponents.back().get()); elements.dateTimeComponents.back()->setVisible(false);
elements.children.emplace_back(
elements.dateTimeComponents.back().get());
}
else {
elements.dateTimeComponents.pop_back();
}
} }
else if (element.second.type == "rating") { else if (element.second.type == "rating") {
elements.ratingComponents.emplace_back(std::make_unique<RatingComponent>()); elements.ratingComponents.emplace_back(std::make_unique<RatingComponent>());
elements.ratingComponents.back()->setDefaultZIndex(45.0f); elements.ratingComponents.back()->setDefaultZIndex(45.0f);
elements.ratingComponents.back()->applyTheme(theme, "system", element.first, elements.ratingComponents.back()->applyTheme(theme, "system", element.first,
ThemeFlags::ALL); ThemeFlags::ALL);
elements.ratingComponents.back()->setVisible(false); if (elements.ratingComponents.back()->getThemeOpacity() != 0.0f) {
elements.ratingComponents.back()->setOpacity( elements.ratingComponents.back()->setVisible(false);
elements.ratingComponents.back()->getOpacity()); elements.ratingComponents.back()->setOpacity(
elements.children.emplace_back(elements.ratingComponents.back().get()); elements.ratingComponents.back()->getOpacity());
elements.children.emplace_back(elements.ratingComponents.back().get());
}
else {
elements.ratingComponents.pop_back();
}
} }
} }
} }

View file

@ -277,6 +277,7 @@ public:
const std::string& getThemeGameSelector() const { return mThemeGameSelector; } const std::string& getThemeGameSelector() const { return mThemeGameSelector; }
const unsigned int getThemeGameSelectorEntry() const { return mThemeGameSelectorEntry; } const unsigned int getThemeGameSelectorEntry() const { return mThemeGameSelectorEntry; }
virtual const std::string getDefaultImage() const { return ""; } virtual const std::string getDefaultImage() const { return ""; }
const float getThemeOpacity() const { return mThemeOpacity; }
virtual std::shared_ptr<Font> getFont() const { return nullptr; } virtual std::shared_ptr<Font> getFont() const { return nullptr; }