From 7c8068b2bd2352cd7d5594800db7048f502d6649 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Wed, 20 Aug 2025 19:35:33 +0700 Subject: [PATCH] background: add vertical parallax --- .../ii/modules/background/Background.qml | 44 +++++++++++++------ .../quickshell/ii/modules/common/Config.qml | 1 + .../ii/modules/settings/StyleConfig.qml | 8 ++++ 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/.config/quickshell/ii/modules/background/Background.qml b/.config/quickshell/ii/modules/background/Background.qml index 087b4dcc9..e3ff9ba0a 100644 --- a/.config/quickshell/ii/modules/background/Background.qml +++ b/.config/quickshell/ii/modules/background/Background.qml @@ -161,22 +161,34 @@ Variants { Behavior on opacity { animation: Appearance.animation.elementMoveEnter.numberAnimation.createObject(this) } - property real value // 0 to 1, for offset cache: false asynchronous: true - value: { - // Range = groups that workspaces span on - const chunkSize = Config?.options.bar.workspaces.shown ?? 10; - const lower = Math.floor(bgRoot.firstWorkspaceId / chunkSize) * chunkSize; - const upper = Math.ceil(bgRoot.lastWorkspaceId / chunkSize) * chunkSize; - const range = upper - lower; - return (Config.options.background.parallax.enableWorkspace ? ((bgRoot.monitor.activeWorkspace?.id - lower) / range) : 0.5) - + (0.15 * GlobalStates.sidebarRightOpen * Config.options.background.parallax.enableSidebar) - - (0.15 * GlobalStates.sidebarLeftOpen * Config.options.background.parallax.enableSidebar) + // Range = groups that workspaces span on + property int chunkSize: Config?.options.bar.workspaces.shown ?? 10; + property int lower: Math.floor(bgRoot.firstWorkspaceId / chunkSize) * chunkSize; + property int upper: Math.ceil(bgRoot.lastWorkspaceId / chunkSize) * chunkSize; + property int range: upper - lower; + property real valueX: { + let result = 0.5; + if (Config.options.background.parallax.enableWorkspace && !Config.options.background.parallax.vertical) { + result = ((bgRoot.monitor.activeWorkspace?.id - lower) / range); + } + if (Config.options.background.parallax.enableSidebar) { + result += (0.15 * GlobalStates.sidebarRightOpen - 0.15 * GlobalStates.sidebarLeftOpen); + } + return result; } - property real effectiveValue: Math.max(0, Math.min(1, value)) - x: -(bgRoot.movableXSpace) - (effectiveValue - 0.5) * 2 * bgRoot.movableXSpace - y: -(bgRoot.movableYSpace) + property real valueY: { + let result = 0.5; + if (Config.options.background.parallax.enableWorkspace && Config.options.background.parallax.vertical) { + result = ((bgRoot.monitor.activeWorkspace?.id - lower) / range); + } + return result; + } + property real effectiveValueX: Math.max(0, Math.min(1, valueX)) + property real effectiveValueY: Math.max(0, Math.min(1, valueY)) + x: -(bgRoot.movableXSpace) - (effectiveValueX - 0.5) * 2 * bgRoot.movableXSpace + y: -(bgRoot.movableYSpace) - (effectiveValueY - 0.5) * 2 * bgRoot.movableYSpace source: bgRoot.wallpaperPath fillMode: Image.PreserveAspectCrop Behavior on x { @@ -185,6 +197,12 @@ Variants { easing.type: Easing.OutCubic } } + Behavior on y { + NumberAnimation { + duration: 600 + easing.type: Easing.OutCubic + } + } sourceSize { width: bgRoot.screen.width * bgRoot.effectiveWallpaperScale height: bgRoot.screen.height * bgRoot.effectiveWallpaperScale diff --git a/.config/quickshell/ii/modules/common/Config.qml b/.config/quickshell/ii/modules/common/Config.qml index 7ae1c8b96..4055d7854 100644 --- a/.config/quickshell/ii/modules/common/Config.qml +++ b/.config/quickshell/ii/modules/common/Config.qml @@ -122,6 +122,7 @@ Singleton { property string wallpaperPath: "" property string thumbnailPath: "" property JsonObject parallax: JsonObject { + property bool vertical: false property bool enableWorkspace: true property real workspaceZoom: 1.07 // Relative to your screen, not wallpaper size property bool enableSidebar: true diff --git a/.config/quickshell/ii/modules/settings/StyleConfig.qml b/.config/quickshell/ii/modules/settings/StyleConfig.qml index 2c312460d..4f375bb2f 100644 --- a/.config/quickshell/ii/modules/settings/StyleConfig.qml +++ b/.config/quickshell/ii/modules/settings/StyleConfig.qml @@ -212,6 +212,14 @@ ContentPage { ContentSubsection { title: Translation.tr("Wallpaper parallax") + ConfigSwitch { + text: Translation.tr("Vertical") + checked: Config.options.background.parallax.vertical + onCheckedChanged: { + Config.options.background.parallax.vertical = checked; + } + } + ConfigRow { uniform: true ConfigSwitch {