ScrollingText: avoid up and down jitter when appearing.

This commit is contained in:
Lemmy
2026-01-03 09:33:13 -05:00
parent b09eef4cd7
commit bb593da766
3 changed files with 12 additions and 6 deletions
+6 -4
View File
@@ -49,8 +49,10 @@ Item {
readonly property int iconSize: Style.toOdd(Style.capsuleHeight * 0.75)
readonly property int verticalSize: Style.toOdd(Style.capsuleHeight * 0.85)
implicitHeight: visible ? (isVerticalBar ? (((!hasFocusedWindow) && hideMode === "hidden") ? 0 : verticalSize) : Style.capsuleHeight) : 0
implicitWidth: visible ? (isVerticalBar ? (((!hasFocusedWindow) && hideMode === "hidden") ? 0 : verticalSize) : (((!hasFocusedWindow) && hideMode === "hidden") ? 0 : dynamicWidth)) : 0
// For horizontal bars, height is always capsuleHeight (no animation needed)
// For vertical bars, collapse to 0 when hidden
implicitHeight: isVerticalBar ? (((!hasFocusedWindow) && hideMode === "hidden") ? 0 : verticalSize) : Style.capsuleHeight
implicitWidth: isVerticalBar ? (((!hasFocusedWindow) && hideMode === "hidden") ? 0 : verticalSize) : (((!hasFocusedWindow) && hideMode === "hidden") ? 0 : dynamicWidth)
// "visible": Always Visible, "hidden": Hide When Empty, "transparent": Transparent When Empty
visible: (hideMode !== "hidden" || hasFocusedWindow) || opacity > 0
@@ -208,6 +210,7 @@ Item {
// Horizontal layout for top/bottom bars
RowLayout {
id: rowLayout
height: iconSize
y: Style.pixelAlignCenter(parent.height, height)
spacing: Style.marginS
visible: !isVerticalBar
@@ -242,6 +245,7 @@ Item {
NScrollText {
id: titleContainer
text: windowTitle
Layout.alignment: Qt.AlignVCenter
maxWidth: {
// Calculate available width based on other elements
var iconWidth = (showIcon && windowIcon.visible ? (iconSize + Style.marginS) : 0);
@@ -257,12 +261,10 @@ Item {
return NScrollText.ScrollMode.Never;
}
NText {
id: titleText
text: windowTitle
pointSize: Style.barFontSize
applyUiScale: false
font.weight: Style.fontWeightMedium
verticalAlignment: Text.AlignVCenter
color: Color.mOnSurface
}
}
+4 -2
View File
@@ -94,8 +94,10 @@ Item {
}
// Layout
implicitWidth: visible ? (isVertical ? (isHidden ? 0 : verticalSize) : (isHidden ? 0 : contentWidth)) : 0
implicitHeight: visible ? (isVertical ? (isHidden ? 0 : verticalSize) : Style.capsuleHeight) : 0
// For horizontal bars, height is always capsuleHeight (no animation needed to prevent jitter)
// For vertical bars, collapse to 0 when hidden
implicitWidth: isVertical ? (isHidden ? 0 : verticalSize) : (isHidden ? 0 : contentWidth)
implicitHeight: isVertical ? (isHidden ? 0 : verticalSize) : Style.capsuleHeight
visible: !shouldHideIdle && (hideMode !== "hidden" || opacity > 0)
opacity: isHidden ? 0.0 : ((hideMode === "transparent" && !hasPlayer) ? 0.0 : 1.0)
+2
View File
@@ -126,12 +126,14 @@ Item {
Loader {
id: titleText
sourceComponent: root.delegate
Layout.alignment: Qt.AlignVCenter
onLoaded: this.item.text = root.text
}
Loader {
id: loopingText
sourceComponent: root.delegate
Layout.alignment: Qt.AlignVCenter
visible: root.state !== NScrollText.ScrollState.None
onLoaded: this.item.text = root.text
}