diff options
| author | xiphon <xiphon@protonmail.com> | 2018-12-08 21:33:04 +0000 |
|---|---|---|
| committer | xiphon <xiphon@protonmail.com> | 2018-12-09 00:49:22 +0300 |
| commit | f8a920dc38d1af80148cbc88fb820871e4ba41cf (patch) | |
| tree | 4b8a97bc8b38b88b81a70f46525929ea4dc992b3 /components | |
| parent | e0796b24c98ac1c20a140ee1d194e62efe3b00a7 (diff) | |
| download | monzero-gui-f8a920dc38d1af80148cbc88fb820871e4ba41cf.tar.gz monzero-gui-f8a920dc38d1af80148cbc88fb820871e4ba41cf.tar.xz monzero-gui-f8a920dc38d1af80148cbc88fb820871e4ba41cf.zip | |
standard-button: add hover color animation
Diffstat (limited to 'components')
| -rw-r--r-- | components/StandardButton.qml | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/components/StandardButton.qml b/components/StandardButton.qml index 88076894..bfb90716 100644 --- a/components/StandardButton.qml +++ b/components/StandardButton.qml @@ -57,27 +57,41 @@ Item { } Rectangle { + id: buttonRect anchors.fill: parent radius: 3 - color: parent.enabled ? MoneroComponents.Style.buttonBackgroundColor : MoneroComponents.Style.buttonBackgroundColorDisabled border.width: parent.focus ? 1 : 0 - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - hoverEnabled: true - - propagateComposedEvents: true - - // possibly do some hover effects here - onEntered: { -// if(button.enabled) parent.color = Style.buttonBackgroundColorHover; -// else parent.color = Style.buttonBackgroundColorDisabledHover; - } - onExited: { -// if(button.enabled) parent.color = Style.buttonBackgroundColor; -// else parent.color = Style.buttonBackgroundColorDisabled; + state: button.enabled ? "active" : "disabled" + Component.onCompleted: state = state + states: [ + State { + name: "hover" + when: buttonArea.containsMouse || button.focus + PropertyChanges { + target: buttonRect + color: MoneroComponents.Style.buttonBackgroundColorHover + } + }, + State { + name: "active" + when: button.enabled + PropertyChanges { + target: buttonRect + color: MoneroComponents.Style.buttonBackgroundColor + } + }, + State { + name: "disabled" + when: !button.enabled + PropertyChanges { + target: buttonRect + color: MoneroComponents.Style.buttonBackgroundColorDisabled + } } + ] + transitions: Transition { + ColorAnimation { duration: 100 } } } @@ -122,6 +136,7 @@ Item { MouseArea { id: buttonArea anchors.fill: parent + hoverEnabled: true onClicked: doClick() cursorShape: Qt.PointingHandCursor } |
