pragma Singleton import QtQuick import Quickshell import "../services" import "../theme" // Caelestia-style drawers: popups that grow out of the bar's bottom edge as one // continuous shape. Drawers register the span they occupy so the bar can open // its border there; geometry helpers keep every drawer on the bar's straight edge. Singleton { id: root readonly property int margin: ConfigService.ready ? ConfigService.data.bar.margin : 10 readonly property int height: ConfigService.ready ? ConfigService.data.bar.height : 48 // Screen y of the bar's bottom edge, where drawers attach. readonly property int bottom: margin + height readonly property real radius: Math.min(Theme.radius, height / 2) // Concave fillet joining a drawer to the bar. readonly property real ear: Math.max(8, Math.min(18, Theme.radius * 0.8)) // The bar window reaches this far below the bar so its glass edge never // lands on the join (HyprGlass refracts at layer box edges). readonly property int overhang: 28 // screen name -> [{id, x0, x1}] in screen coordinates. property var gaps: ({}) function setGap(id, screenName, x0, x1) { const next = Object.assign({}, gaps); for (const key in next) next[key] = next[key].filter(g => g.id !== id); if (screenName) next[screenName] = (next[screenName] || []).concat([ { id: id, x0: x0, x1: x1 } ]); gaps = next; } function clearGap(id) { setGap(id, "", 0, 0); } function gapsFor(screenName) { return gaps[screenName] || []; } // Left edge (screen x) for a drawer of `outerWidth` (body plus both ears) // centred on `centerX`, kept within the bar's straight bottom edge. function clampX(centerX, outerWidth, screenWidth) { const lo = margin + radius, hi = screenWidth - margin - radius - outerWidth; return Math.round(Math.max(lo, Math.min(centerX - outerWidth / 2, hi))); } function leftX() { return Math.round(margin + radius); } function rightX(outerWidth, screenWidth) { return Math.round(screenWidth - margin - radius - outerWidth); } }