osd: fix text not updating during transition

This commit is contained in:
2 * r + 2 * t 2025-06-02 08:37:38 +08:00
parent 3d18ddcd00
commit e52c3d82a0

View file

@ -63,43 +63,40 @@ Slider {
MaterialIcon { MaterialIcon {
id: icon id: icon
property bool moving: handle.moving
function update(): void {
animate = !moving;
text = moving ? Qt.binding(() => Math.round(root.value * 100)) : Qt.binding(() => root.icon);
font.pointSize = moving ? Appearance.font.size.small : Appearance.font.size.normal;
font.family = moving ? Appearance.font.family.sans : Appearance.font.family.material;
}
animate: true animate: true
text: root.icon text: root.icon
color: Colours.palette.m3inverseOnSurface color: Colours.palette.m3inverseOnSurface
anchors.centerIn: parent anchors.centerIn: parent
states: State { Behavior on moving {
name: "value" SequentialAnimation {
when: handle.moving
PropertyChanges {
icon.animate: false
icon.text: Math.round(root.value * 100)
icon.font.pointSize: Appearance.font.size.small
icon.font.family: Appearance.font.family.sans
}
}
transitions: Transition {
NumberAnimation { NumberAnimation {
target: icon target: icon
property: "scale" property: "scale"
from: 1 from: 1
to: 0 to: 0
duration: Appearance.anim.durations.normal duration: Appearance.anim.durations.normal / 2
easing.type: Easing.BezierSpline easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standardAccel easing.bezierCurve: Appearance.anim.curves.standardAccel
} }
PropertyAction { ScriptAction {
target: icon script: icon.update()
properties: "animate,text,font.pointSize,font.family"
} }
NumberAnimation { NumberAnimation {
target: icon target: icon
property: "scale" property: "scale"
from: 0 from: 0
to: 1 to: 1
duration: Appearance.anim.durations.normal duration: Appearance.anim.durations.normal / 2
easing.type: Easing.BezierSpline easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standardDecel easing.bezierCurve: Appearance.anim.curves.standardDecel
} }
@ -107,6 +104,7 @@ Slider {
} }
} }
} }
}
onPressedChanged: handle.moving = pressed onPressedChanged: handle.moving = pressed