diff --git a/desktop/api.cpp b/desktop/api.cpp index 66d3b83..311e57c 100644 --- a/desktop/api.cpp +++ b/desktop/api.cpp @@ -91,6 +91,7 @@ struct GlobalData { volatile bool showCursorShadow; volatile bool useSmartQuotes; volatile bool enableHoverState; + volatile float animationTimeMultiplier; }; struct ThreadLocalStorage { diff --git a/desktop/gui.cpp b/desktop/gui.cpp index a8128af..c1db1b7 100644 --- a/desktop/gui.cpp +++ b/desktop/gui.cpp @@ -1288,7 +1288,7 @@ void UIDrawTransitionEffect(EsPainter *painter, EsPaintTarget *sourceSurface, Es } void EsElementStartTransition(EsElement *element, EsTransitionType transitionType, uint32_t flags, float timeMultiplier) { - uint32_t durationMs = timeMultiplier * GetConstantNumber("transitionTime"); + uint32_t durationMs = timeMultiplier * GetConstantNumber("transitionTime") * api.global->animationTimeMultiplier; if (!durationMs) { return; @@ -1779,7 +1779,7 @@ void EsElement::RefreshStyle(UIStyleKey *_oldStyleKey, bool alreadyRefreshStyleS } if (oldStyle) { - if (oldStyle->style == currentStyle->style) { + if (oldStyle->style == currentStyle->style && api.global->animationTimeMultiplier > 0.01f) { ThemeAnimationBuild(&animation, oldStyle, oldStyleKey.stateFlags, currentStyleKey.stateFlags); animate = !ThemeAnimationComplete(&animation); } else { @@ -3462,7 +3462,7 @@ void EsPanelSwitchTo(EsPanel *panel, EsElement *targetChild, EsTransitionType tr EsMessageMutexCheck(); EsAssert(targetChild->parent == panel); EsAssert(panel->flags & ES_PANEL_SWITCHER); // Cannot switch element for a non-switcher panel. - uint32_t timeMs = timeMultiplier * GetConstantNumber("transitionTime"); + uint32_t timeMs = timeMultiplier * GetConstantNumber("transitionTime") * api.global->animationTimeMultiplier; if (targetChild == panel->switchedTo) { return; @@ -3503,7 +3503,7 @@ void EsPanelSwitchTo(EsPanel *panel, EsElement *targetChild, EsTransitionType tr void EsPanelStartMovementAnimation(EsPanel *panel, float timeMultiplier) { // TODO Custom smoothing functions. - uint32_t timeMs = timeMultiplier * GetConstantNumber("transitionTime"); + uint32_t timeMs = timeMultiplier * GetConstantNumber("transitionTime") * api.global->animationTimeMultiplier; if (!timeMs) return; EsMessageMutexCheck(); EsAssert(~panel->flags & ES_PANEL_SWITCHER); // Use EsPanelSwitchTo! diff --git a/desktop/settings.cpp b/desktop/settings.cpp index e9e482b..8c10ea7 100644 --- a/desktop/settings.cpp +++ b/desktop/settings.cpp @@ -140,6 +140,7 @@ void SettingsUpdateGlobalAndWindowManager() { api.global->showCursorShadow = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("show_cursor_shadow")); api.global->useSmartQuotes = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("use_smart_quotes")); api.global->enableHoverState = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("enable_hover_state")); + api.global->animationTimeMultiplier = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("enable_animations")) ? 1.0f : 0.0f; { float newUIScale = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("ui_scale")) * 0.01f; @@ -698,6 +699,7 @@ void SettingsPageTheme(EsElement *element, SettingsPage *page) { table = EsPanelCreate(container, ES_CELL_H_FILL, &styleSettingsCheckboxGroup); SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsThemeEnableHoverState), 'H', "general", "enable_hover_state"); + SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsThemeEnableAnimations), 'M', "general", "enable_animations"); } SettingsPage settingsPages[] = { diff --git a/res/System Configuration Template.ini b/res/System Configuration Template.ini index 5dc9faf..d7223fd 100644 --- a/res/System Configuration Template.ini +++ b/res/System Configuration Template.ini @@ -6,6 +6,7 @@ ui_scale=100 window_color=6 use_smart_quotes=1 enable_hover_state=1 +enable_animations=1 [paths] fonts=0:/Essence/Fonts diff --git a/shared/strings.cpp b/shared/strings.cpp index b4e74e8..8e287ed 100644 --- a/shared/strings.cpp +++ b/shared/strings.cpp @@ -144,6 +144,7 @@ DEFINE_INTERFACE_STRING(DesktopSettingsDisplayUIScale, "Interface scale:"); DEFINE_INTERFACE_STRING(DesktopSettingsThemeWindowColor, "Window color:"); DEFINE_INTERFACE_STRING(DesktopSettingsThemeEnableHoverState, "Highlight the item the cursor is over"); +DEFINE_INTERFACE_STRING(DesktopSettingsThemeEnableAnimations, "Animate the user interface"); DEFINE_INTERFACE_STRING(DesktopSettingsThemeWallpaper, "Wallpaper"); // File operations.