forked from Shinonome/dots-hyprland
make bar work with bottom position
This commit is contained in:
@@ -36,45 +36,71 @@ HAbstractMorphedPanel {
|
||||
function getHug(cornerStyle) {
|
||||
return cornerStyle === 0;
|
||||
}
|
||||
property int reservedArea: barHeight + getEdgeGap(Config.options.bar.cornerStyle)
|
||||
|
||||
// Some info
|
||||
reservedTop: barHeight + getEdgeGap(Config.options.bar.cornerStyle)
|
||||
reservedTop: Config.options.bar.bottom ? 0 : reservedArea
|
||||
reservedBottom: Config.options.bar.bottom ? reservedArea : 0
|
||||
|
||||
// Background
|
||||
backgroundPolygon: {
|
||||
// It's certainly cleaner to have the below props declared outside, but we do this
|
||||
// to make sure config change only makes this re-evaluate exactly once
|
||||
// to make sure a config change only makes this re-evaluate exactly once
|
||||
const bottom = Config.options.bar.bottom
|
||||
const cornerStyle = Config.options.bar.cornerStyle
|
||||
const rounding = root.getRounding(cornerStyle)
|
||||
const edgeGap = root.getEdgeGap(cornerStyle)
|
||||
const edgeRounding = root.getEdgeRounding(cornerStyle)
|
||||
const hug = root.getHug(cornerStyle)
|
||||
const points = [
|
||||
const xLeft = edgeGap
|
||||
const xRight = root.screenWidth - edgeGap
|
||||
const yTop = bottom ? (root.screenHeight - edgeGap - barHeight) : edgeGap
|
||||
const yBottom = bottom ? (root.screenHeight - edgeGap) : (edgeGap + barHeight)
|
||||
const topRounding = bottom ? rounding : edgeRounding
|
||||
const bottomRounding = bottom ? edgeRounding : rounding
|
||||
var topCornerDirection, bottomCornerDirection;
|
||||
if (cornerStyle === 2) { // Rect
|
||||
topCornerDirection = 0;
|
||||
bottomCornerDirection = 0;
|
||||
} else if (cornerStyle === 1) { // Rect
|
||||
topCornerDirection = 1;
|
||||
bottomCornerDirection = -1;
|
||||
} else { // Hug
|
||||
topCornerDirection = bottom ? -1 : 1;
|
||||
bottomCornerDirection = bottom ? -1 : 1;
|
||||
}
|
||||
|
||||
const points = [
|
||||
// bottom-middle
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth / 2, root.barHeight + edgeGap), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth * 1/2, yBottom), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth * 0.1, yBottom), new CornerRounding.CornerRounding(0)),
|
||||
|
||||
// bottom-left /||
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap + rounding, edgeGap + barHeight), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap + barHeight), new CornerRounding.CornerRounding(rounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap + barHeight + rounding * (hug ? 1 : -1)), new CornerRounding.CornerRounding(edgeRounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xLeft + rounding, yBottom), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xLeft, yBottom), new CornerRounding.CornerRounding(bottomRounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xLeft, yBottom + rounding * bottomCornerDirection), new CornerRounding.CornerRounding(edgeRounding)),
|
||||
// top-left |/-
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap + rounding), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap), new CornerRounding.CornerRounding(edgeRounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap + rounding, edgeGap), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xLeft, yTop + rounding * topCornerDirection), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xLeft, yTop), new CornerRounding.CornerRounding(topRounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xLeft + rounding, yTop), new CornerRounding.CornerRounding(0)),
|
||||
|
||||
// top-middle
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth / 2, edgeGap), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth * 0.1, yTop), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth * 1/2, yTop), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth * 0.9, yTop), new CornerRounding.CornerRounding(0)),
|
||||
|
||||
// top-right -\|
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap - rounding, edgeGap), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap, edgeGap), new CornerRounding.CornerRounding(edgeRounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap, edgeGap + rounding), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xRight - rounding, yTop), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xRight, yTop), new CornerRounding.CornerRounding(topRounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xRight, yTop + rounding * topCornerDirection), new CornerRounding.CornerRounding(0)),
|
||||
|
||||
// bottom-right ||\
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap, root.barHeight + edgeGap + rounding * (hug ? 1 : -1)), new CornerRounding.CornerRounding(edgeRounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap, root.barHeight + edgeGap), new CornerRounding.CornerRounding(rounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap - rounding, root.barHeight + edgeGap), new CornerRounding.CornerRounding(0)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xRight, yBottom + rounding * bottomCornerDirection), new CornerRounding.CornerRounding(edgeRounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xRight, yBottom), new CornerRounding.CornerRounding(bottomRounding)),
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(xRight - rounding, yBottom), new CornerRounding.CornerRounding(0)),
|
||||
|
||||
// bottom-middle
|
||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth * 0.9, yBottom), new CornerRounding.CornerRounding(0)),
|
||||
]
|
||||
return MaterialShapes.customPolygon(points, 1, new Offset.Offset(root.screenWidth / 2, edgeGap + barHeight / 2))
|
||||
}
|
||||
@@ -83,7 +109,26 @@ HAbstractMorphedPanel {
|
||||
implicitHeight: barHeight + getEdgeGap(Config.options.bar.cornerStyle) * 2
|
||||
anchors {
|
||||
top: parent.top
|
||||
bottom: undefined
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
states: State {
|
||||
name: "bottom"
|
||||
when: Config.options.bar.bottom
|
||||
AnchorChanges {
|
||||
target: root
|
||||
anchors.top: undefined
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
}
|
||||
}
|
||||
transitions: Transition {
|
||||
AnchorAnimation {
|
||||
duration: 500
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Appearance.animationCurves.expressiveDefaultSpatial
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user