In notch mode the picker grows from the screen's top edge in the notch's shape, with the notch's open fill and opening/closing speeds, and the collapsed notch hides while it is up. Bar mode is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
117 lines
4.5 KiB
QML
117 lines
4.5 KiB
QML
import QtQuick
|
|
import "../core"
|
|
import "../theme"
|
|
|
|
// A popup that grows out of the bar (Caelestia-style drawer). Place it at
|
|
// y = BarDrawers.bottom in a window whose top is the screen's top edge: the
|
|
// layer box then starts above the bar, so the join is not a glass edge.
|
|
// Content slides down with the body as it is revealed.
|
|
Item {
|
|
id: root
|
|
default property alias content: inner.data
|
|
property bool open: false
|
|
property bool attached: true
|
|
property real contentWidth: 300
|
|
property real contentHeight: 200
|
|
// Registered with the bar so it opens its border over this span.
|
|
property string drawerId: ""
|
|
property string screenName: ""
|
|
property real screenX: 0
|
|
readonly property real ear: attached ? BarDrawers.ear : 0
|
|
// "slide" unrolls out of the bar; "drop" falls into place and away
|
|
// downwards; "fade" fades in place; "shrink" grows from / shrinks to nothing.
|
|
property string style: "slide"
|
|
// Fill and timing; notch mode passes the notch's own.
|
|
property color fillColor: Qt.alpha(Theme.surface, Theme.glassOpacity)
|
|
property real openDuration: Theme.duration * 1.8
|
|
property real closeDuration: Theme.duration
|
|
readonly property bool unrolls: style === "slide"
|
|
property real progress: open ? 1 : 0
|
|
readonly property real revealed: unrolls ? Math.max(0, contentHeight * progress) : contentHeight
|
|
// Drop moves down on the way in and on the way out.
|
|
property real dropFrom: -1
|
|
onOpenChanged: dropFrom = open ? -1 : 1
|
|
readonly property bool shown: progress > 0.001
|
|
readonly property bool settled: !anim.running && open
|
|
// Input/hover region: the full body as soon as it opens (the pointer may
|
|
// reach the drawer before the reveal finishes), the visible part while closing.
|
|
readonly property alias body: area
|
|
readonly property bool hovered: hover.hovered
|
|
// Content parent, for items reparented in at runtime.
|
|
readonly property alias container: inner
|
|
// Enter: emphasized decelerate; exit: emphasized accelerate (Material 3).
|
|
Behavior on progress {
|
|
NumberAnimation {
|
|
id: anim
|
|
duration: root.open ? root.openDuration : root.closeDuration
|
|
easing.type: Easing.BezierSpline
|
|
easing.bezierCurve: root.open ? [0.05, 0.7, 0.1, 1, 1, 1] : [0.3, 0, 0.8, 0.15, 1, 1]
|
|
}
|
|
}
|
|
implicitWidth: contentWidth + 2 * ear
|
|
implicitHeight: contentHeight
|
|
width: implicitWidth
|
|
height: implicitHeight
|
|
|
|
// Input/hover region stays put; only the drawn drawer animates.
|
|
Item {
|
|
id: area
|
|
x: root.ear
|
|
width: root.contentWidth
|
|
height: root.open ? root.contentHeight : root.revealed
|
|
}
|
|
// On the root so it wraps the content: a sibling under the content would
|
|
// lose hover to the content's own hover areas.
|
|
HoverHandler {
|
|
id: hover
|
|
}
|
|
Item {
|
|
id: motion
|
|
width: root.width
|
|
height: root.height
|
|
opacity: root.style === "fade" || root.style === "drop" ? root.progress : root.style === "shrink" ? Math.min(1, root.progress * 1.5) : 1
|
|
scale: root.style === "shrink" ? Math.max(0.001, root.progress) : 1
|
|
transformOrigin: Item.Center
|
|
transform: Translate {
|
|
y: root.style === "drop" ? (1 - root.progress) * 28 * root.dropFrom * Math.max(0.3, Theme.intensity) : 0
|
|
}
|
|
DrawerShape {
|
|
id: shape
|
|
bodyWidth: root.contentWidth
|
|
bodyHeight: root.revealed
|
|
ear: BarDrawers.ear
|
|
attached: root.attached
|
|
fillColor: root.fillColor
|
|
}
|
|
Item {
|
|
id: hit
|
|
x: root.ear
|
|
width: root.contentWidth
|
|
height: root.revealed
|
|
clip: true
|
|
Item {
|
|
id: inner
|
|
width: root.contentWidth
|
|
height: root.contentHeight
|
|
y: root.revealed - root.contentHeight
|
|
opacity: root.unrolls ? Math.min(1, root.progress * 1.6) : 1
|
|
}
|
|
}
|
|
}
|
|
|
|
readonly property bool joined: attached && (unrolls ? shown : progress > 0.5)
|
|
readonly property var gapKey: [joined, screenName, Math.round(screenX), Math.round(width)]
|
|
onGapKeyChanged: syncGap()
|
|
Component.onCompleted: syncGap()
|
|
Component.onDestruction: if (drawerId)
|
|
BarDrawers.clearGap(drawerId)
|
|
function syncGap() {
|
|
if (!drawerId)
|
|
return;
|
|
if (joined && screenName)
|
|
BarDrawers.setGap(drawerId, screenName, screenX, screenX + width);
|
|
else
|
|
BarDrawers.clearGap(drawerId);
|
|
}
|
|
}
|