mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-10 03:42:05 +02:00
standard-button: add hover color animation
This commit is contained in:
parent
e0796b24c9
commit
f8a920dc38
@ -57,27 +57,41 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: buttonRect
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: 3
|
radius: 3
|
||||||
color: parent.enabled ? MoneroComponents.Style.buttonBackgroundColor : MoneroComponents.Style.buttonBackgroundColorDisabled
|
|
||||||
border.width: parent.focus ? 1 : 0
|
border.width: parent.focus ? 1 : 0
|
||||||
|
|
||||||
MouseArea {
|
state: button.enabled ? "active" : "disabled"
|
||||||
anchors.fill: parent
|
Component.onCompleted: state = state
|
||||||
cursorShape: Qt.PointingHandCursor
|
states: [
|
||||||
hoverEnabled: true
|
State {
|
||||||
|
name: "hover"
|
||||||
propagateComposedEvents: true
|
when: buttonArea.containsMouse || button.focus
|
||||||
|
PropertyChanges {
|
||||||
// possibly do some hover effects here
|
target: buttonRect
|
||||||
onEntered: {
|
color: MoneroComponents.Style.buttonBackgroundColorHover
|
||||||
// if(button.enabled) parent.color = Style.buttonBackgroundColorHover;
|
|
||||||
// else parent.color = Style.buttonBackgroundColorDisabledHover;
|
|
||||||
}
|
}
|
||||||
onExited: {
|
},
|
||||||
// if(button.enabled) parent.color = Style.buttonBackgroundColor;
|
State {
|
||||||
// else parent.color = Style.buttonBackgroundColorDisabled;
|
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 {
|
MouseArea {
|
||||||
id: buttonArea
|
id: buttonArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
onClicked: doClick()
|
onClicked: doClick()
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user