Added a fadeAbovePrimary property to control whether elements above the system view carousel and textlist should be rendered during fade transitions.

This commit is contained in:
Leon Styhre 2022-09-26 20:02:31 +02:00
parent 577ed366b4
commit 06fd76abc3
5 changed files with 36 additions and 14 deletions

View file

@ -169,12 +169,12 @@ void SystemView::render(const glm::mat4& parentTrans)
if (mPrimary == nullptr)
return; // Nothing to render.
bool fade {false};
bool transitionFade {false};
if (mNavigated && mMaxFade)
fade = true;
transitionFade = true;
if (!fade)
if (!transitionFade)
renderElements(parentTrans, false);
glm::mat4 trans {getTransform() * parentTrans};
@ -187,7 +187,7 @@ void SystemView::render(const glm::mat4& parentTrans)
mPrimary->render(trans);
mRenderer->popClipRect();
if (!fade || mLegacyMode)
if (!mPrimary->getFadeAbovePrimary() || !transitionFade)
renderElements(parentTrans, true);
}
@ -1258,22 +1258,29 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
if ((mFadeTransitions || element->getDimming() != 1.0f) &&
element->getZIndex() < primaryZIndex)
element->setDimming(1.0f - mFadeOpacity);
if (mFadeTransitions && isAnimationPlaying(0))
element->setOpacity(1.0f - mFadeOpacity);
else
element->setOpacity(1.0f);
if (mFadeTransitions && mNavigated && mMaxFade)
continue;
if (mFadeTransitions && mPrimary->getFadeAbovePrimary()) {
if (mFadeTransitions && isAnimationPlaying(0))
element->setOpacity(1.0f - mFadeOpacity);
else
element->setOpacity(1.0f);
}
element->render(elementTrans);
}
}
else if (!mLegacyMode && mSystemElements.size() > static_cast<size_t>(index)) {
for (auto child : mSystemElements[index].children) {
if (abovePrimary && child->getZIndex() > primaryZIndex) {
if (mFadeTransitions || child->getOpacity() != 1.0f)
child->setOpacity(1.0f - mFadeOpacity);
if (abovePrimary && (child->getZIndex() > primaryZIndex)) {
if (mFadeTransitions && mPrimary->getFadeAbovePrimary()) {
if (mFadeTransitions || child->getOpacity() != 1.0f)
child->setOpacity(1.0f - mFadeOpacity);
}
else {
child->setOpacity(1.0f);
}
child->render(elementTrans);
}
else if (!abovePrimary && child->getZIndex() <= primaryZIndex) {
if (mFadeTransitions || child->getDimming() != 1.0f)
child->setDimming(1.0f - mFadeOpacity);

View file

@ -299,6 +299,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"fontSize", FLOAT},
{"letterCase", STRING},
{"lineSpacing", FLOAT},
{"fadeAbovePrimary", BOOLEAN},
{"zIndex", FLOAT},
{"legacyZIndexMode", STRING}}}, // For backward compatibility with legacy themes.
{"textlist",
@ -326,6 +327,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"lineSpacing", FLOAT},
{"indicators", STRING},
{"collectionIndicators", STRING},
{"fadeAbovePrimary", BOOLEAN},
{"zIndex", FLOAT}}},
{"gameselector",
{{"selection", STRING},

View file

@ -104,6 +104,7 @@ private:
int getCursor() override { return mCursor; }
const size_t getNumEntries() override { return mEntries.size(); }
const bool getFadeAbovePrimary() const override { return mFadeAbovePrimary; }
Renderer* mRenderer;
std::function<void(CursorState state)> mCursorChangedCallback;
@ -139,6 +140,7 @@ private:
bool mLinearInterpolation;
bool mInstantItemTransitions;
bool mItemAxisHorizontal;
bool mFadeAbovePrimary;
float mItemScale;
float mItemRotation;
glm::vec2 mItemRotationOrigin;
@ -185,6 +187,7 @@ CarouselComponent<T>::CarouselComponent()
, mLinearInterpolation {false}
, mInstantItemTransitions {false}
, mItemAxisHorizontal {false}
, mFadeAbovePrimary {false}
, mItemScale {1.2f}
, mItemRotation {7.5f}
, mItemRotationOrigin {-3.0f, 0.5f}
@ -1244,6 +1247,9 @@ void CarouselComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
}
}
if (elem->has("fadeAbovePrimary"))
mFadeAbovePrimary = elem->get<bool>("fadeAbovePrimary");
GuiComponent::applyTheme(theme, view, element, ALL);
mSize.x = glm::clamp(mSize.x, mRenderer->getScreenWidth() * 0.05f,

View file

@ -42,6 +42,7 @@ public:
virtual void setCursorChangedCallback(const std::function<void(CursorState state)>& func) = 0;
virtual int getCursor() = 0;
virtual const size_t getNumEntries() = 0;
virtual const bool getFadeAbovePrimary() const = 0;
// Functions used by some primary components.
virtual void onDemandTextureLoad() {}

View file

@ -146,6 +146,7 @@ private:
int getCursor() override { return mCursor; }
const size_t getNumEntries() override { return mEntries.size(); }
const bool getFadeAbovePrimary() const override { return mFadeAbovePrimary; }
Renderer* mRenderer;
std::function<void()> mCancelTransitionsCallback;
@ -167,6 +168,7 @@ private:
std::string mIndicators;
std::string mCollectionIndicators;
bool mLegacyMode;
bool mFadeAbovePrimary;
bool mUppercase;
bool mLowercase;
bool mCapitalize;
@ -199,6 +201,7 @@ TextListComponent<T>::TextListComponent()
, mIndicators {"symbols"}
, mCollectionIndicators {"symbols"}
, mLegacyMode {false}
, mFadeAbovePrimary {false}
, mUppercase {false}
, mLowercase {false}
, mCapitalize {false}
@ -657,7 +660,7 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
if (elem->has("selectorImagePath")) {
std::string path {elem->get<std::string>("selectorImagePath")};
bool tile = elem->has("selectorImageTile") && elem->get<bool>("selectorImageTile");
bool tile {elem->has("selectorImageTile") && elem->get<bool>("selectorImageTile")};
mSelectorImage.setImage(path, tile);
mSelectorImage.setSize(mSize.x, mSelectorHeight);
mSelectorImage.setResize(mSize.x, mSelectorHeight);
@ -667,6 +670,9 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
else {
mSelectorImage.setImage("");
}
if (elem->has("fadeAbovePrimary"))
mFadeAbovePrimary = elem->get<bool>("fadeAbovePrimary");
}
template <typename T> void TextListComponent<T>::onCursorChanged(const CursorState& state)