From 05fa3647d355fb4e0798fff1225663b41290f4e8 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Fri, 1 Aug 2025 19:08:29 +0800 Subject: fix(ActiveWindow): properly resize text when space is unavaliable --- bar/ActiveWindow.qml | 32 +++++++++++++++++++++----------- bar/Bar.qml | 1 + 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/bar/ActiveWindow.qml b/bar/ActiveWindow.qml index 0dc1bde..db69e3e 100644 --- a/bar/ActiveWindow.qml +++ b/bar/ActiveWindow.qml @@ -40,6 +40,7 @@ IRect { id: rowLayout anchors.centerIn: parent spacing: Bar.resourceIconTextSpacing + width: Math.min(implicitWidth, root.width) IconImage { id: icon @@ -56,16 +57,25 @@ IRect { } } - IText { - animate: true - font.pixelSize: General.fontSize - text: strip(root?.toplevel?.title) || "" - - // sync animation - opacity: root.activated ? 1 : 0 - Behavior on opacity { - NumberAnimation { - duration: General.animationDuration / 4 + Item { + Layout.fillWidth: true + Layout.fillHeight: true + implicitWidth: childrenRect.width + IText { + anchors.verticalCenter: parent.verticalCenter + width: Math.min(implicitWidth, rowLayout.width - icon.implicitWidth) + animate: true + clip: true + elide: Text.ElideRight + font.pixelSize: General.fontSize + text: strip(root?.toplevel?.title) || "" + + // sync animation + opacity: root.activated ? 1 : 0 + Behavior on opacity { + NumberAnimation { + duration: General.animationDuration / 4 + } } } } @@ -79,7 +89,7 @@ IRect { } } - Behavior on implicitWidth { + Behavior on width { ISpringAnimation { spring: General.springAnimationSpring * 2 damping: General.springAnimationDamping * 1.3 diff --git a/bar/Bar.qml b/bar/Bar.qml index 93b31a6..27bc3e5 100644 --- a/bar/Bar.qml +++ b/bar/Bar.qml @@ -86,6 +86,7 @@ Scope { ActiveWindow { id: activeWindow + width: Math.min(implicitWidth, child.width - Math.max(leftRow.width, rightRow.width) * 2 - Bar.leftMargin - Bar.rightMargin) // we don't do child.width - leftRow.width - rightRow.width because left and right width isn't symetric, and we're centered meaning we will colide into the larger width side } } -- cgit v1.2.3