mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 03:59:38 +00:00
standard-button: add hover color animation
This commit is contained in:
parent
e0796b24c9
commit
f8a920dc38
1 changed files with 31 additions and 16 deletions
|
@ -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;
|
||||
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
|
||||
}
|
||||
onExited: {
|
||||
// if(button.enabled) parent.color = Style.buttonBackgroundColor;
|
||||
// else parent.color = Style.buttonBackgroundColorDisabled;
|
||||
},
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue