Disabled non-blurred backgrounds when rotating screen 90 or 270 degrees.

This commit is contained in:
Leon Styhre 2023-02-21 18:39:56 +01:00
parent c2790f5c2f
commit b335901ee6
3 changed files with 28 additions and 11 deletions

View file

@ -728,16 +728,29 @@ void GuiMenu::openUIOptions()
// Blur background when the menu is open.
auto menuBlurBackground = std::make_shared<SwitchComponent>();
menuBlurBackground->setState(Settings::getInstance()->getBool("MenuBlurBackground"));
s->addWithLabel("BLUR BACKGROUND WHEN MENU IS OPEN", menuBlurBackground);
s->addSaveFunc([menuBlurBackground, s] {
if (menuBlurBackground->getState() !=
Settings::getInstance()->getBool("MenuBlurBackground")) {
Settings::getInstance()->setBool("MenuBlurBackground", menuBlurBackground->getState());
s->setNeedsSaving();
s->setInvalidateCachedBackground();
}
});
if (mRenderer->getScreenRotation() == 90 || mRenderer->getScreenRotation() == 270) {
// TODO: Add support for non-blurred background when rotating screen 90 or 270 degrees.
menuBlurBackground->setState(true);
s->addWithLabel("BLUR BACKGROUND WHEN MENU IS OPEN", menuBlurBackground);
menuBlurBackground->setEnabled(false);
menuBlurBackground->setOpacity(DISABLED_OPACITY);
menuBlurBackground->getParent()
->getChild(menuBlurBackground->getChildIndex() - 1)
->setOpacity(DISABLED_OPACITY);
}
else {
menuBlurBackground->setState(Settings::getInstance()->getBool("MenuBlurBackground"));
s->addWithLabel("BLUR BACKGROUND WHEN MENU IS OPEN", menuBlurBackground);
s->addSaveFunc([menuBlurBackground, s] {
if (menuBlurBackground->getState() !=
Settings::getInstance()->getBool("MenuBlurBackground")) {
Settings::getInstance()->setBool("MenuBlurBackground",
menuBlurBackground->getState());
s->setNeedsSaving();
s->setInvalidateCachedBackground();
}
});
}
// Display pillarboxes (and letterboxes) for videos in the gamelists.
auto gamelistVideoPillarbox = std::make_shared<SwitchComponent>();

View file

@ -46,6 +46,7 @@ private:
void openOtherOptions();
void openQuitMenu();
Renderer* mRenderer;
MenuComponent mMenu;
TextComponent mVersion;
};

View file

@ -505,7 +505,10 @@ void Window::render()
// of iterations relative to the screen resolution.
Renderer::postProcessingParams backgroundParameters;
if (Settings::getInstance()->getBool("MenuBlurBackground")) {
// TODO: Add support for non-blurred background when rotating screen 90 or 270
// degrees.
if (Settings::getInstance()->getBool("MenuBlurBackground") ||
mRenderer->getScreenRotation() == 90 || mRenderer->getScreenRotation() == 270) {
const float resolutionModifier {mRenderer->getScreenResolutionModifier()};
// clang-format off
if (resolutionModifier < 1)