Files
qbz/crates/qbz-qt/qml/controls/PanelResizeHandle.qml
T
vicrodh dc158bd9b6 feat(shell): resizable playlist sidebar and queue/lyrics column (#771)
Both panels were fixed-width (240 / 300); playlist names elided on wide
monitors. Each panel's visible edge (the content pane's edge, 8px past the
panel — the bezel between them shares the panel colour) now carries a 5px
grab strip with a 2x28 notch, split cursor, and a one-shot accent pulse when
a drag lands on a snap point.

Rules live in `panel_resize.rs` (pure, unit-tested), the bridge applies them
live and persists on release (`ui_prefs` `sidebar_width` / `queue_panel_width`,
clamped on read):
- sidebar: 240..480 while open; below 200 it snaps to the mini rail, below 24
  it closes through the same state the header button uses (with the Large-NPB
  fallback); the mini rail reopens at 220 — a 20px hysteresis band so no
  pointer x can flip open<->mini on every move (the flapping seen in the
  2026-09-11 screencast). The stored width never drops below 240, so
  reopening restores the last open width. A state snap during a drag still
  animates: the bridge raises `sidebarSnapping` before the state change and
  Sidebar's width Behavior honours it while the drag otherwise disables it.
- column: 300..600; below 260 it closes queue and lyrics as their X would.
  With the queue in the column and the width parked at 600, the notch shows a
  steady larger glow toward the content; pushing 60px further opens the
  Listen List (queue-view) and the queue leaves the column, lyrics staying
  if open. A lyrics-only column never pushes through.

The Large-NPB dock is untouched: it is mounted with absolute x/width in
AppShell and reads nothing from the sidebar width.

Verified: panel_resize 9/9, qmllint + the six qt-run.sh audits, release
builds v1-v4, four owner smoke rounds.

cc
2026-09-11 13:09:47 -06:00

108 lines
3.9 KiB
QML

// Edge drag handle for a resizable shell panel (#771) — the playlist sidebar's
// right edge and the queue/lyrics column's left edge.
//
// It owns NOTHING but the pointer: every drag position is handed to the host
// through `dragged(px)` and the host (AppShell) forwards it to the bridge,
// where `panel_resize.rs` decides clamp / snap / close. `released()` is where
// the host persists. `active` mirrors the press so the host can suspend the
// panel's width animation while the pointer is driving it (a 160 ms Behavior
// fighting a mouse reads as lag).
//
// Where it sits: on the border the user SEES. The panel's own edge is
// invisible — the content frame's 8px bezel is the same colour as the panel
// (AppShell.qml `contentFrame`) — so the visible line is the content PANE's
// edge, 8px in. The host places the strip there (owner, 2026-09-11, with the
// pointer screenshot: "ahí debería estar el grabber").
//
// Visual: one 2x28 notch in border-muted, vertically centred on the border
// (the Local Library tree rail draws a full-height line that lights up in
// accent; this is the "much more subtle" version the owner asked for). It
// brightens a little on hover/press, and `pulse()` — called by the host when
// a drag reaches a snap point (min, max, mini) — runs ONE short accent fade
// behind it. Nothing here ticks: the fade is a one-shot that ends.
import QtQuick
import "../theme"
Item {
id: root
width: 5
/// The px the host cares about, in the host's coordinate space: for the
/// sidebar the pointer's x (a width from the window's left edge); for
/// the right column the host converts to a width itself.
signal dragged(real px)
signal released()
readonly property bool active: area.pressed
readonly property bool lit: area.containsMouse || area.pressed
/// One accent pulse behind the notch — the host calls it when the drag
/// reaches a snap point. Restarting mid-fade is fine (it just re-peaks).
function pulse() {
glowFade.restart()
}
/// "There is more past here": a steady, slightly larger glow that leans
/// toward `beyondSide` (-1 = left, +1 = right) while the host says the
/// drag is parked at a range end that can push through to something
/// else (the queue column at its maximum -> Listen List). Static while
/// on; nothing ticks.
property bool beyond: false
property int beyondSide: -1
Rectangle {
visible: root.beyond
anchors.verticalCenter: parent.verticalCenter
x: root.beyondSide < 0 ? (root.width / 2) - width + 2 : (root.width / 2) - 2
width: 12
height: 44
radius: 6
color: theme.accent
opacity: 0.28
}
Rectangle {
id: glow
anchors.centerIn: parent
width: 4
height: 34
radius: 2
color: theme.accent
opacity: 0.0
SequentialAnimation {
id: glowFade
NumberAnimation { target: glow; property: "opacity"; to: 0.55; duration: 60 }
NumberAnimation { target: glow; property: "opacity"; to: 0.0; duration: 260; easing.type: Easing.OutQuad }
}
}
Rectangle {
id: notch
anchors.centerIn: parent
width: 2
height: 28
radius: 1
color: theme.borderMuted
opacity: root.lit ? 0.95 : 0.55
}
MouseArea {
id: area
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.SplitHCursor
acceptedButtons: Qt.LeftButton
// The strip is 5px wide: the pointer leaves it on the first move, so
// the press must keep delivering moves to us, not to what is under.
preventStealing: true
onPositionChanged: function (mouse) {
if (!pressed)
return
const p = area.mapToItem(root.parent, mouse.x, mouse.y)
root.dragged(p.x)
}
onReleased: root.released()
onCanceled: root.released()
}
}