diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 422290b2..fccdafcd 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -1555,8 +1555,8 @@ "label": "Appearance" }, "settings-panel-attached-to-bar": { - "description": "Keep the Settings window aligned with the bar for a unified look.", - "label": "Snap Settings window to bar" + "description": "Keep the settings window aligned with the bar for a unified look.", + "label": "Snap settings window to bar" }, "shadows": { "description": "Enables drop shadows under bars and panels.", diff --git a/Modules/MainScreen/SmartPanel.qml b/Modules/MainScreen/SmartPanel.qml index 6a5d34aa..58cabc37 100644 --- a/Modules/MainScreen/SmartPanel.qml +++ b/Modules/MainScreen/SmartPanel.qml @@ -382,9 +382,14 @@ Item { rightEdgePos = root.width - root.barMarginH - Style.barHeight - panelWidth } - if (Math.abs(calculatedX - leftEdgePos) <= root.edgeSnapDistance) { + // Only snap to left edge if panel is actually meant to be at left (or no explicit anchor) + var shouldSnapToLeft = root.effectivePanelAnchorLeft || (!root.hasExplicitHorizontalAnchor && root.barPosition === "left") + // Only snap to right edge if panel is actually meant to be at right (or no explicit anchor) + var shouldSnapToRight = root.effectivePanelAnchorRight || (!root.hasExplicitHorizontalAnchor && root.barPosition === "right") + + if (shouldSnapToLeft && Math.abs(calculatedX - leftEdgePos) <= root.edgeSnapDistance) { calculatedX = leftEdgePos - } else if (Math.abs(calculatedX - rightEdgePos) <= root.edgeSnapDistance) { + } else if (shouldSnapToRight && Math.abs(calculatedX - rightEdgePos) <= root.edgeSnapDistance) { calculatedX = rightEdgePos } } @@ -515,9 +520,14 @@ Item { bottomEdgePos = root.height - root.barMarginV - Style.barHeight - panelHeight } - if (Math.abs(calculatedY - topEdgePos) <= root.edgeSnapDistance) { + // Only snap to top edge if panel is actually meant to be at top (or no explicit anchor) + var shouldSnapToTop = root.effectivePanelAnchorTop || (!root.hasExplicitVerticalAnchor && root.barPosition === "top") + // Only snap to bottom edge if panel is actually meant to be at bottom (or no explicit anchor) + var shouldSnapToBottom = root.effectivePanelAnchorBottom || (!root.hasExplicitVerticalAnchor && root.barPosition === "bottom") + + if (shouldSnapToTop && Math.abs(calculatedY - topEdgePos) <= root.edgeSnapDistance) { calculatedY = topEdgePos - } else if (Math.abs(calculatedY - bottomEdgePos) <= root.edgeSnapDistance) { + } else if (shouldSnapToBottom && Math.abs(calculatedY - bottomEdgePos) <= root.edgeSnapDistance) { calculatedY = bottomEdgePos } }