diff --git a/es-app/src/views/GamelistView.cpp b/es-app/src/views/GamelistView.cpp index 110217586..32305a60e 100644 --- a/es-app/src/views/GamelistView.cpp +++ b/es-app/src/views/GamelistView.cpp @@ -189,32 +189,47 @@ void GamelistView::onThemeChanged(const std::shared_ptr& theme) mImageComponents.push_back(std::make_unique()); mImageComponents.back()->setDefaultZIndex(30.0f); mImageComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); - if (mImageComponents.back()->getThemeImageTypes().size() != 0) - mImageComponents.back()->setScrollHide(true); - else if (mImageComponents.back()->getMetadataElement()) - mImageComponents.back()->setScrollHide(true); - addChild(mImageComponents.back().get()); + if (mImageComponents.back()->getThemeOpacity() != 0.0f) { + if (mImageComponents.back()->getThemeImageTypes().size() != 0) + mImageComponents.back()->setScrollHide(true); + else if (mImageComponents.back()->getMetadataElement()) + mImageComponents.back()->setScrollHide(true); + addChild(mImageComponents.back().get()); + } + else { + mImageComponents.pop_back(); + } } else if (element.second.type == "video") { if (element.second.has("path")) { mStaticVideoComponents.push_back(std::make_unique()); mStaticVideoComponents.back()->setDefaultZIndex(30.0f); - addChild(mStaticVideoComponents.back().get()); mStaticVideoComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); - if (mStaticVideoComponents.back()->getMetadataElement()) - mStaticVideoComponents.back()->setScrollHide(true); - mStaticVideoComponents.back()->setGeneralFade(true); - if (element.second.has("audio")) - mStaticVideoAudio = element.second.get("audio"); + if (mStaticVideoComponents.back()->getThemeOpacity() != 0.0f) { + if (mStaticVideoComponents.back()->getMetadataElement()) + mStaticVideoComponents.back()->setScrollHide(true); + mStaticVideoComponents.back()->setGeneralFade(true); + if (element.second.has("audio")) + mStaticVideoAudio = element.second.get("audio"); + addChild(mStaticVideoComponents.back().get()); + } + else { + mStaticVideoComponents.pop_back(); + } } else { mVideoComponents.push_back(std::make_unique()); mVideoComponents.back()->setDefaultZIndex(30.0f); - addChild(mVideoComponents.back().get()); mVideoComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); - if (mVideoComponents.back()->getThemeImageTypes().size() != 0) - mVideoComponents.back()->setScrollHide(true); + if (mVideoComponents.back()->getThemeOpacity() != 0.0f) { + 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")) { @@ -224,17 +239,27 @@ void GamelistView::onThemeChanged(const std::shared_ptr& theme) mLottieAnimComponents.push_back(std::make_unique()); mLottieAnimComponents.back()->setDefaultZIndex(35.0f); mLottieAnimComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); - if (mLottieAnimComponents.back()->getMetadataElement()) - mLottieAnimComponents.back()->setScrollHide(true); - addChild(mLottieAnimComponents.back().get()); + if (mLottieAnimComponents.back()->getThemeOpacity() != 0.0f) { + if (mLottieAnimComponents.back()->getMetadataElement()) + mLottieAnimComponents.back()->setScrollHide(true); + addChild(mLottieAnimComponents.back().get()); + } + else { + mLottieAnimComponents.pop_back(); + } } else if (extension == ".gif") { mGIFAnimComponents.push_back(std::make_unique()); mGIFAnimComponents.back()->setDefaultZIndex(35.0f); mGIFAnimComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); - if (mGIFAnimComponents.back()->getMetadataElement()) - mGIFAnimComponents.back()->setScrollHide(true); - addChild(mGIFAnimComponents.back().get()); + if (mGIFAnimComponents.back()->getThemeOpacity() != 0.0f) { + if (mGIFAnimComponents.back()->getMetadataElement()) + mGIFAnimComponents.back()->setScrollHide(true); + addChild(mGIFAnimComponents.back().get()); + } + else { + mGIFAnimComponents.pop_back(); + } } else if (extension == ".") { LOG(LogWarning) @@ -252,65 +277,92 @@ void GamelistView::onThemeChanged(const std::shared_ptr& theme) mBadgeComponents.push_back(std::make_unique()); mBadgeComponents.back()->setDefaultZIndex(35.0f); mBadgeComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); - mBadgeComponents.back()->setScrollHide(true); - addChild(mBadgeComponents.back().get()); + if (mBadgeComponents.back()->getThemeOpacity() != 0.0f) { + mBadgeComponents.back()->setScrollHide(true); + addChild(mBadgeComponents.back().get()); + } + else { + mBadgeComponents.pop_back(); + } } else if (element.second.type == "text") { if (element.second.has("container") && element.second.get("container")) { mContainerComponents.push_back(std::make_unique()); mContainerComponents.back()->setDefaultZIndex(40.0f); - addChild(mContainerComponents.back().get()); mContainerTextComponents.push_back(std::make_unique()); mContainerTextComponents.back()->setDefaultZIndex(40.0f); mContainerComponents.back()->addChild(mContainerTextComponents.back().get()); 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 ^ ORIGIN ^ Z_INDEX ^ ThemeFlags::SIZE ^ VISIBLE ^ ROTATION); - if (mContainerTextComponents.back()->getThemeMetadata() != "") - mContainerComponents.back()->setScrollHide(true); - else if (mContainerTextComponents.back()->getMetadataElement()) - mContainerComponents.back()->setScrollHide(true); + if (mContainerComponents.back()->getThemeOpacity() != 0.0f) { + mContainerComponents.back()->setAutoScroll(true); + mContainerTextComponents.back()->setSize( + mContainerComponents.back()->getSize().x, 0.0f); + mContainerTextComponents.back()->applyTheme( + theme, "gamelist", element.first, + ALL ^ POSITION ^ ORIGIN ^ Z_INDEX ^ ThemeFlags::SIZE ^ VISIBLE ^ + ROTATION); + if (mContainerTextComponents.back()->getThemeMetadata() != "") + mContainerComponents.back()->setScrollHide(true); + else if (mContainerTextComponents.back()->getMetadataElement()) + mContainerComponents.back()->setScrollHide(true); + addChild(mContainerComponents.back().get()); + } + else { + mContainerComponents.pop_back(); + } } else { mTextComponents.push_back(std::make_unique()); mTextComponents.back()->setDefaultZIndex(40.0f); mTextComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); - if (mTextComponents.back()->getThemeMetadata() != "") { - mTextComponents.back()->setScrollHide(true); + if (mTextComponents.back()->getThemeOpacity() != 0.0f) { + 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()) { - mTextComponents.back()->setScrollHide(true); + else { + mTextComponents.pop_back(); } - addChild(mTextComponents.back().get()); } } else if (element.second.type == "datetime") { mDateTimeComponents.push_back(std::make_unique()); mDateTimeComponents.back()->setDefaultZIndex(40.0f); mDateTimeComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); - if (mDateTimeComponents.back()->getThemeMetadata() != "") - mDateTimeComponents.back()->setScrollHide(true); - addChild(mDateTimeComponents.back().get()); + if (mDateTimeComponents.back()->getThemeOpacity() != 0.0f) { + if (mDateTimeComponents.back()->getThemeMetadata() != "") + mDateTimeComponents.back()->setScrollHide(true); + addChild(mDateTimeComponents.back().get()); + } + else { + mDateTimeComponents.pop_back(); + } } else if (element.second.type == "gamelistinfo") { mGamelistInfoComponents.push_back(std::make_unique()); mGamelistInfoComponents.back()->setDefaultZIndex(45.0f); 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") { mRatingComponents.push_back(std::make_unique()); mRatingComponents.back()->setDefaultZIndex(45.0f); mRatingComponents.back()->applyTheme(theme, "gamelist", element.first, ALL); - mRatingComponents.back()->setScrollHide(true); - mRatingComponents.back()->setOpacity(mRatingComponents.back()->getOpacity()); - addChild(mRatingComponents.back().get()); + if (mRatingComponents.back()->getThemeOpacity() != 0.0f) { + mRatingComponents.back()->setScrollHide(true); + mRatingComponents.back()->setOpacity(mRatingComponents.back()->getOpacity()); + addChild(mRatingComponents.back().get()); + } + else { + mRatingComponents.pop_back(); + } } } diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 7f7b795a7..c4d93b11a 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -604,7 +604,10 @@ void SystemView::populate() elements.imageComponents.back()->setDefaultZIndex(30.0f); elements.imageComponents.back()->applyTheme(theme, "system", element.first, 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") { elements.videoComponents.emplace_back( @@ -613,7 +616,10 @@ void SystemView::populate() elements.videoComponents.back()->setStaticVideo(); elements.videoComponents.back()->applyTheme(theme, "system", element.first, 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")) { const std::string extension {Utils::FileSystem::getExtension( @@ -624,8 +630,11 @@ void SystemView::populate() elements.lottieAnimComponents.back()->setDefaultZIndex(35.0f); elements.lottieAnimComponents.back()->applyTheme( theme, "system", element.first, ThemeFlags::ALL); - elements.children.emplace_back( - elements.lottieAnimComponents.back().get()); + if (elements.lottieAnimComponents.back()->getThemeOpacity() != 0.0f) + elements.children.emplace_back( + elements.lottieAnimComponents.back().get()); + else + elements.lottieAnimComponents.pop_back(); } else if (extension == ".gif") { elements.GIFAnimComponents.emplace_back( @@ -633,7 +642,11 @@ void SystemView::populate() elements.GIFAnimComponents.back()->setDefaultZIndex(35.0f); elements.GIFAnimComponents.back()->applyTheme( 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 == ".") { LOG(LogWarning) @@ -657,8 +670,11 @@ void SystemView::populate() elements.gameCountComponents.back()->setDefaultZIndex(40.0f); elements.gameCountComponents.back()->applyTheme( theme, "system", element.first, ThemeFlags::ALL); - elements.children.emplace_back( - elements.gameCountComponents.back().get()); + if (elements.gameCountComponents.back()->getThemeOpacity() != 0.0f) + elements.children.emplace_back( + elements.gameCountComponents.back().get()); + else + elements.gameCountComponents.pop_back(); } } else { @@ -666,7 +682,11 @@ void SystemView::populate() elements.textComponents.back()->setDefaultZIndex(40.0f); elements.textComponents.back()->applyTheme( 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") { @@ -675,18 +695,29 @@ void SystemView::populate() elements.dateTimeComponents.back()->setDefaultZIndex(40.0f); elements.dateTimeComponents.back()->applyTheme( theme, "system", element.first, ThemeFlags::ALL); - elements.dateTimeComponents.back()->setVisible(false); - elements.children.emplace_back(elements.dateTimeComponents.back().get()); + if (elements.dateTimeComponents.back()->getThemeOpacity() != 0.0f) { + elements.dateTimeComponents.back()->setVisible(false); + elements.children.emplace_back( + elements.dateTimeComponents.back().get()); + } + else { + elements.dateTimeComponents.pop_back(); + } } else if (element.second.type == "rating") { elements.ratingComponents.emplace_back(std::make_unique()); elements.ratingComponents.back()->setDefaultZIndex(45.0f); elements.ratingComponents.back()->applyTheme(theme, "system", element.first, ThemeFlags::ALL); - elements.ratingComponents.back()->setVisible(false); - elements.ratingComponents.back()->setOpacity( - elements.ratingComponents.back()->getOpacity()); - elements.children.emplace_back(elements.ratingComponents.back().get()); + if (elements.ratingComponents.back()->getThemeOpacity() != 0.0f) { + elements.ratingComponents.back()->setVisible(false); + elements.ratingComponents.back()->setOpacity( + elements.ratingComponents.back()->getOpacity()); + elements.children.emplace_back(elements.ratingComponents.back().get()); + } + else { + elements.ratingComponents.pop_back(); + } } } } diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index 02bcc8d67..fe1afcde5 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -277,6 +277,7 @@ public: const std::string& getThemeGameSelector() const { return mThemeGameSelector; } const unsigned int getThemeGameSelectorEntry() const { return mThemeGameSelectorEntry; } virtual const std::string getDefaultImage() const { return ""; } + const float getThemeOpacity() const { return mThemeOpacity; } virtual std::shared_ptr getFont() const { return nullptr; }