diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-28 14:01:27 +0800 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-28 14:01:27 +0800 |
| commit | 10f48f2b6be2332da5b5859222a58fc8ccf5f213 (patch) | |
| tree | e9d6dc548208b3d5efd8b705c0d5be0fc35d0637 /modules | |
| parent | dashboard: fix media visualiser spacing (diff) | |
| download | caelestia-shell-10f48f2b6be2332da5b5859222a58fc8ccf5f213.tar.gz caelestia-shell-10f48f2b6be2332da5b5859222a58fc8ccf5f213.tar.bz2 caelestia-shell-10f48f2b6be2332da5b5859222a58fc8ccf5f213.zip | |
bar: crossfade active window title
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/bar/components/ActiveWindow.qml | 67 |
1 files changed, 46 insertions, 21 deletions
diff --git a/modules/bar/components/ActiveWindow.qml b/modules/bar/components/ActiveWindow.qml index 6ac4b89..8195b51 100644 --- a/modules/bar/components/ActiveWindow.qml +++ b/modules/bar/components/ActiveWindow.qml @@ -17,11 +17,13 @@ Item { Item { id: child + property Item current: text1 + anchors.centerIn: parent clip: true - implicitWidth: Math.max(icon.implicitWidth, text.implicitHeight) - implicitHeight: icon.implicitHeight + text.implicitWidth + text.anchors.topMargin + implicitWidth: Math.max(icon.implicitWidth, current.implicitHeight) + implicitHeight: icon.implicitHeight + current.implicitWidth + current.anchors.topMargin MaterialIcon { id: icon @@ -33,26 +35,12 @@ Item { anchors.horizontalCenter: parent.horizontalCenter } - StyledText { - id: text - - anchors.horizontalCenter: icon.horizontalCenter - anchors.top: icon.bottom - anchors.topMargin: Appearance.spacing.small - - text: metrics.elidedText - font.pointSize: metrics.font.pointSize - font.family: metrics.font.family - color: root.colour - - transform: Rotation { - angle: 90 - origin.x: text.implicitHeight / 2 - origin.y: text.implicitHeight / 2 - } + Title { + id: text1 + } - width: implicitHeight - height: implicitWidth + Title { + id: text2 } TextMetrics { @@ -63,6 +51,13 @@ Item { font.family: Appearance.font.family.mono elide: Qt.ElideRight elideWidth: root.height - icon.height + + onTextChanged: { + const next = child.current === text1 ? text2 : text1; + next.text = elidedText; + child.current = next; + } + onElideWidthChanged: child.current.text = elidedText } Behavior on implicitWidth { @@ -81,4 +76,34 @@ Item { } } } + + component Title: StyledText { + id: text + + anchors.horizontalCenter: icon.horizontalCenter + anchors.top: icon.bottom + anchors.topMargin: Appearance.spacing.small + + font.pointSize: metrics.font.pointSize + font.family: metrics.font.family + color: root.colour + opacity: child.current === this ? 1 : 0 + + transform: Rotation { + angle: 90 + origin.x: text.implicitHeight / 2 + origin.y: text.implicitHeight / 2 + } + + width: implicitHeight + height: implicitWidth + + Behavior on opacity { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } + } + } } |