Added a 'renderDuringTransitions' property to the image element

This commit is contained in:
Leon Styhre 2023-12-18 01:16:32 +01:00
parent 183862d974
commit 3abd8d9035
6 changed files with 59 additions and 7 deletions

View file

@ -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<ViewTransitionAnimation>(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);
}
}

View file

@ -1476,10 +1476,33 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
glm::ivec2 {static_cast<int>(mSize.x), static_cast<int>(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<ViewTransitionAnimation>(
Settings::getInstance()->getInt("TransitionsSystemToGamelist")) !=
ViewTransitionAnimation::SLIDE &&
viewState.viewing == ViewController::ViewMode::GAMELIST)
renderChild = true;
if (renderChild)
child->render(trans);
}
};
clipRectFunc();
if (mSystemElements.size() > static_cast<size_t>(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);
}
}
}

View file

@ -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}

View file

@ -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;

View file

@ -275,6 +275,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"rotation", FLOAT},
{"rotationOrigin", NORMALIZED_PAIR},
{"stationary", STRING},
{"renderDuringTransitions", BOOLEAN},
{"flipHorizontal", BOOLEAN},
{"flipVertical", BOOLEAN},
{"path", PATH},

View file

@ -557,6 +557,9 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
<< element.substr(6) << "\" defined as \"" << stationary << "\"";
}
if (elem->has("renderDuringTransitions"))
mRenderDuringTransitions = elem->get<bool>("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<float>("rotation"))};