From 3abd8d9035fd20080dd2b4509943b0353ed8fdfb Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 18 Dec 2023 01:16:32 +0100 Subject: [PATCH] Added a 'renderDuringTransitions' property to the image element --- es-app/src/views/GamelistView.cpp | 26 ++++++++++++++++-- es-app/src/views/SystemView.cpp | 33 +++++++++++++++++++---- es-core/src/GuiComponent.cpp | 1 + es-core/src/GuiComponent.h | 2 ++ es-core/src/ThemeData.cpp | 1 + es-core/src/components/ImageComponent.cpp | 3 +++ 6 files changed, 59 insertions(+), 7 deletions(-) diff --git a/es-app/src/views/GamelistView.cpp b/es-app/src/views/GamelistView.cpp index c1784a376..962e69c87 100644 --- a/es-app/src/views/GamelistView.cpp +++ b/es-app/src/views/GamelistView.cpp @@ -416,6 +416,28 @@ void GamelistView::render(const glm::mat4& parentTrans) const ViewController::State viewState {ViewController::getInstance()->getState()}; bool stationaryApplicable {false}; + auto renderChildFunc = [this, &viewState](int i, glm::mat4 trans) { + if (getChild(i)->getRenderDuringTransitions()) { + getChild(i)->render(trans); + } + else { + bool renderChild {false}; + if (!ViewController::getInstance()->isCameraMoving()) + renderChild = true; + else if (viewState.previouslyViewed == ViewController::ViewMode::NOTHING) + renderChild = true; + else if (viewState.viewing == viewState.previouslyViewed) + renderChild = true; + else if (static_cast(Settings::getInstance()->getInt( + "TransitionsGamelistToSystem")) != ViewTransitionAnimation::SLIDE && + viewState.viewing == ViewController::ViewMode::SYSTEM_SELECT) + renderChild = true; + + if (renderChild) + getChild(i)->render(trans); + } + }; + // If it's the startup animation, then don't apply stationary properties. if (viewState.previouslyViewed == ViewController::ViewMode::NOTHING) stationaryApplicable = false; @@ -467,11 +489,11 @@ void GamelistView::render(const glm::mat4& parentTrans) if (viewState.getSystem() != mRoot->getSystem()) continue; mRenderer->popClipRect(); - getChild(i)->render(mRenderer->getIdentity()); + renderChildFunc(i, mRenderer->getIdentity()); clipRectFunc(); } else { - getChild(i)->render(trans); + renderChildFunc(i, trans); } } diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 789077a63..e54c7263b 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -1476,10 +1476,33 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary) glm::ivec2 {static_cast(mSize.x), static_cast(mSize.y)}); }; + auto renderChildFunc = [this, &viewState](GuiComponent* child, glm::mat4 trans) { + if (child->getRenderDuringTransitions()) { + child->render(trans); + } + else { + bool renderChild {false}; + if (!ViewController::getInstance()->isCameraMoving()) + renderChild = true; + else if (viewState.previouslyViewed == ViewController::ViewMode::NOTHING) + renderChild = true; + else if (viewState.viewing == viewState.previouslyViewed) + renderChild = true; + else if (static_cast( + Settings::getInstance()->getInt("TransitionsSystemToGamelist")) != + ViewTransitionAnimation::SLIDE && + viewState.viewing == ViewController::ViewMode::GAMELIST) + renderChild = true; + + if (renderChild) + child->render(trans); + } + }; + clipRectFunc(); if (mSystemElements.size() > static_cast(index)) { - for (auto child : mSystemElements[index].children) { + for (GuiComponent* child : mSystemElements[index].children) { bool renderChild {true}; bool childStationary {false}; if (stationaryApplicable) { @@ -1520,11 +1543,11 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary) if (renderChild) { if (childStationary) { mRenderer->popClipRect(); - child->render(mRenderer->getIdentity()); + renderChildFunc(child, mRenderer->getIdentity()); clipRectFunc(); } else { - child->render(elementTrans); + renderChildFunc(child, elementTrans); } } } @@ -1534,11 +1557,11 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary) if (renderChild) { if (childStationary) { mRenderer->popClipRect(); - child->render(mRenderer->getIdentity()); + renderChildFunc(child, mRenderer->getIdentity()); clipRectFunc(); } else { - child->render(elementTrans); + renderChildFunc(child, elementTrans); } } } diff --git a/es-core/src/GuiComponent.cpp b/es-core/src/GuiComponent.cpp index 9673ab874..6f36be539 100644 --- a/es-core/src/GuiComponent.cpp +++ b/es-core/src/GuiComponent.cpp @@ -31,6 +31,7 @@ GuiComponent::GuiComponent() , mRotationOrigin {0.5f, 0.5f} , mSize {0.0f, 0.0f} , mStationary {Stationary::NEVER} + , mRenderDuringTransitions {true} , mBrightness {0.0f} , mOpacity {1.0f} , mSaturation {1.0f} diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index bf83c26b0..261c25fa4 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -117,6 +117,7 @@ public: void setRotationOrigin(glm::vec2 origin) { setRotationOrigin(origin.x, origin.y); } const Stationary getStationary() const { return mStationary; } + const bool getRenderDuringTransitions() const { return mRenderDuringTransitions; } virtual glm::vec2 getSize() const { return mSize; } void setSize(const glm::vec2& size) { setSize(size.x, size.y); } @@ -400,6 +401,7 @@ protected: glm::vec2 mRotationOrigin; glm::vec2 mSize; Stationary mStationary; + bool mRenderDuringTransitions; float mBrightness; float mOpacity; diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 45d248cc1..2e4ef0d62 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -275,6 +275,7 @@ std::map> {"rotation", FLOAT}, {"rotationOrigin", NORMALIZED_PAIR}, {"stationary", STRING}, + {"renderDuringTransitions", BOOLEAN}, {"flipHorizontal", BOOLEAN}, {"flipVertical", BOOLEAN}, {"path", PATH}, diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index c48f5de10..37f59a7e0 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -557,6 +557,9 @@ void ImageComponent::applyTheme(const std::shared_ptr& theme, << element.substr(6) << "\" defined as \"" << stationary << "\""; } + if (elem->has("renderDuringTransitions")) + mRenderDuringTransitions = elem->get("renderDuringTransitions"); + // Enable linear interpolation by default if element is arbitrarily rotated. if (properties & ThemeFlags::ROTATION && elem->has("rotation")) { const float rotation {std::abs(elem->get("rotation"))};