39 lines
1.2 KiB
QML
39 lines
1.2 KiB
QML
import QtQuick
|
|
|
|
Rectangle {
|
|
id: root
|
|
|
|
property color idleColor: "transparent"
|
|
property color hoverColor: "transparent"
|
|
property color pressColor: "transparent"
|
|
property color borderIdleColor: "transparent"
|
|
property color borderHoverColor: "transparent"
|
|
property real pressScale: 0.97
|
|
property int animDuration: 150
|
|
property int btnRadius: 8
|
|
property int btnBorderWidth: 1
|
|
|
|
readonly property bool hovered: _hover.hovered
|
|
readonly property bool pressed: _tap.pressed
|
|
|
|
signal clicked()
|
|
|
|
radius: root.btnRadius
|
|
color: pressed ? pressColor : (hovered ? hoverColor : idleColor)
|
|
border.color: hovered ? borderHoverColor : borderIdleColor
|
|
border.width: root.btnBorderWidth
|
|
|
|
scale: pressed ? pressScale : 1.0
|
|
|
|
Behavior on color { ColorAnimation { duration: root.animDuration } }
|
|
Behavior on border.color { ColorAnimation { duration: root.animDuration } }
|
|
Behavior on scale { NumberAnimation { duration: 100; easing.type: Easing.OutQuad } }
|
|
|
|
HoverHandler { id: _hover }
|
|
TapHandler {
|
|
id: _tap
|
|
cursorShape: Qt.PointingHandCursor
|
|
onTapped: root.clicked()
|
|
}
|
|
}
|