Lots of uncommitted changes

This commit is contained in:
outfoxxed 2024-05-08 14:18:44 -07:00
parent daace49bfc
commit 497ca48ada
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
27 changed files with 909 additions and 134 deletions

View file

@ -0,0 +1,127 @@
import QtQuick
import Quickshell
import Quickshell.Hyprland
Scope {
id: root
required property var bar;
property TooltipItem activeTooltip: null;
property TooltipItem activeMenu: null;
readonly property TooltipItem activeItem: activeMenu ?? activeTooltip;
property TooltipItem lastActiveItem: null;
onActiveItemChanged: {
if (activeItem != null) activeItem.visible = true;
if (lastActiveItem != null) lastActiveItem.visible = false;
lastActiveItem = activeItem;
}
function setItem(item: TooltipItem) {
if (item.isMenu) {
activeMenu = item;
} else {
activeTooltip = item;
}
}
function removeItem(item: TooltipItem) {
if (item.isMenu && activeMenu == item) {
activeMenu = null
} else if (!item.isMenu && activeTooltip == item) {
activeTooltip = null
}
}
LazyLoader {
id: popupLoader
activeAsync: activeItem != null
PopupWindow {
id: popup
parentWindow: bar.widgetSurface
relativeX: bar.widgetSurface.tooltipXOffset
relativeY: 0
height: bar.widgetSurface.height
width: tooltipItem.width
visible: true
color: "transparent"
mask: Region {
item: (activeItem?.isMenu ?? false) ? tooltipItem : null
}
HyprlandFocusGrab {
active: activeItem?.isMenu ?? false
windows: [ popup, bar.widgetSurface ]
onActiveChanged: {
if (!active && activeItem?.isMenu) {
activeMenu.close()
}
}
}
BarWidgetInner {
id: tooltipItem
readonly property var targetWidth: activeItem?.implicitWidth ?? 10;
readonly property var targetHeight: (activeItem?.implicitHeight ?? 0) + 10;
readonly property real targetY: {
if (activeItem == null) return 0;
const target = bar.widgetSurface.contentItem.mapFromItem(activeItem.owner, 0, activeItem.targetRelativeY).y;
return bar.widgetSurface.boundedY(target, activeItem.implicitHeight / 2);
}
width: targetWidth + 10
property var y1: -1
property var y2: -1
y: y1
height: y2 - y1
SmoothedAnimation {
target: tooltipItem;
property: "y1";
to: tooltipItem.targetY - tooltipItem.targetHeight / 2;
onToChanged: {
if (tooltipItem.y1 == -1 || !(activeItem?.animateSize ?? true)) {
stop();
tooltipItem.y1 = to;
} else {
velocity = (Math.max(tooltipItem.y1, to) - Math.min(tooltipItem.y1, to)) * 5;
restart();
}
}
}
SmoothedAnimation {
target: tooltipItem
property: "y2"
to: tooltipItem.targetY + tooltipItem.targetHeight / 2;
onToChanged: {
if (tooltipItem.y2 == -1 || !(activeItem?.animateSize ?? true)) {
stop();
tooltipItem.y2 = to;
} else {
velocity = (Math.max(tooltipItem.y2, to) - Math.min(tooltipItem.y2, to)) * 5;
restart();
}
}
}
Item {
clip: true
children: [ activeItem ]
anchors {
fill: parent
margins: 5
}
}
}
}
}
}