bar: add auto hide

This commit is contained in:
end-4
2025-08-08 19:54:10 +07:00
parent 3d408b18f7
commit f806e2c22c
3 changed files with 113 additions and 77 deletions
+6 -3
View File
@@ -17,11 +17,12 @@ Singleton {
property bool osdVolumeOpen: false property bool osdVolumeOpen: false
property bool oskOpen: false property bool oskOpen: false
property bool overviewOpen: false property bool overviewOpen: false
property bool sessionOpen: false
property bool workspaceShowNumbers: false
property bool superReleaseMightTrigger: true
property bool screenLocked: false property bool screenLocked: false
property bool screenLockContainsCharacters: false property bool screenLockContainsCharacters: false
property bool sessionOpen: false
property bool superDown: false
property bool superReleaseMightTrigger: true
property bool workspaceShowNumbers: false
property real screenZoom: 1 property real screenZoom: 1
onScreenZoomChanged: { onScreenZoomChanged: {
@@ -51,9 +52,11 @@ Singleton {
description: "Hold to show workspace numbers, release to show icons" description: "Hold to show workspace numbers, release to show icons"
onPressed: { onPressed: {
root.superDown = true
workspaceShowNumbersTimer.start() workspaceShowNumbersTimer.start()
} }
onReleased: { onReleased: {
root.superDown = false
workspaceShowNumbersTimer.stop() workspaceShowNumbersTimer.stop()
workspaceShowNumbers = false workspaceShowNumbers = false
} }
+101 -73
View File
@@ -39,8 +39,10 @@ Scope {
property real useShortenedForm: (Appearance.sizes.barHellaShortenScreenWidthThreshold >= screen.width) ? 2 : (Appearance.sizes.barShortenScreenWidthThreshold >= screen.width) ? 1 : 0 property real useShortenedForm: (Appearance.sizes.barHellaShortenScreenWidthThreshold >= screen.width) ? 2 : (Appearance.sizes.barShortenScreenWidthThreshold >= screen.width) ? 1 : 0
readonly property int centerSideModuleWidth: (useShortenedForm == 2) ? Appearance.sizes.barCenterSideModuleWidthHellaShortened : (useShortenedForm == 1) ? Appearance.sizes.barCenterSideModuleWidthShortened : Appearance.sizes.barCenterSideModuleWidth readonly property int centerSideModuleWidth: (useShortenedForm == 2) ? Appearance.sizes.barCenterSideModuleWidthHellaShortened : (useShortenedForm == 1) ? Appearance.sizes.barCenterSideModuleWidthShortened : Appearance.sizes.barCenterSideModuleWidth
property bool mustShow: hoverRegion.containsMouse || (Config?.options.bar.autoHide.showWhenPressingSuper && GlobalStates.superDown)
exclusionMode: ExclusionMode.Ignore exclusionMode: ExclusionMode.Ignore
exclusiveZone: Appearance.sizes.baseBarHeight + (Config.options.bar.cornerStyle === 1 ? Appearance.sizes.hyprlandGapsOut : 0) exclusiveZone: (Config?.options.bar.autoHide.enabled && (!mustShow || !Config?.options.bar.autoHide.pushWindows)) ? 0 :
Appearance.sizes.baseBarHeight + (Config.options.bar.cornerStyle === 1 ? Appearance.sizes.hyprlandGapsOut : 0)
WlrLayershell.namespace: "quickshell:bar" WlrLayershell.namespace: "quickshell:bar"
implicitHeight: Appearance.sizes.barHeight + Appearance.rounding.screenRounding implicitHeight: Appearance.sizes.barHeight + Appearance.rounding.screenRounding
mask: Region { mask: Region {
@@ -55,90 +57,116 @@ Scope {
right: true right: true
} }
BarContent { MouseArea {
id: barContent id: hoverRegion
hoverEnabled: true
anchors.fill: parent
anchors { BarContent {
right: parent.right id: barContent
left: parent.left
top: parent.top
bottom: undefined
}
implicitHeight: Appearance.sizes.barHeight
states: State { implicitHeight: Appearance.sizes.barHeight
name: "bottom" anchors {
when: Config.options.bar.bottom right: parent.right
AnchorChanges { left: parent.left
target: barContent top: parent.top
anchors { bottom: undefined
right: parent.right topMargin: (Config?.options.bar.autoHide.enabled && !mustShow) ? -Appearance.sizes.barHeight + 1 : 0
left: parent.left bottomMargin: 0
top: undefined }
bottom: parent.bottom Behavior on anchors.topMargin {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
Behavior on anchors.bottomMargin {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
states: State {
name: "bottom"
when: Config.options.bar.bottom
AnchorChanges {
target: barContent
anchors {
right: parent.right
left: parent.left
top: undefined
bottom: parent.bottom
}
}
PropertyChanges {
target: barContent
anchors.topMargin: 0
anchors.bottomMargin: (Config?.options.bar.autoHide.enabled && !mustShow) ? -Appearance.sizes.barHeight + 1 : 0
} }
} }
} }
}
// Round decorators // Round decorators
Loader { Loader {
id: roundDecorators id: roundDecorators
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right
} top: barContent.bottom
y: Appearance.sizes.barHeight bottom: undefined
width: parent.width
height: Appearance.rounding.screenRounding
active: showBarBackground && Config.options.bar.cornerStyle === 0 // Hug
states: State {
name: "bottom"
when: Config.options.bar.bottom
PropertyChanges {
roundDecorators.y: 0
} }
} width: parent.width
height: Appearance.rounding.screenRounding
active: showBarBackground && Config.options.bar.cornerStyle === 0 // Hug
sourceComponent: Item { states: State {
implicitHeight: Appearance.rounding.screenRounding name: "bottom"
RoundCorner { when: Config.options.bar.bottom
id: leftCorner AnchorChanges {
anchors { target: roundDecorators
top: parent.top anchors {
bottom: parent.bottom right: parent.right
left: parent.left left: parent.left
} top: undefined
bottom: barContent.top
implicitSize: Appearance.rounding.screenRounding
color: showBarBackground ? Appearance.colors.colLayer0 : "transparent"
corner: RoundCorner.CornerEnum.TopLeft
states: State {
name: "bottom"
when: Config.options.bar.bottom
PropertyChanges {
leftCorner.corner: RoundCorner.CornerEnum.BottomLeft
} }
} }
} }
RoundCorner {
id: rightCorner
anchors {
right: parent.right
top: !Config.options.bar.bottom ? parent.top : undefined
bottom: Config.options.bar.bottom ? parent.bottom : undefined
}
implicitSize: Appearance.rounding.screenRounding
color: showBarBackground ? Appearance.colors.colLayer0 : "transparent"
corner: RoundCorner.CornerEnum.TopRight sourceComponent: Item {
states: State { implicitHeight: Appearance.rounding.screenRounding
name: "bottom" RoundCorner {
when: Config.options.bar.bottom id: leftCorner
PropertyChanges { anchors {
rightCorner.corner: RoundCorner.CornerEnum.BottomRight top: parent.top
bottom: parent.bottom
left: parent.left
}
implicitSize: Appearance.rounding.screenRounding
color: showBarBackground ? Appearance.colors.colLayer0 : "transparent"
corner: RoundCorner.CornerEnum.TopLeft
states: State {
name: "bottom"
when: Config.options.bar.bottom
PropertyChanges {
leftCorner.corner: RoundCorner.CornerEnum.BottomLeft
}
}
}
RoundCorner {
id: rightCorner
anchors {
right: parent.right
top: !Config.options.bar.bottom ? parent.top : undefined
bottom: Config.options.bar.bottom ? parent.bottom : undefined
}
implicitSize: Appearance.rounding.screenRounding
color: showBarBackground ? Appearance.colors.colLayer0 : "transparent"
corner: RoundCorner.CornerEnum.TopRight
states: State {
name: "bottom"
when: Config.options.bar.bottom
PropertyChanges {
rightCorner.corner: RoundCorner.CornerEnum.BottomRight
}
} }
} }
} }
@@ -124,6 +124,11 @@ Singleton {
} }
property JsonObject bar: JsonObject { property JsonObject bar: JsonObject {
property JsonObject autoHide: JsonObject {
property bool enabled: false
property bool pushWindows: false
property bool showWhenPressingSuper: true
}
property bool bottom: false // Instead of top property bool bottom: false // Instead of top
property int cornerStyle: 0 // 0: Hug | 1: Float | 2: Plain rectangle property int cornerStyle: 0 // 0: Hug | 1: Float | 2: Plain rectangle
property bool borderless: false // true for no grouping of items property bool borderless: false // true for no grouping of items