Fix panel spacing and borders
This commit is contained in:
@@ -9,7 +9,7 @@ PopupWindow {
|
|||||||
required property Item anchorItem
|
required property Item anchorItem
|
||||||
required property QtObject bar
|
required property QtObject bar
|
||||||
property var owner: null
|
property var owner: null
|
||||||
property int margin: 8
|
property int margin: 10
|
||||||
property int padding: 14
|
property int padding: 14
|
||||||
property int contentWidth: 280
|
property int contentWidth: 280
|
||||||
property int contentHeight: 200
|
property int contentHeight: 200
|
||||||
@@ -83,28 +83,31 @@ PopupWindow {
|
|||||||
if (!window) return
|
if (!window) return
|
||||||
|
|
||||||
if (root.centerOnBar) {
|
if (root.centerOnBar) {
|
||||||
|
var cx = 0;
|
||||||
|
var cy = 0;
|
||||||
if (root.bar.position === "top" || root.bar.position === "bottom") {
|
if (root.bar.position === "top" || root.bar.position === "bottom") {
|
||||||
localX = window.width / 2 - popupWidth / 2
|
cx = window.width / 2 - popupWidth / 2
|
||||||
localY = root.bar.position === "bottom" ? -popupHeight - root.margin : window.height + root.margin
|
cy = root.bar.position === "bottom" ? -popupHeight - root.margin : window.height + root.margin
|
||||||
localX = Math.max(root.margin, Math.min(localX, window.width - popupWidth - root.margin))
|
cx = Math.max(root.margin, Math.min(cx, window.width - popupWidth - root.margin))
|
||||||
} else {
|
} else {
|
||||||
localX = root.bar.position === "left" ? window.width + root.margin : -popupWidth - root.margin
|
cx = root.bar.position === "left" ? window.width + root.margin : -popupWidth - root.margin
|
||||||
localY = window.height / 2 - popupHeight / 2
|
cy = window.height / 2 - popupHeight / 2
|
||||||
localY = Math.max(root.margin, Math.min(localY, window.height - popupHeight - root.margin))
|
cy = Math.max(root.margin, Math.min(cy, window.height - popupHeight - root.margin))
|
||||||
}
|
}
|
||||||
|
|
||||||
popupAnchor.rect.x = Math.round(localX)
|
popupAnchor.rect.x = Math.round(cx)
|
||||||
popupAnchor.rect.y = Math.round(localY)
|
popupAnchor.rect.y = Math.round(cy)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var point = window.contentItem.mapFromItem(target, localX, localY)
|
||||||
|
|
||||||
if (root.bar.position === "top" || root.bar.position === "bottom") {
|
if (root.bar.position === "top" || root.bar.position === "bottom") {
|
||||||
localX = Math.max(root.margin, Math.min(localX, window.width - popupWidth - root.margin))
|
point.x = Math.max(root.margin, Math.min(point.x, window.width - popupWidth - root.margin))
|
||||||
} else {
|
} else {
|
||||||
localY = Math.max(root.margin, Math.min(localY, window.height - popupHeight - root.margin))
|
point.y = Math.max(root.margin, Math.min(point.y, window.height - popupHeight - root.margin))
|
||||||
}
|
}
|
||||||
|
|
||||||
var point = window.contentItem.mapFromItem(target, localX, localY)
|
|
||||||
popupAnchor.rect.x = Math.round(point.x)
|
popupAnchor.rect.x = Math.round(point.x)
|
||||||
popupAnchor.rect.y = Math.round(point.y)
|
popupAnchor.rect.y = Math.round(point.y)
|
||||||
}
|
}
|
||||||
@@ -115,7 +118,7 @@ PopupWindow {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: Color.popups.background
|
color: Color.popups.background
|
||||||
border.color: Color.popups.border
|
border.color: Color.popups.border
|
||||||
border.width: 1
|
border.width: 2
|
||||||
radius: 0
|
radius: 0
|
||||||
opacity: root.open ? 1.0 : 0
|
opacity: root.open ? 1.0 : 0
|
||||||
|
|
||||||
|
|||||||
@@ -192,7 +192,9 @@ Item {
|
|||||||
owner: root
|
owner: root
|
||||||
bar: root.bar
|
bar: root.bar
|
||||||
open: root.popupOpen
|
open: root.popupOpen
|
||||||
contentWidth: 380
|
// Match the width/inset of the window below so the popup outline
|
||||||
|
// overlays cleanly instead of bleeding past the underlying frame.
|
||||||
|
contentWidth: 370
|
||||||
contentHeight: Math.min(560, panelColumn.implicitHeight + 28)
|
contentHeight: Math.min(560, panelColumn.implicitHeight + 28)
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
@@ -296,7 +298,7 @@ Item {
|
|||||||
|
|
||||||
width: panelColumn.width
|
width: panelColumn.width
|
||||||
height: deviceRow.implicitHeight + 10
|
height: deviceRow.implicitHeight + 10
|
||||||
radius: 4
|
radius: 0
|
||||||
color: deviceArea.pressed
|
color: deviceArea.pressed
|
||||||
? Qt.rgba(root.bar.foreground.r, root.bar.foreground.g, root.bar.foreground.b, 0.22)
|
? Qt.rgba(root.bar.foreground.r, root.bar.foreground.g, root.bar.foreground.b, 0.22)
|
||||||
: deviceArea.containsMouse
|
: deviceArea.containsMouse
|
||||||
@@ -447,7 +449,7 @@ Item {
|
|||||||
|
|
||||||
width: panelColumn.width
|
width: panelColumn.width
|
||||||
height: sourceRow.implicitHeight + 10
|
height: sourceRow.implicitHeight + 10
|
||||||
radius: 4
|
radius: 0
|
||||||
color: sourceArea.pressed
|
color: sourceArea.pressed
|
||||||
? Qt.rgba(root.bar.foreground.r, root.bar.foreground.g, root.bar.foreground.b, 0.22)
|
? Qt.rgba(root.bar.foreground.r, root.bar.foreground.g, root.bar.foreground.b, 0.22)
|
||||||
: sourceArea.containsMouse
|
: sourceArea.containsMouse
|
||||||
|
|||||||
Reference in New Issue
Block a user