summaryrefslogtreecommitdiff
path: root/bar
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-07-14 23:22:24 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-07-14 23:22:24 +0800
commit318965ec16b11b2e5b454978a282521e74b2220a (patch)
treed1e34b306074fd904aa4ca6832e092df7d1c80ff /bar
parent4f23c7746a1fc310db93d34711aa526b21f654b3 (diff)
more animation + custom strip text
Diffstat (limited to 'bar')
-rw-r--r--bar/ActiveWindow.qml81
1 files changed, 75 insertions, 6 deletions
diff --git a/bar/ActiveWindow.qml b/bar/ActiveWindow.qml
index 4bc3f09..5727e3a 100644
--- a/bar/ActiveWindow.qml
+++ b/bar/ActiveWindow.qml
@@ -12,34 +12,103 @@ Rectangle {
property var toplevel: Hyprland.activeToplevel
property var icon: Quickshell.iconPath(AppSearch.guessIcon(toplevel?.wayland?.appId), "image-missing")
+ property var activated: ToplevelManager.activeToplevel?.activated || false
+
// use IRect
- implicitWidth: rowLayout.implicitWidth + General.rectMargin * 4
+ implicitWidth: activated ? rowLayout.implicitWidth + General.rectMargin * 4 : 0
implicitHeight: rowLayout.implicitHeight + General.rectMargin * 2
anchors.centerIn: parent
color: Colors.alt
// according to docs, null could happen but doesn't seem to happen in practice so..
// hypr toplevel.activated is always true and doesn't change either so..
- opacity: ToplevelManager.activeToplevel?.activated ? 1 : 0
+ opacity: activated ? 1 : 0
radius: Style.rounding.smaller
+ function strip(s) {
+ var out = s;
+ Bar.windowStrip.forEach(function (w) {
+ out = out.replace(new RegExp(w, "g"), "");
+ });
+ return out;
+ }
+
RowLayout {
id: rowLayout
anchors.centerIn: parent
spacing: Bar.resourceIconTextSpacing
IconImage {
+ id: icon
source: root.icon
implicitWidth: Bar.appIconSize
implicitHeight: Bar.appIconSize
- Layout.fillHeight: true
- Layout.fillWidth: false
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+
+ // sync animation
+ opacity: root.activated ? 1 : 0
+ Behavior on opacity {
+ NumberAnimation {
+ duration: General.animateDuration / 2.5
+ }
+ }
+ Layout.preferredWidth: Bar.appIconSize
+ Layout.preferredHeight: Bar.appIconSize
+ Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
}
+
IText {
+ animate: true
font.pixelSize: General.fontSize
- text: root?.toplevel?.wayland?.title || ""
+ text: strip(root?.toplevel?.wayland?.title) || ""
+
+ // sync animation
+ opacity: root.activated ? 1 : 0
+ Behavior on opacity {
+ NumberAnimation {
+ duration: General.animateDuration / 2.5
+ }
+ }
+ }
+ }
+
+ onIconChanged: fadeIcon.start()
+
+ Behavior on opacity {
+ NumberAnimation {
+ duration: General.animateDuration / 2.5
+ }
+ }
+
+ Behavior on implicitWidth {
+ ISpringAnimation {
+ property: "implicitWidth"
+ spring: General.springAnimationSpring * 2
+ damping: General.springAnimationDamping * 1.3
+ }
+ }
+
+ SequentialAnimation {
+ id: fadeIcon
+ running: false
+
+ PropertyAnimation {
+ target: icon
+ property: "opacity"
+ to: 0
+ duration: General.animateDuration / 3
+ }
+ ScriptAction {
+ script: icon.source = root.icon
+ }
+ PropertyAnimation {
+ target: icon
+ property: "opacity"
+ to: 1
+ duration: General.animateDuration / 3
+ }
+ ScriptAction {
+ script: icon.source = root.icon
}
}
}