bar: workspaces better anim
Also make it work for vertical
This commit is contained in:
parent
7e532dbe85
commit
123676bd42
2 changed files with 39 additions and 30 deletions
|
|
@ -19,7 +19,7 @@ BoxLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
horizontalAlignment: Text.AlignJustify
|
horizontalAlignment: Label.AlignHCenter
|
||||||
text: root.vertical ? Time.format("hh\nmm") : Time.format("dd/MM/yy hh:mm")
|
text: root.vertical ? Time.format("hh\nmm") : Time.format("dd/MM/yy hh:mm")
|
||||||
font.pointSize: Appearance.font.size.smaller
|
font.pointSize: Appearance.font.size.smaller
|
||||||
font.family: Appearance.font.family.mono
|
font.family: Appearance.font.family.mono
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ Item {
|
||||||
BoxLayout {
|
BoxLayout {
|
||||||
id: layout
|
id: layout
|
||||||
|
|
||||||
padding: [Appearance.padding.smaller / 2, 0]
|
padding: vertical ? [0, Appearance.padding.smaller / 2] : [Appearance.padding.smaller / 2, 0]
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
homogenous: true
|
homogenous: true
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
@ -32,10 +32,11 @@ Item {
|
||||||
|
|
||||||
text: index + 1
|
text: index + 1
|
||||||
color: root.colour
|
color: root.colour
|
||||||
horizontalAlignment: Label.AlignCenter
|
horizontalAlignment: Label.AlignHCenter
|
||||||
|
|
||||||
Layout.alignment: Layout.Center
|
Layout.alignment: Layout.Center
|
||||||
Layout.preferredWidth: layout.homogenous ? layout.height : -1
|
Layout.preferredWidth: layout.homogenous && !layout.vertical ? layout.height : -1
|
||||||
|
Layout.preferredHeight: layout.homogenous && layout.vertical ? layout.width : -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -43,16 +44,13 @@ Item {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: active
|
id: active
|
||||||
|
|
||||||
// property int lastIdx: 0
|
property int currentIdx: 0
|
||||||
property int currentIdx: (Hyprland.activeWorkspace?.id ?? 1) - 1
|
property int lastIdx: 0
|
||||||
readonly property real size: layout.children[currentIdx][root.vertical ? "height" : "width"]
|
property real leading: layout.children[currentIdx][root.vertical ? "y" : "x"]
|
||||||
readonly property real offset: {
|
property real trailing: layout.children[lastIdx][root.vertical ? "y" : "x"]
|
||||||
const vertical = root.vertical;
|
property real currentSize: layout.children[currentIdx][root.vertical ? "height" : "width"]
|
||||||
const child = layout.children[currentIdx];
|
property real size: Math.abs(leading - trailing) + currentSize
|
||||||
const size = child[vertical ? "height" : "width"];
|
property real offset: Math.min(leading, trailing)
|
||||||
const implicitSize = child[vertical ? "implicitHeight" : "implicitWidth"];
|
|
||||||
return child.x - (size - implicitSize) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
x: root.vertical ? 0 : offset
|
x: root.vertical ? 0 : offset
|
||||||
|
|
@ -62,6 +60,15 @@ Item {
|
||||||
color: Appearance.colours.mauve
|
color: Appearance.colours.mauve
|
||||||
radius: Appearance.rounding.full
|
radius: Appearance.rounding.full
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Hyprland
|
||||||
|
|
||||||
|
function onActiveWorkspaceChanged() {
|
||||||
|
active.currentIdx = (Hyprland.activeWorkspace?.id ?? 1) - 1;
|
||||||
|
active.lastIdx = active.currentIdx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: base
|
id: base
|
||||||
|
|
||||||
|
|
@ -78,28 +85,30 @@ Item {
|
||||||
y: root.vertical ? -parent.offset : 0
|
y: root.vertical ? -parent.offset : 0
|
||||||
width: root.width
|
width: root.width
|
||||||
height: root.height
|
height: root.height
|
||||||
|
|
||||||
Behavior on x {
|
|
||||||
Anim {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on y {
|
Behavior on leading {
|
||||||
Anim {}
|
NumberAnimation {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on x {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on y {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
component Anim: NumberAnimation {
|
|
||||||
duration: Appearance.anim.durations.normal
|
duration: Appearance.anim.durations.normal
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
easing.bezierCurve: Appearance.anim.curves.standard
|
easing.bezierCurve: Appearance.anim.curves.emphasized
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on trailing {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.anim.durations.normal * 2
|
||||||
|
easing.type: Easing.BezierSpline
|
||||||
|
easing.bezierCurve: Appearance.anim.curves.emphasized
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on currentSize {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.anim.durations.normal
|
||||||
|
easing.type: Easing.BezierSpline
|
||||||
|
easing.bezierCurve: Appearance.anim.curves.emphasized
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue