NPanel dimensions & Dimmer: Panels have no margin they are full screen and prevent clicking on the bar until dismissed.

Margins are now included in the rectangle X,Y coordinates calculation

Might sound weird at first but it fixes a lot of inconsistencies/issues
we have had for a long time when a panel was open:
- can't close panel when clicking in a dead zone of the bar.
- hovering an icon on the bar used to make it look like you could
interact with it, but the click would just close the panel and not
actuall y do anything with bar .

I recommend turning back on dimming, as it is now way cooler. Changed
the default to true.
This commit is contained in:
LemmyCook 2025-09-16 21:53:11 -04:00
parent 6f1ae43d62
commit cdca7c1d83
2 changed files with 60 additions and 62 deletions

View file

@ -328,7 +328,7 @@ Singleton {
// general // general
property JsonObject general: JsonObject { property JsonObject general: JsonObject {
property string avatarImage: defaultAvatar property string avatarImage: defaultAvatar
property bool dimDesktop: false property bool dimDesktop: true
property bool showScreenCorners: false property bool showScreenCorners: false
property bool forceBlackScreenCorners: false property bool forceBlackScreenCorners: false
property real radiusRatio: 1.0 property real radiusRatio: 1.0

View file

@ -193,54 +193,6 @@ Loader {
anchors.right: true anchors.right: true
anchors.bottom: true anchors.bottom: true
margins.top: {
if (!barIsVisible) {
return 0
}
switch (barPosition || panelAnchorVerticalCenter) {
case "top":
return (Style.barHeight + Style.marginS) * scaling + (Settings.data.bar.floating ? Settings.data.bar.marginVertical * 2 * Style.marginXL * scaling : 0)
default:
return Style.marginS * scaling
}
}
margins.bottom: {
if (!barIsVisible || panelAnchorVerticalCenter) {
return 0
}
switch (barPosition) {
case "bottom":
return (Style.barHeight + Style.marginS) * scaling + (Settings.data.bar.floating ? Settings.data.bar.marginVertical * 2 * Style.marginXL * scaling : 0)
default:
return Style.marginS * scaling
}
}
margins.left: {
if (!barIsVisible || panelAnchorHorizontalCenter) {
return 0
}
switch (barPosition) {
case "left":
return (Style.barHeight + Style.marginS) * scaling + (Settings.data.bar.floating ? Settings.data.bar.marginHorizontal * 2 * Style.marginXL * scaling : 0)
default:
return Style.marginS * scaling
}
}
margins.right: {
if (!barIsVisible || panelAnchorHorizontalCenter) {
return 0
}
switch (barPosition) {
case "right":
return (Style.barHeight + Style.marginS) * scaling + (Settings.data.bar.floating ? Settings.data.bar.marginHorizontal * 2 * Style.marginXL * scaling : 0)
default:
return Style.marginS * scaling
}
}
// Close any panel with Esc without requiring focus // Close any panel with Esc without requiring focus
Shortcut { Shortcut {
sequences: ["Escape"] sequences: ["Escape"]
@ -290,9 +242,55 @@ Loader {
y: calculatedY y: calculatedY
// --------------------------------------------- // ---------------------------------------------
// All Style.marginXXX are handled above in the PanelWindow itself.
// Does not account for corners are they are negligible and helps keep the code clean. // Does not account for corners are they are negligible and helps keep the code clean.
// --------------------------------------------- // ---------------------------------------------
property real marginTop: {
if (!barIsVisible) {
return 0
}
switch (barPosition || panelAnchorVerticalCenter) {
case "top":
return (Style.barHeight + Style.marginS) * scaling + (Settings.data.bar.floating ? Settings.data.bar.marginVertical * 2 * Style.marginXL * scaling : 0)
default:
return Style.marginS * scaling
}
}
property real marginBottom: {
if (!barIsVisible || panelAnchorVerticalCenter) {
return 0
}
switch (barPosition) {
case "bottom":
return (Style.barHeight + Style.marginS) * scaling + (Settings.data.bar.floating ? Settings.data.bar.marginVertical * 2 * Style.marginXL * scaling : 0)
default:
return Style.marginS * scaling
}
}
property real marginLeft: {
if (!barIsVisible || panelAnchorHorizontalCenter) {
return 0
}
switch (barPosition) {
case "left":
return (Style.barHeight + Style.marginS) * scaling + (Settings.data.bar.floating ? Settings.data.bar.marginHorizontal * 2 * Style.marginXL * scaling : 0)
default:
return Style.marginS * scaling
}
}
property real marginRight: {
if (!barIsVisible || panelAnchorHorizontalCenter) {
return 0
}
switch (barPosition) {
case "right":
return (Style.barHeight + Style.marginS) * scaling + (Settings.data.bar.floating ? Settings.data.bar.marginHorizontal * 2 * Style.marginXL * scaling : 0)
default:
return Style.marginS * scaling
}
}
// --------------------------------------------- // ---------------------------------------------
property int calculatedX: { property int calculatedX: {
@ -300,9 +298,9 @@ Loader {
if (panelAnchorHorizontalCenter) { if (panelAnchorHorizontalCenter) {
return Math.round((panelWindow.width - panelBackground.width) / 2) return Math.round((panelWindow.width - panelBackground.width) / 2)
} else if (panelAnchorLeft) { } else if (panelAnchorLeft) {
return 0 return marginLeft
} else if (panelAnchorRight) { } else if (panelAnchorRight) {
return Math.round(panelWindow.width - panelBackground.width) return Math.round(panelWindow.width - panelBackground.width - marginRight)
} }
// No fixed anchoring // No fixed anchoring
@ -310,10 +308,10 @@ Loader {
// Vertical bar // Vertical bar
if (barPosition === "right") { if (barPosition === "right") {
// To the left of the right bar // To the left of the right bar
return Math.round(panelWindow.width - panelBackground.width) return Math.round(panelWindow.width - panelBackground.width - marginRight)
} else { } else {
// To the right of the left bar // To the right of the left bar
return 0 return marginLeft
} }
} else { } else {
// Horizontal bar // Horizontal bar
@ -321,8 +319,8 @@ Loader {
// Position panel relative to button // Position panel relative to button
var targetX = buttonPosition.x + (buttonWidth / 2) - (panelBackground.width / 2) var targetX = buttonPosition.x + (buttonWidth / 2) - (panelBackground.width / 2)
// Keep panel within screen bounds // Keep panel within screen bounds
var maxX = panelWindow.width - panelBackground.width var maxX = panelWindow.width - panelBackground.width - marginRight
var minX = Style.marginS * scaling var minX = marginLeft
return Math.round(Math.max(minX, Math.min(targetX, maxX))) return Math.round(Math.max(minX, Math.min(targetX, maxX)))
} else { } else {
// Fallback to center horizontally // Fallback to center horizontally
@ -337,9 +335,9 @@ Loader {
if (panelAnchorVerticalCenter) { if (panelAnchorVerticalCenter) {
return Math.round((panelWindow.height - panelBackground.height) / 2) return Math.round((panelWindow.height - panelBackground.height) / 2)
} else if (panelAnchorTop) { } else if (panelAnchorTop) {
return 0 return marginTop
} else if (panelAnchorBottom) { } else if (panelAnchorBottom) {
return Math.round(panelWindow.height - panelBackground.height) return Math.round(panelWindow.height - panelBackground.height - marginBottom)
} }
// No fixed anchoring // No fixed anchoring
@ -349,8 +347,8 @@ Loader {
// Position panel relative to button // Position panel relative to button
var targetY = buttonPosition.y + (buttonHeight / 2) - (panelBackground.height / 2) var targetY = buttonPosition.y + (buttonHeight / 2) - (panelBackground.height / 2)
// Keep panel within screen bounds // Keep panel within screen bounds
var maxY = panelWindow.height - panelBackground.height var maxY = panelWindow.height - panelBackground.height - marginBottom
var minY = Style.marginS * scaling var minY = marginTop
return Math.round(Math.max(minY, Math.min(targetY, maxY))) return Math.round(Math.max(minY, Math.min(targetY, maxY)))
} else { } else {
// Fallback to center vertically // Fallback to center vertically
@ -360,10 +358,10 @@ Loader {
// Horizontal bar // Horizontal bar
if (barPosition === "bottom") { if (barPosition === "bottom") {
// Above the bottom bar // Above the bottom bar
return Math.round(panelWindow.height - panelBackground.height) return Math.round(panelWindow.height - panelBackground.height - marginBottom)
} else { } else {
// Below the top bar // Below the top bar
return 0 return marginTop
} }
} }
} }