From 02cc6cc567150909587d9f09c39882b354f5c4a3 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Fri, 1 Jul 2016 12:18:26 -0700 Subject: [PATCH] hover states --- .../qml/hifi/toolbars/ToolbarButton.qml | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/toolbars/ToolbarButton.qml b/interface/resources/qml/hifi/toolbars/ToolbarButton.qml index a3be4533d2..4356b18253 100644 --- a/interface/resources/qml/hifi/toolbars/ToolbarButton.qml +++ b/interface/resources/qml/hifi/toolbars/ToolbarButton.qml @@ -8,6 +8,7 @@ Item { property var subImage; property int yOffset: 0 property int buttonState: 0 + property int hoverOffset: 0 property var toolbar; property real size: 50 // toolbar ? toolbar.buttonSize : 50 width: size; height: size @@ -36,9 +37,15 @@ Item { } } - + function updateOffset() { + yOffset = size * (buttonState + hoverOffset); + } onButtonStateChanged: { - yOffset = size * buttonState + hoverOffset = 0; // subtle: show the new state without hover. don't wait for mouse to be moved away + // The above is per UX design, but ALSO avoid a subtle issue that would be a problem because + // the hand controllers don't move the mouse when not triggered, so releasing the trigger would + // never show unhovered. + updateOffset(); } Component.onCompleted: { @@ -58,8 +65,18 @@ Item { } MouseArea { + id: mouseArea + hoverEnabled: true anchors.fill: parent onClicked: button.clicked(); + onEntered: { + hoverOffset = 2; + updateOffset(); + } + onExited: { + hoverOffset = 0; + updateOffset(); + } } }