quickshell-toki-night/modules/bar/popouts/Background.qml

80 lines
2.6 KiB
QML

import qs.config
import qs.custom
import qs.services
import QtQuick
import QtQuick.Shapes
Shape {
id: root
required property Item wrapper
readonly property bool invertLeftRounding: wrapper.x <= 2
readonly property bool invertRightRounding: wrapper.x + wrapper.width >= wrapper.parent.width - 2
readonly property real rounding: Config.border.rounding
readonly property bool flatten: wrapper.height < rounding * 2
readonly property real roundingY: flatten ? wrapper.height / 2 : rounding
property real ilr: invertLeftRounding ? -1 : 1
property real irr: invertRightRounding ? -1 : 1
property real sideRounding: wrapper.y > 0 ? -1 : 1
ShapePath {
startX: -root.rounding * root.sideRounding + (invertRightRounding ? 1 : 0)
startY: -1
strokeWidth: -1
fillColor: Config.colors.bg
PathArc {
relativeX: root.rounding * root.sideRounding
relativeY: root.roundingY
radiusX: root.rounding
radiusY: Math.min(root.rounding, root.wrapper.height)
direction: root.sideRounding < 0 ? PathArc.Counterclockwise : PathArc.Clockwise
}
PathLine {
relativeX: 0
relativeY: root.wrapper.height - root.roundingY - root.roundingY * root.ilr
}
PathArc {
relativeX: root.rounding
relativeY: root.roundingY * root.ilr
radiusX: root.rounding
radiusY: Math.min(root.rounding, root.wrapper.height)
direction: root.ilr < 0 ? PathArc.Clockwise : PathArc.Counterclockwise
}
PathLine {
relativeX: root.wrapper.width - root.rounding * 2
relativeY: 0
}
PathArc {
relativeX: root.rounding
relativeY: -root.roundingY * root.irr
radiusX: root.rounding
radiusY: Math.min(root.rounding, root.wrapper.height)
direction: root.irr < 0 ? PathArc.Clockwise : PathArc.Counterclockwise
}
PathLine {
relativeX: 0
relativeY: -(root.wrapper.height - root.roundingY - root.roundingY * root.irr)
}
PathArc {
relativeX: root.rounding * root.sideRounding
relativeY: -root.roundingY
radiusX: root.rounding
radiusY: Math.min(root.rounding, root.wrapper.height)
direction: root.sideRounding < 0 ? PathArc.Counterclockwise : PathArc.Clockwise
}
}
Behavior on ilr {
Anim {}
}
Behavior on irr {
Anim {}
}
Behavior on sideRounding {
Anim {}
}
}