From b307b596d2ed6e0dd221604e55ad1ce3e3488326 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 16 Dec 2019 04:42:41 -0400 Subject: [PATCH] Animators are buggy crap, drop them --- src/qml/Base/HBox.qml | 2 +- src/qml/Base/HButtonBackground.qml | 2 +- src/qml/Base/HButtonContent.qml | 55 ++++++++++------------- src/qml/Base/HCheckBox.qml | 3 +- src/qml/Base/HCircleProgressBar.qml | 2 +- src/qml/Base/HImage.qml | 2 +- src/qml/Base/HOpacityAnimator.qml | 7 --- src/qml/Base/HPopup.qml | 3 +- src/qml/Base/HProgressBar.qml | 2 +- src/qml/Base/HRotationAnimator.qml | 7 --- src/qml/Base/HScaleAnimator.qml | 10 ----- src/qml/Base/HScrollableTextArea.qml | 4 +- src/qml/Base/HTextField.qml | 4 +- src/qml/Base/HToolTip.qml | 1 - src/qml/Base/HXAnimator.qml | 7 --- src/qml/Base/HYAnimator.qml | 7 --- src/qml/Chat/Chat.qml | 2 +- src/qml/Chat/RoomPane/MemberView.qml | 2 +- src/qml/Chat/Timeline/EventDelegate.qml | 2 +- src/qml/Chat/Timeline/EventImage.qml | 4 +- src/qml/MainPane/AccountDelegate.qml | 6 +-- src/qml/MainPane/MainPane.qml | 2 +- src/qml/MainPane/MainPaneToolBar.qml | 2 +- src/qml/MainPane/RoomDelegate.qml | 2 +- src/qml/Pages/AccountSettings/Profile.qml | 2 +- src/qml/Pages/AddChat/CreateRoom.qml | 2 +- src/qml/UI.qml | 11 +++-- src/qml/Window.qml | 2 +- 28 files changed, 56 insertions(+), 101 deletions(-) delete mode 100644 src/qml/Base/HOpacityAnimator.qml delete mode 100644 src/qml/Base/HRotationAnimator.qml delete mode 100644 src/qml/Base/HScaleAnimator.qml delete mode 100644 src/qml/Base/HXAnimator.qml delete mode 100644 src/qml/Base/HYAnimator.qml diff --git a/src/qml/Base/HBox.qml b/src/qml/Base/HBox.qml index 2909e9b9..2016c280 100644 --- a/src/qml/Base/HBox.qml +++ b/src/qml/Base/HBox.qml @@ -32,7 +32,7 @@ Rectangle { } - HScaleAnimator on scale { + HNumberAnimation on scale { running: true from: 0 to: 1 diff --git a/src/qml/Base/HButtonBackground.qml b/src/qml/Base/HButtonBackground.qml index b82902f7..52efb65b 100644 --- a/src/qml/Base/HButtonBackground.qml +++ b/src/qml/Base/HButtonBackground.qml @@ -11,7 +11,7 @@ Rectangle { property QtObject buttonTheme - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } Rectangle { diff --git a/src/qml/Base/HButtonContent.qml b/src/qml/Base/HButtonContent.qml index 76f9bdf9..be91a266 100644 --- a/src/qml/Base/HButtonContent.qml +++ b/src/qml/Base/HButtonContent.qml @@ -16,45 +16,49 @@ HRowLayout { readonly property alias label: label - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } - Item { - id: iconWrapper + HIcon { + property bool loading: button.loading || false + + id: icon + svgName: button.icon.name + colorize: enabled ? button.icon.color: theme.icons.disabledColorize + cache: button.icon.cache + + onLoadingChanged: if (! loading) resetAnimations.start() + + Layout.fillHeight: true Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: icon.width - Layout.preferredHeight: icon.height + ParallelAnimation { id: resetAnimations - HOpacityAnimator { target: iconWrapper; to: 1 } - HRotationAnimator { target: iconWrapper; to: 0 } + HNumberAnimation { target: icon; property: "opacity"; to: 1 } + HNumberAnimation { target: icon; property: "rotation"; to: 0 } } - HOpacityAnimator { + + HNumberAnimation on opacity { id: blink - target: iconWrapper from: 1 to: 0.5 factor: 2 running: button.loading || false - onFinished: { - if (button.loading) { [from, to] = [to, from]; start() } - } + onFinished: { [from, to] = [to, from]; start() } } SequentialAnimation { running: button.loading || false loops: Animation.Infinite - onStopped: resetAnimations.start() HPauseAnimation { factor: blink.factor * 8 } - // These don't work directly on HIcon, hence why we wrap it in - // an Item. Qt bug? (5.13.1_1) - HRotationAnimator { + HNumberAnimation { id: rotation1 - target: iconWrapper + target: icon + property: "rotation" from: 0 to: 180 factor: blink.factor @@ -62,26 +66,14 @@ HRowLayout { HPauseAnimation { factor: blink.factor * 8 } - HRotationAnimator { + HNumberAnimation { target: rotation1.target + property: rotation1.property from: rotation1.to to: 360 factor: rotation1.factor - direction: RotationAnimator.Clockwise } } - - HIcon { - property bool loading: button.loading || false - - id: icon - svgName: button.icon.name - colorize: enabled ? button.icon.color: theme.icons.disabledColorize - cache: button.icon.cache - - Layout.fillHeight: true - Layout.alignment: Qt.AlignCenter - } } HLabel { @@ -93,7 +85,6 @@ HRowLayout { verticalAlignment: Text.AlignVCenter elide: Text.ElideRight - Layout.alignment: Qt.AlignCenter Layout.fillWidth: true Layout.fillHeight: true } diff --git a/src/qml/Base/HCheckBox.qml b/src/qml/Base/HCheckBox.qml index 53cc8503..d1a2cd99 100644 --- a/src/qml/Base/HCheckBox.qml +++ b/src/qml/Base/HCheckBox.qml @@ -37,7 +37,6 @@ CheckBox { scale: box.checked ? 1 : 0 - // FIXME: HScaleAnimator won't work here? Behavior on scale { HNumberAnimation { overshoot: 4 @@ -88,5 +87,5 @@ CheckBox { function reset() { checked = defaultChecked } - Behavior on opacity { HOpacityAnimator { factor: 2 } } + Behavior on opacity { HNumberAnimation { factor: 2 } } } diff --git a/src/qml/Base/HCircleProgressBar.qml b/src/qml/Base/HCircleProgressBar.qml index cb5cb762..101d3f43 100644 --- a/src/qml/Base/HCircleProgressBar.qml +++ b/src/qml/Base/HCircleProgressBar.qml @@ -38,7 +38,7 @@ RadialBar { when: bar.indeterminate } - RotationAnimator on rotation { + HNumberAnimation on rotation { running: bar.indeterminate from: 0 to: 360 diff --git a/src/qml/Base/HImage.qml b/src/qml/Base/HImage.qml index 3bf01903..8a499376 100644 --- a/src/qml/Base/HImage.qml +++ b/src/qml/Base/HImage.qml @@ -56,7 +56,7 @@ Image { ) scale: parent.status === Image.Ready && parent.paused ? 1 : 0 - Behavior on scale { HScaleAnimator { overshoot: 4 } } + Behavior on scale { HNumberAnimation { overshoot: 4 } } } } } diff --git a/src/qml/Base/HOpacityAnimator.qml b/src/qml/Base/HOpacityAnimator.qml deleted file mode 100644 index 7fab7366..00000000 --- a/src/qml/Base/HOpacityAnimator.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.12 - -OpacityAnimator { - duration: theme.animationDuration * factor - - property real factor: 1.0 -} diff --git a/src/qml/Base/HPopup.qml b/src/qml/Base/HPopup.qml index cb140fa9..7ce65531 100644 --- a/src/qml/Base/HPopup.qml +++ b/src/qml/Base/HPopup.qml @@ -10,11 +10,10 @@ Popup { margins: theme.spacing enter: Transition { - HScaleAnimator { from: 0; to: 1; overshoot: 4 } + HNumberAnimation { property: "scale"; from: 0; to: 1; overshoot: 4 } } exit: Transition { - // FIXME: HScaleAnimator won't work here? HNumberAnimation { property: "scale"; to: 0 } } diff --git a/src/qml/Base/HProgressBar.qml b/src/qml/Base/HProgressBar.qml index 432c78fd..7bb0dc2a 100644 --- a/src/qml/Base/HProgressBar.qml +++ b/src/qml/Base/HProgressBar.qml @@ -26,7 +26,7 @@ ProgressBar { Behavior on color { HColorAnimation {} } - XAnimator on x { + HNumberAnimation on x { running: bar.indeterminate duration: theme.animationDuration * 8 from: 0 diff --git a/src/qml/Base/HRotationAnimator.qml b/src/qml/Base/HRotationAnimator.qml deleted file mode 100644 index 38408cc9..00000000 --- a/src/qml/Base/HRotationAnimator.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.12 - -RotationAnimator { - duration: theme.animationDuration * factor - - property real factor: 1.0 -} diff --git a/src/qml/Base/HScaleAnimator.qml b/src/qml/Base/HScaleAnimator.qml deleted file mode 100644 index 659c1f34..00000000 --- a/src/qml/Base/HScaleAnimator.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.12 - -ScaleAnimator { - property real factor: 1.0 - property real overshoot: 1.0 - - duration: theme.animationDuration * Math.max(overshoot / 1.7, 1.0) * factor - easing.type: overshoot > 1 ? Easing.OutBack : Easing.Linear - easing.overshoot: overshoot -} diff --git a/src/qml/Base/HScrollableTextArea.qml b/src/qml/Base/HScrollableTextArea.qml index 88daa392..f678cd62 100644 --- a/src/qml/Base/HScrollableTextArea.qml +++ b/src/qml/Base/HScrollableTextArea.qml @@ -38,7 +38,7 @@ ScrollView { function reset() { area.clear(); text = defaultText } - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } TextArea { id: textArea @@ -102,7 +102,7 @@ ScrollView { font.family: parent.font.family font.pixelSize: parent.font.pixelSize - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } } } } diff --git a/src/qml/Base/HTextField.qml b/src/qml/Base/HTextField.qml index 693063fa..2ab8af35 100644 --- a/src/qml/Base/HTextField.qml +++ b/src/qml/Base/HTextField.qml @@ -80,7 +80,7 @@ TextField { when: disabledText !== null && ! field.enabled } - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } Behavior on color { HColorAnimation {} } Behavior on placeholderTextColor { HColorAnimation {} } @@ -99,6 +99,6 @@ TextField { font.family: parent.font.family font.pixelSize: parent.font.pixelSize - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } } } diff --git a/src/qml/Base/HToolTip.qml b/src/qml/Base/HToolTip.qml index 76736eda..4ffd227b 100644 --- a/src/qml/Base/HToolTip.qml +++ b/src/qml/Base/HToolTip.qml @@ -41,7 +41,6 @@ ToolTip { } } - // FIXME: HOpacityAnimator won't work for these? enter: Transition { HNumberAnimation { property: "opacity"; from: 0.0; to: 1.0 } } diff --git a/src/qml/Base/HXAnimator.qml b/src/qml/Base/HXAnimator.qml deleted file mode 100644 index e1c5a861..00000000 --- a/src/qml/Base/HXAnimator.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.12 - -XAnimator { - duration: theme.animationDuration * factor - - property real factor: 1.0 -} diff --git a/src/qml/Base/HYAnimator.qml b/src/qml/Base/HYAnimator.qml deleted file mode 100644 index d59c00a1..00000000 --- a/src/qml/Base/HYAnimator.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.12 - -YAnimator { - duration: theme.animationDuration * factor - - property real factor: 1.0 -} diff --git a/src/qml/Chat/Chat.qml b/src/qml/Chat/Chat.qml index 02ff8803..8ff4b651 100644 --- a/src/qml/Chat/Chat.qml +++ b/src/qml/Chat/Chat.qml @@ -44,7 +44,7 @@ Item { source: opacity > 0 ? "../Base/HBusyIndicator.qml" : "" opacity: ready ? 0 : 1 - Behavior on opacity { HOpacityAnimator { factor: 2 } } + Behavior on opacity { HNumberAnimation { factor: 2 } } } } diff --git a/src/qml/Chat/RoomPane/MemberView.qml b/src/qml/Chat/RoomPane/MemberView.qml index c4d3691f..2a5f00a9 100644 --- a/src/qml/Chat/RoomPane/MemberView.qml +++ b/src/qml/Chat/RoomPane/MemberView.qml @@ -60,7 +60,7 @@ HColumnLayout { Layout.fillWidth: true Layout.fillHeight: true - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } } HButton { diff --git a/src/qml/Chat/Timeline/EventDelegate.qml b/src/qml/Chat/Timeline/EventDelegate.qml index 6f7e7338..8854b1e4 100644 --- a/src/qml/Chat/Timeline/EventDelegate.qml +++ b/src/qml/Chat/Timeline/EventDelegate.qml @@ -102,7 +102,7 @@ Column { id: eventContent width: parent.width - Behavior on x { HXAnimator {} } + Behavior on x { HNumberAnimation {} } } diff --git a/src/qml/Chat/Timeline/EventImage.qml b/src/qml/Chat/Timeline/EventImage.qml index ae900a4f..081de30c 100644 --- a/src/qml/Chat/Timeline/EventImage.qml +++ b/src/qml/Chat/Timeline/EventImage.qml @@ -96,7 +96,7 @@ HMxcImage { opacity: hover.hovered ? 0 : 1 visible: opacity > 0 - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } } EventImageTextBubble { @@ -107,6 +107,6 @@ HMxcImage { opacity: hover.hovered ? 0 : 1 visible: opacity > 0 - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } } } diff --git a/src/qml/MainPane/AccountDelegate.qml b/src/qml/MainPane/AccountDelegate.qml index d11f7ba0..78a936d6 100644 --- a/src/qml/MainPane/AccountDelegate.qml +++ b/src/qml/MainPane/AccountDelegate.qml @@ -20,7 +20,7 @@ HTileDelegate { ! mainPaneList.activateLimiter.running && ! mainPane.hasFocus - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } readonly property bool forceExpand: Boolean(mainPaneList.filter) @@ -71,7 +71,7 @@ HTileDelegate { Layout.fillHeight: true - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } } HButton { @@ -99,7 +99,7 @@ HTileDelegate { Behavior on angle { HNumberAnimation {} } } - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } } contextMenu: HMenu { diff --git a/src/qml/MainPane/MainPane.qml b/src/qml/MainPane/MainPane.qml index 0e627e40..1541aa9b 100644 --- a/src/qml/MainPane/MainPane.qml +++ b/src/qml/MainPane/MainPane.qml @@ -26,7 +26,7 @@ HDrawer { } - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } Binding on visible { value: false diff --git a/src/qml/MainPane/MainPaneToolBar.qml b/src/qml/MainPane/MainPaneToolBar.qml index 226ab910..8670848c 100644 --- a/src/qml/MainPane/MainPaneToolBar.qml +++ b/src/qml/MainPane/MainPaneToolBar.qml @@ -53,6 +53,6 @@ HRowLayout { mainUI.pageLoader.forceActiveFocus() } - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } } } diff --git a/src/qml/MainPane/RoomDelegate.qml b/src/qml/MainPane/RoomDelegate.qml index 22a34598..c491a4dd 100644 --- a/src/qml/MainPane/RoomDelegate.qml +++ b/src/qml/MainPane/RoomDelegate.qml @@ -18,7 +18,7 @@ HTileDelegate { ! mainPaneList.activateLimiter.running && ! mainPane.hasFocus - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } readonly property bool joined: ! invited && ! parted diff --git a/src/qml/Pages/AccountSettings/Profile.qml b/src/qml/Pages/AccountSettings/Profile.qml index 6e611195..02b0aedf 100644 --- a/src/qml/Pages/AccountSettings/Profile.qml +++ b/src/qml/Pages/AccountSettings/Profile.qml @@ -81,7 +81,7 @@ HGridLayout { (! avatar.mxc && overlayHover.hovered) ? 0.8 : 0.7 ) - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } Behavior on color { HColorAnimation {} } HoverHandler { id: overlayHover } diff --git a/src/qml/Pages/AddChat/CreateRoom.qml b/src/qml/Pages/AddChat/CreateRoom.qml index 0e9087a1..991e31c5 100644 --- a/src/qml/Pages/AddChat/CreateRoom.qml +++ b/src/qml/Pages/AddChat/CreateRoom.qml @@ -67,7 +67,7 @@ HBox { opacity: nameField.text ? 0 : 1 visible: opacity > 0 - Behavior on opacity { HOpacityAnimator {} } + Behavior on opacity { HNumberAnimation {} } } } diff --git a/src/qml/UI.qml b/src/qml/UI.qml index 7a2012cb..3d87943e 100644 --- a/src/qml/UI.qml +++ b/src/qml/UI.qml @@ -20,8 +20,12 @@ Item { SequentialAnimation { id: pressAnimation - HScaleAnimator { target: mainUI; from: 1.0; to: 0.9 } - HScaleAnimator { target: mainUI; from: 0.9; to: 1.0 } + HNumberAnimation { + target: mainUI; property: "scale"; from: 1.0; to: 0.9 + } + HNumberAnimation { + target: mainUI; property: "scale"; from: 0.9; to: 1.0 + } } property bool accountsPresent: @@ -134,9 +138,10 @@ Item { } - XAnimator { + HNumberAnimation { id: appearAnimation target: pageLoader.item + property: "x" from: -300 to: 0 easing.type: Easing.OutBack diff --git a/src/qml/Window.qml b/src/qml/Window.qml index a97bb143..26e54c57 100644 --- a/src/qml/Window.qml +++ b/src/qml/Window.qml @@ -89,6 +89,6 @@ ApplicationWindow { scale: py.ready ? 1 : 0.5 source: py.ready ? (Qt.application.arguments[1] || "UI.qml") : "" - Behavior on scale { HScaleAnimator { overshoot: 5; factor: 1.2 } } + Behavior on scale { HNumberAnimation { overshoot: 5; factor: 1.2 } } } }