mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-15 07:35:20 -04:00
feat(popouts): implement hover popout functionality
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -709,6 +709,14 @@ PanelWindow {
|
||||
readonly property var _rightSection: topBarContent ? (barWindow.isVertical ? topBarContent.vRightSection : topBarContent.hRightSection) : null
|
||||
readonly property real _revealProgress: topBarSlide.x + topBarSlide.y
|
||||
|
||||
function containsGlobalPoint(gx, gy, padding) {
|
||||
const pad = padding !== undefined ? padding : 16;
|
||||
if (!inputMask.showing)
|
||||
return false;
|
||||
const topLeft = inputMask.mapToItem(null, 0, 0);
|
||||
return gx >= topLeft.x - pad && gx < topLeft.x + inputMask.width + pad && gy >= topLeft.y - pad && gy < topLeft.y + inputMask.height + pad;
|
||||
}
|
||||
|
||||
function sectionRect(section, isCenter, _dep) {
|
||||
if (!section)
|
||||
return {
|
||||
@@ -1010,7 +1018,7 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
onWheel: wheel => {
|
||||
function processWheel(wheel) {
|
||||
if (!(barConfig?.scrollEnabled ?? true) || actionInProgress) {
|
||||
wheel.accepted = false;
|
||||
return;
|
||||
@@ -1079,6 +1087,8 @@ PanelWindow {
|
||||
|
||||
wheel.accepted = false;
|
||||
}
|
||||
|
||||
onWheel: wheel => processWheel(wheel)
|
||||
}
|
||||
|
||||
DankBarContent {
|
||||
@@ -1090,6 +1100,36 @@ PanelWindow {
|
||||
centerWidgetsModel: barWindow.centerWidgetsModel
|
||||
rightWidgetsModel: barWindow.rightWidgetsModel
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: hoverPopoutArea
|
||||
anchors.fill: parent
|
||||
z: 1
|
||||
hoverEnabled: barConfig?.hoverPopouts ?? false
|
||||
enabled: hoverPopoutArea.hoverEnabled && !barWindow.clickThroughEnabled
|
||||
acceptedButtons: Qt.NoButton
|
||||
propagateComposedEvents: true
|
||||
|
||||
property real lastGlobalX: 0
|
||||
property real lastGlobalY: 0
|
||||
|
||||
onPositionChanged: mouse => {
|
||||
const gp = mapToItem(null, mouse.x, mouse.y);
|
||||
lastGlobalX = gp.x;
|
||||
lastGlobalY = gp.y;
|
||||
topBarContent.checkHoverPopout(gp.x, gp.y);
|
||||
}
|
||||
|
||||
onWheel: wheel => scrollArea.processWheel(wheel)
|
||||
|
||||
onContainsMouseChanged: {
|
||||
if (containsMouse)
|
||||
return;
|
||||
if (topBarContent.cursorOverHoverChain(lastGlobalX, lastGlobalY))
|
||||
return;
|
||||
topBarContent.closeHoverSurfaces();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1922,4 +1922,53 @@ BasePill {
|
||||
return;
|
||||
currentTrayMenu.showForTrayItem(item, anchor, screen, atBottom, vertical ?? false, axisObj);
|
||||
}
|
||||
|
||||
function _trayLayoutRoot() {
|
||||
const contentChildren = root.visualContent?.children;
|
||||
if (!contentChildren || contentChildren.length === 0)
|
||||
return null;
|
||||
const contentRoot = contentChildren[0];
|
||||
return contentRoot?.layoutLoader?.item || null;
|
||||
}
|
||||
|
||||
function _trayHitAtGlobalPoint(gx, gy) {
|
||||
if (!root.visible || root.width <= 0 || root.height <= 0)
|
||||
return null;
|
||||
const local = root.mapFromItem(null, gx, gy);
|
||||
if (local.x < 0 || local.y < 0 || local.x > root.width || local.y > root.height)
|
||||
return null;
|
||||
const layout = _trayLayoutRoot();
|
||||
if (!layout)
|
||||
return null;
|
||||
const layoutLocal = layout.mapFromItem(null, gx, gy);
|
||||
const children = layout.children || [];
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i];
|
||||
if (!child.visible || child.width <= 0 || child.height <= 0)
|
||||
continue;
|
||||
if (layoutLocal.x < child.x || layoutLocal.x >= child.x + child.width)
|
||||
continue;
|
||||
if (layoutLocal.y < child.y || layoutLocal.y >= child.y + child.height)
|
||||
continue;
|
||||
if (child.trayItem)
|
||||
return child;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function hoverTriggerAtGlobalPoint(gx, gy) {
|
||||
const hit = _trayHitAtGlobalPoint(gx, gy);
|
||||
if (!hit?.trayItem?.hasMenu)
|
||||
return "";
|
||||
return "tray-" + (hit.trayItem.id || hit.itemKey || "");
|
||||
}
|
||||
|
||||
function openHoverAtGlobalPoint(gx, gy) {
|
||||
const hit = _trayHitAtGlobalPoint(gx, gy);
|
||||
if (!hit?.trayItem?.hasMenu)
|
||||
return false;
|
||||
const anchor = hit.children?.length > 0 ? hit.children[0] : hit;
|
||||
showForTrayItem(hit.trayItem, anchor, parentScreen, isAtBottom, isVerticalOrientation, axis);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user