From a6d71f508ea6ad11d21e84b72d2b2fb5842d24c0 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 14 Jul 2016 17:20:08 -0700 Subject: [PATCH] Fix edit toolbar button vanishing, persistent edit button --- .../resources/qml/hifi/toolbars/Toolbar.qml | 3 +-- .../qml/hifi/toolbars/ToolbarButton.qml | 25 ++++++++----------- scripts/system/edit.js | 6 ++--- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/interface/resources/qml/hifi/toolbars/Toolbar.qml b/interface/resources/qml/hifi/toolbars/Toolbar.qml index c5c15a6406..4e7eef62d5 100644 --- a/interface/resources/qml/hifi/toolbars/Toolbar.qml +++ b/interface/resources/qml/hifi/toolbars/Toolbar.qml @@ -19,7 +19,6 @@ Window { shown: true width: content.width height: content.height - visible: true // Disable this window from being able to call 'desktop.raise() and desktop.showDesktop' activator: MouseArea { width: frame.decoration ? frame.decoration.width : window.width @@ -38,7 +37,7 @@ Window { property real buttonSize: 50; property var buttons: [] property var container: horizontal ? row : column - + Settings { category: "toolbar/" + window.objectName property alias x: window.x diff --git a/interface/resources/qml/hifi/toolbars/ToolbarButton.qml b/interface/resources/qml/hifi/toolbars/ToolbarButton.qml index 47a52c4c36..f4693adec5 100644 --- a/interface/resources/qml/hifi/toolbars/ToolbarButton.qml +++ b/interface/resources/qml/hifi/toolbars/ToolbarButton.qml @@ -8,23 +8,16 @@ Item { property var subImage; property int yOffset: 0 property int buttonState: 0 - property int hoverOffset: 0 + property int hoverState: -1 + property int defaultState: -1 property var toolbar; property real size: 50 // toolbar ? toolbar.buttonSize : 50 width: size; height: size property bool pinned: false clip: true - - function updateOffset() { - yOffset = size * (buttonState + hoverOffset); - } - + onButtonStateChanged: { - 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(); + yOffset = size * buttonState; } Component.onCompleted: { @@ -57,12 +50,14 @@ Item { anchors.fill: parent onClicked: asyncClickSender.start(); onEntered: { - hoverOffset = 2; - updateOffset(); + if (hoverState > 0) { + buttonState = hoverState; + } } onExited: { - hoverOffset = 0; - updateOffset(); + if (defaultState > 0) { + buttonState = defaultState; + } } } } diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 47d6fd4367..883a804e4b 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -201,6 +201,7 @@ var toolBar = (function() { function cleanup() { that.setActive(false); + systemToolbar.removeButton("com.highfidelity.interface.system.editButton"); } function addButton(name, image, handler) { @@ -237,11 +238,10 @@ var toolBar = (function() { systemToolbar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); activeButton = systemToolbar.addButton({ - objectName: "activeButton", + objectName: "com.highfidelity.interface.system.editButton", imageURL: TOOL_ICON_URL + "edit.svg", visible: true, buttonState: 1, - alpha: 0.9, }); activeButton.clicked.connect(function(){ that.setActive(!isActive); @@ -418,9 +418,7 @@ var toolBar = (function() { toolBar.writeProperty("shown", active); var visible = toolBar.readProperty("visible"); if (active && !visible) { - toolBar.writeProperty("visible", false); toolBar.writeProperty("shown", false); - toolBar.writeProperty("visible", true); toolBar.writeProperty("shown", true); } //toolBar.selectTool(activeButton, isActive);