forked from Shinonome/dots-hyprland
hefty: bar: make popups not move while open
This commit is contained in:
+21
-1
@@ -65,14 +65,23 @@ Shapes.ShapeCanvas {
|
|||||||
const maxOffset = maxPopupY - yInGlobal;
|
const maxOffset = maxPopupY - yInGlobal;
|
||||||
return maxOffset;
|
return maxOffset;
|
||||||
}
|
}
|
||||||
|
property bool lockPopupX: false
|
||||||
|
property bool lockPopupY: false
|
||||||
readonly property real popupXOffset: {
|
readonly property real popupXOffset: {
|
||||||
|
// print("popupXOffset", popupXOffset, "lock", lockPopupX)
|
||||||
|
if (bgShape.lockPopupX) return;
|
||||||
|
// if (bgShape.showPopup) lockPopupX = true;
|
||||||
if (!vertical) return Math.min(Math.max(-(popupWidth - containerShape.width) / 2, minPopupXOffset), maxPopupXOffset);
|
if (!vertical) return Math.min(Math.max(-(popupWidth - containerShape.width) / 2, minPopupXOffset), maxPopupXOffset);
|
||||||
else return atBottom ? -(popupShape.width + spacing) : (containerShape.width + spacing);
|
else return atBottom ? -(popupShape.width + spacing) : (containerShape.width + spacing);
|
||||||
}
|
}
|
||||||
|
onPopupXOffsetChanged: if (bgShape.showPopup) lockPopupX = true;
|
||||||
readonly property real popupYOffset: {
|
readonly property real popupYOffset: {
|
||||||
|
if (bgShape.lockPopupY) return;
|
||||||
|
// if (bgShape.showPopup) lockPopupY = true;
|
||||||
if (!vertical) return atBottom ? -(popupShape.height + spacing) : (containerShape.height + spacing);
|
if (!vertical) return atBottom ? -(popupShape.height + spacing) : (containerShape.height + spacing);
|
||||||
else return Math.min(Math.max(-(popupHeight - containerShape.height) / 2, minPopupYOffset), maxPopupYOffset)
|
else return Math.min(Math.max(-(popupHeight - containerShape.height) / 2, minPopupYOffset), maxPopupYOffset)
|
||||||
}
|
}
|
||||||
|
onPopupYOffsetChanged: if (bgShape.showPopup) lockPopupY = true;
|
||||||
|
|
||||||
// Positioning
|
// Positioning
|
||||||
readonly property real popupContentOffsetBase: -baseMargin + popupPadding
|
readonly property real popupContentOffsetBase: -baseMargin + popupPadding
|
||||||
@@ -111,7 +120,18 @@ Shapes.ShapeCanvas {
|
|||||||
}
|
}
|
||||||
property bool popupHiding: false
|
property bool popupHiding: false
|
||||||
onShowPopupChanged: popupHiding = true
|
onShowPopupChanged: popupHiding = true
|
||||||
onProgressChanged: if (progress == 1) popupHiding = false
|
onProgressChanged: {
|
||||||
|
if (progress == 1) {
|
||||||
|
popupHiding = false
|
||||||
|
if (showPopup) {
|
||||||
|
lockPopupX = true;
|
||||||
|
lockPopupY = true;
|
||||||
|
} else {
|
||||||
|
lockPopupX = false;
|
||||||
|
lockPopupY = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
color: showPopup || popupHiding ? C.Appearance.colors.colLayer3Base : C.Appearance.colors.colLayer1
|
color: showPopup || popupHiding ? C.Appearance.colors.colLayer3Base : C.Appearance.colors.colLayer1
|
||||||
xOffset: {
|
xOffset: {
|
||||||
if (!vertical) return showPopup ? Math.max(-popupXOffset, 0) : 0;
|
if (!vertical) return showPopup ? Math.max(-popupXOffset, 0) : 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user