import QtQuick import QtQuick.Shapes import "../theme" // Drawer body hanging from the bar: concave "ears" blend it into the bar's // bottom edge and its top side has no border, so bar and drawer read as one // shape. `bodyHeight` is the revealed height; detached drawers are plain cards. Item { id: root property real bodyWidth: 300 property real bodyHeight: 200 property real ear: 16 property real radius: Theme.radius property bool attached: true property color fillColor: Qt.alpha(Theme.surface, Theme.glassOpacity) property color borderColor: Theme.border implicitWidth: bodyWidth + (attached ? 2 * ear : 0) implicitHeight: bodyHeight readonly property real w: implicitWidth readonly property real h: Math.max(0, bodyHeight) // Ears and corners shrink while the drawer is still short. readonly property real e: Math.min(ear, h) readonly property real r: Math.max(0, Math.min(radius, h - e, bodyWidth / 2)) readonly property string body: { const W = w, E = ear, h = root.h, e = root.e, r = root.r; return `L ${W - E} ${h - r} A ${r} ${r} 0 0 1 ${W - E - r} ${h} L ${E + r} ${h} A ${r} ${r} 0 0 1 ${E} ${h - r} L ${E} ${e}`; } visible: h > 0.5 Shape { anchors.fill: parent visible: root.attached preferredRendererType: Shape.CurveRenderer ShapePath { fillColor: root.fillColor strokeColor: "transparent" strokeWidth: 0 PathSvg { path: `M 0 0 L ${root.w} 0 A ${root.ear} ${root.e} 0 0 0 ${root.w - root.ear} ${root.e} ${root.body} A ${root.ear} ${root.e} 0 0 0 0 0 Z` } } // Outline everywhere except along the bar. ShapePath { fillColor: "transparent" strokeColor: root.borderColor strokeWidth: 1 PathSvg { path: `M 0 0.5 A ${root.ear} ${root.e} 0 0 1 ${root.ear} ${root.e} L ${root.ear} ${root.h - root.r} A ${root.r} ${root.r} 0 0 0 ${root.ear + root.r} ${root.h - 0.5} L ${root.w - root.ear - root.r} ${root.h - 0.5} A ${root.r} ${root.r} 0 0 0 ${root.w - root.ear} ${root.h - root.r} L ${root.w - root.ear} ${root.e} A ${root.ear} ${root.e} 0 0 1 ${root.w} 0.5` } } } Rectangle { anchors.fill: parent visible: !root.attached radius: Math.min(root.radius, root.h / 2) color: root.fillColor border.width: 1 border.color: root.borderColor } }