mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2025-12-06 06:36:15 +00:00
SmartPanel: improved snapping behavior
This commit is contained in:
@@ -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.",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user