forked from Shinonome/dots-hyprland
make bar work with bottom position
This commit is contained in:
@@ -15,8 +15,12 @@ Item {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
// To be fed
|
// To be fed
|
||||||
required property int screenWidth
|
property int screenWidth: QsWindow.window.width
|
||||||
required property int screenHeight
|
property int screenHeight: QsWindow.window.height
|
||||||
|
|
||||||
|
// Signals
|
||||||
|
signal requestFocus()
|
||||||
|
signal dismissed()
|
||||||
|
|
||||||
// Some info
|
// Some info
|
||||||
property int reservedTop: 0
|
property int reservedTop: 0
|
||||||
|
|||||||
@@ -36,45 +36,71 @@ HAbstractMorphedPanel {
|
|||||||
function getHug(cornerStyle) {
|
function getHug(cornerStyle) {
|
||||||
return cornerStyle === 0;
|
return cornerStyle === 0;
|
||||||
}
|
}
|
||||||
|
property int reservedArea: barHeight + getEdgeGap(Config.options.bar.cornerStyle)
|
||||||
|
|
||||||
// Some info
|
// Some info
|
||||||
reservedTop: barHeight + getEdgeGap(Config.options.bar.cornerStyle)
|
reservedTop: Config.options.bar.bottom ? 0 : reservedArea
|
||||||
|
reservedBottom: Config.options.bar.bottom ? reservedArea : 0
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
backgroundPolygon: {
|
backgroundPolygon: {
|
||||||
// It's certainly cleaner to have the below props declared outside, but we do this
|
// 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 cornerStyle = Config.options.bar.cornerStyle
|
||||||
const rounding = root.getRounding(cornerStyle)
|
const rounding = root.getRounding(cornerStyle)
|
||||||
const edgeGap = root.getEdgeGap(cornerStyle)
|
const edgeGap = root.getEdgeGap(cornerStyle)
|
||||||
const edgeRounding = root.getEdgeRounding(cornerStyle)
|
const edgeRounding = root.getEdgeRounding(cornerStyle)
|
||||||
const hug = root.getHug(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
|
// 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 /||
|
// bottom-left /||
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap + rounding, edgeGap + barHeight), new CornerRounding.CornerRounding(0)),
|
new MaterialShapes.PointNRound(new Offset.Offset(xLeft + rounding, yBottom), new CornerRounding.CornerRounding(0)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap + barHeight), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(xLeft, yBottom), new CornerRounding.CornerRounding(bottomRounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap + barHeight + rounding * (hug ? 1 : -1)), new CornerRounding.CornerRounding(edgeRounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(xLeft, yBottom + rounding * bottomCornerDirection), new CornerRounding.CornerRounding(edgeRounding)),
|
||||||
// top-left |/-
|
// top-left |/-
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap + rounding), new CornerRounding.CornerRounding(0)),
|
new MaterialShapes.PointNRound(new Offset.Offset(xLeft, yTop + rounding * topCornerDirection), new CornerRounding.CornerRounding(0)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap), new CornerRounding.CornerRounding(edgeRounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(xLeft, yTop), new CornerRounding.CornerRounding(topRounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap + rounding, edgeGap), new CornerRounding.CornerRounding(0)),
|
new MaterialShapes.PointNRound(new Offset.Offset(xLeft + rounding, yTop), new CornerRounding.CornerRounding(0)),
|
||||||
|
|
||||||
// top-middle
|
// 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 -\|
|
// top-right -\|
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap - rounding, edgeGap), new CornerRounding.CornerRounding(0)),
|
new MaterialShapes.PointNRound(new Offset.Offset(xRight - rounding, yTop), new CornerRounding.CornerRounding(0)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap, edgeGap), new CornerRounding.CornerRounding(edgeRounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(xRight, yTop), new CornerRounding.CornerRounding(topRounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap, edgeGap + rounding), new CornerRounding.CornerRounding(0)),
|
new MaterialShapes.PointNRound(new Offset.Offset(xRight, yTop + rounding * topCornerDirection), new CornerRounding.CornerRounding(0)),
|
||||||
|
|
||||||
// bottom-right ||\
|
// 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(xRight, yBottom + rounding * bottomCornerDirection), 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(xRight, yBottom), new CornerRounding.CornerRounding(bottomRounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap - rounding, root.barHeight + edgeGap), new CornerRounding.CornerRounding(0)),
|
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))
|
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
|
implicitHeight: barHeight + getEdgeGap(Config.options.bar.cornerStyle) * 2
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
|
bottom: undefined
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,30 +13,32 @@ HAbstractMorphedPanel {
|
|||||||
property int edgeGap: Appearance.sizes.hyprlandGapsOut
|
property int edgeGap: Appearance.sizes.hyprlandGapsOut
|
||||||
property real rounding: Appearance.rounding.windowRounding
|
property real rounding: Appearance.rounding.windowRounding
|
||||||
property real contentHeight: 300 // For now
|
property real contentHeight: 300 // For now
|
||||||
|
property real contentWidth: root.screenWidth * 0.9
|
||||||
|
property real horizontalGap: (root.screenWidth - contentWidth) / 2
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
backgroundPolygon: MaterialShapes.customPolygon([
|
backgroundPolygon: MaterialShapes.customPolygon([
|
||||||
// bottom-middle
|
// bottom-middle
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth / 2, edgeGap + root.contentHeight), new CornerRounding.CornerRounding(0)),
|
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth / 2, edgeGap + root.contentHeight), new CornerRounding.CornerRounding(0)),
|
||||||
// bottom-left
|
// bottom-left
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap + rounding, edgeGap + root.contentHeight), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(horizontalGap + rounding, edgeGap + root.contentHeight), new CornerRounding.CornerRounding(rounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap + root.contentHeight), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(horizontalGap, edgeGap + root.contentHeight), new CornerRounding.CornerRounding(rounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap + root.contentHeight - rounding), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(horizontalGap, edgeGap + root.contentHeight - rounding), new CornerRounding.CornerRounding(rounding)),
|
||||||
// top-left
|
// top-left
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap + rounding), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(horizontalGap, edgeGap + rounding), new CornerRounding.CornerRounding(rounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap, edgeGap), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(horizontalGap, edgeGap), new CornerRounding.CornerRounding(rounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(edgeGap + rounding, edgeGap), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(horizontalGap + rounding, edgeGap), new CornerRounding.CornerRounding(rounding)),
|
||||||
// top-middle
|
// top-middle
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth / 2, edgeGap), new CornerRounding.CornerRounding(0)),
|
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth / 2, edgeGap), new CornerRounding.CornerRounding(0)),
|
||||||
// top-right
|
// top-right
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap - rounding, edgeGap), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - horizontalGap - rounding, edgeGap), new CornerRounding.CornerRounding(rounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap, edgeGap), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - horizontalGap, edgeGap), new CornerRounding.CornerRounding(rounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap, edgeGap + rounding), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - horizontalGap, edgeGap + rounding), new CornerRounding.CornerRounding(rounding)),
|
||||||
|
|
||||||
// bottom-right
|
// bottom-right
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap, edgeGap + root.contentHeight - rounding), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - horizontalGap, edgeGap + root.contentHeight - rounding), new CornerRounding.CornerRounding(rounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap, edgeGap + root.contentHeight), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - horizontalGap, edgeGap + root.contentHeight), new CornerRounding.CornerRounding(rounding)),
|
||||||
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - edgeGap - rounding, edgeGap + root.contentHeight), new CornerRounding.CornerRounding(rounding)),
|
new MaterialShapes.PointNRound(new Offset.Offset(root.screenWidth - horizontalGap - rounding, edgeGap + root.contentHeight), new CornerRounding.CornerRounding(rounding)),
|
||||||
], 1, new Offset.Offset(root.screenWidth / 2, edgeGap + contentHeight / 2))
|
], 1, new Offset.Offset(root.screenWidth / 2, edgeGap + contentHeight / 2))
|
||||||
|
|
||||||
// Keybinds
|
// Keybinds
|
||||||
@@ -72,4 +74,15 @@ HAbstractMorphedPanel {
|
|||||||
GlobalStates.superReleaseMightTrigger = false;
|
GlobalStates.superReleaseMightTrigger = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: GlobalStates
|
||||||
|
function onOverviewOpenChanged() {
|
||||||
|
if (GlobalStates.overviewOpen) {
|
||||||
|
root.requestFocus();
|
||||||
|
} else {
|
||||||
|
root.dismissed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -45,15 +45,11 @@ PanelWindow {
|
|||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
easing.bezierCurve: Appearance.animationCurves.expressiveDefaultSpatial
|
easing.bezierCurve: Appearance.animationCurves.expressiveDefaultSpatial
|
||||||
}
|
}
|
||||||
// animation: SpringAnimation {
|
|
||||||
// spring: 3.5
|
|
||||||
// damping: 0.3
|
|
||||||
// }
|
|
||||||
color: Appearance.colors.colLayer0
|
color: Appearance.colors.colLayer0
|
||||||
borderWidth: (root.currentPanel === bar && Config.options.bar.cornerStyle !== 1) ? 0 : 1
|
borderWidth: (root.currentPanel === bar && Config.options.bar.cornerStyle !== 1) ? 0 : 1
|
||||||
borderColor: Appearance.colors.colLayer0Border
|
borderColor: Appearance.colors.colLayer0Border
|
||||||
visible: false // cuz there's already the shadow
|
visible: false // cuz there's already the shadow
|
||||||
// debug: true
|
debug: true
|
||||||
}
|
}
|
||||||
DropShadow {
|
DropShadow {
|
||||||
id: shadow
|
id: shadow
|
||||||
@@ -87,27 +83,18 @@ PanelWindow {
|
|||||||
|
|
||||||
////////////// Content: Panels ///////////////
|
////////////// Content: Panels ///////////////
|
||||||
|
|
||||||
|
function dismiss() {
|
||||||
|
root.currentPanel = bar;
|
||||||
|
}
|
||||||
|
|
||||||
HBar {
|
HBar {
|
||||||
id: bar
|
id: bar
|
||||||
screenWidth: root.width
|
|
||||||
screenHeight: root.height
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HOverview {
|
HOverview {
|
||||||
id: overview
|
id: overview
|
||||||
screenWidth: root.width
|
onRequestFocus: root.currentPanel = overview;
|
||||||
screenHeight: root.height
|
onDismissed: root.dismiss();
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: GlobalStates
|
|
||||||
function onOverviewOpenChanged() {
|
|
||||||
if (GlobalStates.overviewOpen) {
|
|
||||||
currentPanel = overview;
|
|
||||||
} else {
|
|
||||||
currentPanel = bar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////// Components /////////////////
|
//////////////// Components /////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user