forked from Shinonome/dots-hyprland
fix widget parallax
This commit is contained in:
@@ -127,7 +127,6 @@ Variants {
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
clip: true
|
|
||||||
|
|
||||||
// Wallpaper
|
// Wallpaper
|
||||||
StyledImage {
|
StyledImage {
|
||||||
@@ -148,35 +147,38 @@ Variants {
|
|||||||
return Math.max(0, Math.min(1, workspaceIndex / (bgRoot.totalWorkspaces - 1)));
|
return Math.max(0, Math.min(1, workspaceIndex / (bgRoot.totalWorkspaces - 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
x: {
|
property real usedFractionX: {
|
||||||
if (bgRoot.screen.width > bgRoot.scaledWallpaperWidth) {
|
|
||||||
// Center the picture
|
|
||||||
return (bgRoot.screen.width - bgRoot.scaledWallpaperWidth) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
let usedFraction = middleFraction;
|
let usedFraction = middleFraction;
|
||||||
if (Config.options.background.parallax.enableWorkspace && !bgRoot.verticalParallax) {
|
if (Config.options.background.parallax.enableWorkspace && !bgRoot.verticalParallax) {
|
||||||
usedFraction = fraction;
|
usedFraction = fraction;
|
||||||
}
|
}
|
||||||
if (Config.options.background.parallax.enableSidebar) {
|
if (Config.options.background.parallax.enableSidebar) {
|
||||||
let sidebarFraction = bgRoot.parallaxRation / 10;
|
let sidebarFraction = bgRoot.parallaxRation / bgRoot.workspaceChunkSize / 2;
|
||||||
usedFraction += (sidebarFraction * GlobalStates.sidebarRightOpen - sidebarFraction * GlobalStates.sidebarLeftOpen);
|
usedFraction += (sidebarFraction * GlobalStates.sidebarRightOpen - sidebarFraction * GlobalStates.sidebarLeftOpen);
|
||||||
}
|
}
|
||||||
usedFraction = Math.max(0, Math.min(1, usedFraction));
|
return Math.max(0, Math.min(1, usedFraction));
|
||||||
return - bgRoot.parallaxTotalPixelsX * usedFraction;
|
}
|
||||||
|
property real usedFractionY: {
|
||||||
|
let usedFraction = middleFraction;
|
||||||
|
if (Config.options.background.parallax.enableWorkspace && bgRoot.verticalParallax) {
|
||||||
|
usedFraction = fraction;
|
||||||
|
}
|
||||||
|
return Math.max(0, Math.min(1, usedFraction));
|
||||||
|
}
|
||||||
|
|
||||||
|
x: {
|
||||||
|
if (bgRoot.screen.width > bgRoot.scaledWallpaperWidth) {
|
||||||
|
// Center the picture
|
||||||
|
return (bgRoot.screen.width - bgRoot.scaledWallpaperWidth) / 2;
|
||||||
|
}
|
||||||
|
return - bgRoot.parallaxTotalPixelsX * usedFractionX;
|
||||||
}
|
}
|
||||||
y: {
|
y: {
|
||||||
if (bgRoot.screen.height > bgRoot.scaledWallpaperHeight) {
|
if (bgRoot.screen.height > bgRoot.scaledWallpaperHeight) {
|
||||||
// Center the picture
|
// Center the picture
|
||||||
return (bgRoot.screen.height - bgRoot.scaledWallpaperHeight) / 2;
|
return (bgRoot.screen.height - bgRoot.scaledWallpaperHeight) / 2;
|
||||||
}
|
}
|
||||||
|
return - bgRoot.parallaxTotalPixelsY * usedFractionY;
|
||||||
let usedFraction = middleFraction;
|
|
||||||
if (Config.options.background.parallax.enableWorkspace && bgRoot.verticalParallax) {
|
|
||||||
usedFraction = fraction;
|
|
||||||
}
|
|
||||||
usedFraction = Math.max(0, Math.min(1, usedFraction));
|
|
||||||
return - bgRoot.parallaxTotalPixelsY * usedFraction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
source: bgRoot.wallpaperSafetyTriggered ? "" : bgRoot.wallpaperPath
|
source: bgRoot.wallpaperSafetyTriggered ? "" : bgRoot.wallpaperPath
|
||||||
@@ -229,43 +231,20 @@ Variants {
|
|||||||
|
|
||||||
WidgetCanvas {
|
WidgetCanvas {
|
||||||
id: widgetCanvas
|
id: widgetCanvas
|
||||||
anchors {
|
width: parent.width
|
||||||
left: wallpaper.left
|
height: parent.height
|
||||||
right: wallpaper.right
|
readonly property real parallaxFactor: {
|
||||||
top: wallpaper.top
|
var f = Config.options.background.parallax.widgetsFactor;
|
||||||
bottom: wallpaper.bottom
|
return f / Config.options.background.parallax.workspaceZoom;
|
||||||
horizontalCenter: undefined
|
|
||||||
verticalCenter: undefined
|
|
||||||
readonly property real parallaxFactor: Config.options.background.parallax.widgetsFactor
|
|
||||||
Behavior on leftMargin {
|
|
||||||
animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
|
|
||||||
}
|
|
||||||
Behavior on topMargin {
|
|
||||||
animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
width: wallpaper.width
|
|
||||||
height: wallpaper.height
|
|
||||||
states: State {
|
|
||||||
name: "centered"
|
|
||||||
when: GlobalStates.screenLocked || bgRoot.wallpaperSafetyTriggered
|
|
||||||
PropertyChanges {
|
|
||||||
target: widgetCanvas
|
|
||||||
width: parent.width
|
|
||||||
height: parent.height
|
|
||||||
}
|
|
||||||
AnchorChanges {
|
|
||||||
target: widgetCanvas
|
|
||||||
anchors {
|
|
||||||
left: undefined
|
|
||||||
right: undefined
|
|
||||||
top: undefined
|
|
||||||
bottom: undefined
|
|
||||||
horizontalCenter: parent.horizontalCenter
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
readonly property real baseWallpaperOffsetX: (bgRoot.screen.width - bgRoot.scaledWallpaperWidth) / 2
|
||||||
|
readonly property real baseWallpaperOffsetY: (bgRoot.screen.height - bgRoot.scaledWallpaperHeight) / 2
|
||||||
|
readonly property real wallpaperTotalOffsetX: wallpaper.x - baseWallpaperOffsetX
|
||||||
|
readonly property real wallpaperTotalOffsetY: wallpaper.y - baseWallpaperOffsetY
|
||||||
|
readonly property bool locked: GlobalStates.screenLocked
|
||||||
|
x: wallpaperTotalOffsetX * parallaxFactor * !locked
|
||||||
|
y: wallpaperTotalOffsetY * parallaxFactor * !locked
|
||||||
|
|
||||||
transitions: Transition {
|
transitions: Transition {
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
properties: "width,height"
|
properties: "width,height"
|
||||||
|
|||||||
Reference in New Issue
Block a user