shift-shell/containments/homescreens/folio/qml/private/WidgetResizeHandle.qml
Marco Allegretti a37734b74a Move homescreens to shared motion
Use Motion wrappers and state layers across Folio and Halcyon delegates, drawers, folders, resize handles, and dock feedback. Also align Folio edit/drop highlights with theme colors instead of fixed white overlays.
2026-05-21 11:13:36 +02:00

101 lines
2.8 KiB
QML

// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick
import org.kde.kirigami as Kirigami
import org.kde.plasma.private.mobileshell as MobileShell
import '../delegate'
MouseArea {
id: root
height: 10 + touchPadding * 2
width: 10 + touchPadding * 2
readonly property real touchPadding: 20
readonly property int pressAnimationDuration: MobileShell.Motion.duration(MobileShell.Motion.EffectsSlow)
readonly property color resizeHandleColor: Kirigami.Theme.highlightColor
property int orientation
signal dragEvent(real leftEdgeDelta, real rightEdgeDelta, real topEdgeDelta, real bottomEdgeDelta)
cursorShape: Qt.PointingHandCursor
drag {
target: root
axis: {
switch (orientation) {
case WidgetHandlePosition.TopCenter:
return Drag.YAxis;
case WidgetHandlePosition.LeftCenter:
return Drag.XAxis;
case WidgetHandlePosition.RightCenter:
return Drag.XAxis;
case WidgetHandlePosition.BottomCenter:
return Drag.YAxis;
}
return Drag.XAndYAxis;
}
}
property real pressX
property real pressY
onPressed: {
pressX = mouseX;
pressY = mouseY;
}
onPositionChanged: {
// HACK: need to call it twice to work
updateDrag();
updateDrag();
}
drag { target: root; axis: Drag.XAndYAxis }
function updateDrag() {
if (!drag.active) return;
const dx = mouseX;
const dy = mouseY;
switch (orientation) {
case WidgetHandlePosition.TopCenter:
root.dragEvent(0, 0, -dy, 0);
break;
case WidgetHandlePosition.LeftCenter:
root.dragEvent(-dx, 0, 0, 0);
break;
case WidgetHandlePosition.RightCenter:
root.dragEvent(0, dx, 0, 0);
break;
case WidgetHandlePosition.BottomCenter:
root.dragEvent(0, 0, 0, dy);
break;
}
}
Rectangle {
id: rect
anchors.fill: parent
anchors.margins: root.touchPadding
color: root.resizeHandleColor
radius: width / 2
transform: Scale {
property real scaleFactor: root.pressed ? MobileShell.Motion.pressScaleOut : 1.0
Behavior on scaleFactor {
MobileShell.MotionNumberAnimation { type: MobileShell.Motion.EffectsSlow; duration: root.pressAnimationDuration }
}
xScale: scaleFactor
yScale: scaleFactor
origin.x: rect.width / 2
origin.y: rect.height / 2
}
}
}