import QtQuick import Quickshell import "../services" import "../theme" // Notch mode's own panel animation (BarDrawer swaps to it while notch mode // is on). There is no bar to unroll from, so a glass bead swells out under the // clicked island icon on a tapered neck, works as a lens on the wallpaper // while it hangs, then widens into the panel and lets go of the island. // Drawer-local coordinates; `progress` runs linearly, the easing lives here. Item { id: root property real progress: 0 property real bodyX: 0 property real bodyWidth: 300 property real bodyHeight: 200 // Drawer-local x of the icon the panel belongs to; -1 is the middle. property real sourceX: -1 // Distance from the screen top to the drawer's top edge. property real topSpace: 0 // Drawer-local y of the islands' bottom edge (negative: above the drawer). property real islandBottom: -5 property real radius: Theme.radius property color fillColor: Qt.alpha(Theme.surface, Theme.glassOpacity) property color borderColor: Theme.border property string screenName: "" property real screenX: 0 y: -topSpace height: topSpace + bodyHeight visible: progress > 0.002 function clamp(x, a, b) { return Math.min(b, Math.max(a, x)); } function lerp(a, b, t) { return a + (b - a) * t; } function sstep(a, b, x) { const t = clamp((x - a) / (b - a), 0, 1); return t * t * (3 - 2 * t); } function out3(t) { return 1 - Math.pow(1 - clamp(t, 0, 1), 3); } readonly property var g: { const p = progress, W = bodyWidth, H = bodyHeight, X = bodyX; const panelR = Math.min(radius, W / 2, H / 2); // Small panels (tooltips) get a smaller bead. const bulbMax = Math.max(6, Math.min(40, W / 2 - 2, H / 2 - 2)); const top = islandBottom - 3; const sx = clamp(sourceX < 0 ? X + W / 2 : sourceX, X + bulbMax + 2, X + W - bulbMax - 2); const a = out3(p / 0.4); // bead swells and sinks const b = clamp((p - 0.3) / 0.62, 0, 1); // bead becomes the panel const eb = out3(b); const release = sstep(0.8, 0.95, p); // the neck lets go const bulbR = lerp(3, bulbMax, a); const hang = Math.max(4, Math.min(66, H - bulbMax - 2 - top)); const beadY = top + lerp(4, hang, a); // A small sideways swell as it settles, kept inside the ears. const swell = Math.sin(clamp((b - 0.55) / 0.45, 0, 1) * Math.PI) * 0.03; const halfW = Math.min(lerp(bulbR, W / 2, eb) * (1 + swell), W / 2 + X - 1); const halfH = lerp(bulbR, H / 2, eb); const cx = lerp(sx, X + W / 2, eb), cy = lerp(beadY, H / 2, eb); return { stem: Qt.vector4d(sx, top, lerp(6, 11, a) * (1 - release), lerp(bulbR * 0.9, 10, eb) * (1 - release)), stemH: lerp(beadY, 12, eb) - top, box: Qt.vector4d(cx, cy, halfW, halfH), boxR: Math.min(lerp(bulbR, panelR, eb), halfW, halfH), melt: lerp(20, 6, release), // Only the bead is a lens; it clears before the panel takes shape. lens: Qt.vector4d(cx, cy, Math.min(Math.max(halfW, halfH), bulbMax * 1.4), 1 - sstep(0.3, 0.52, p)) }; } // The wallpaper under this screen, for the lens. Loaded only while the drop // is out; the pixmap cache keeps it for the next opening. readonly property var screenObj: Quickshell.screens.find(s => s.name === screenName) || null readonly property string wallPath: { if (!screenName || !ConfigService.ready) return ""; return WallpaperService.observed[screenName] || ConfigService.data.wallpaper.byMonitor[screenName] || ""; } Image { id: wallImage visible: false asynchronous: true cache: true sourceSize.width: 1280 source: root.visible && root.wallPath ? "file://" + root.wallPath : "" } readonly property vector4d cover: { const iw = wallImage.implicitWidth, ih = wallImage.implicitHeight; const sw = screenObj ? screenObj.width : 1920, sh = screenObj ? screenObj.height : 1080; if (iw <= 0 || ih <= 0) return Qt.vector4d(0, 0, 0, 0); const sc = Math.max(sw / iw, sh / ih), w = iw * sc, h = ih * sc; return Qt.vector4d(1 / w, 1 / h, (w - sw) / 2 / w, (h - sh) / 2 / h); } ShaderEffect { anchors.fill: parent property point size: Qt.point(width, height) property real topY: -root.topSpace property vector4d stem: root.g.stem property real stemH: root.g.stemH property vector4d box: root.g.box property real boxR: root.g.boxR property real melt: root.g.melt property vector4d lens: root.g.lens property vector4d fill: Qt.vector4d(root.fillColor.r * root.fillColor.a, root.fillColor.g * root.fillColor.a, root.fillColor.b * root.fillColor.a, root.fillColor.a) property vector4d edge: Qt.vector4d(root.borderColor.r * root.borderColor.a, root.borderColor.g * root.borderColor.a, root.borderColor.b * root.borderColor.a, root.borderColor.a) property vector4d cover: root.cover property point screenOrigin: Qt.point(root.screenX, root.topSpace) property real hasWall: wallImage.status === Image.Ready ? 1 : 0 property var wall: wallImage fragmentShader: Qt.resolvedUrl("shaders/notchdrop.frag.qsb") } }