Fix edit toolbar button vanishing, persistent edit button

This commit is contained in:
Brad Davis 2016-07-14 17:20:08 -07:00
parent 1adf96c8df
commit a6d71f508e
3 changed files with 13 additions and 21 deletions

View file

@ -19,7 +19,6 @@ Window {
shown: true shown: true
width: content.width width: content.width
height: content.height height: content.height
visible: true
// Disable this window from being able to call 'desktop.raise() and desktop.showDesktop' // Disable this window from being able to call 'desktop.raise() and desktop.showDesktop'
activator: MouseArea { activator: MouseArea {
width: frame.decoration ? frame.decoration.width : window.width width: frame.decoration ? frame.decoration.width : window.width
@ -38,7 +37,7 @@ Window {
property real buttonSize: 50; property real buttonSize: 50;
property var buttons: [] property var buttons: []
property var container: horizontal ? row : column property var container: horizontal ? row : column
Settings { Settings {
category: "toolbar/" + window.objectName category: "toolbar/" + window.objectName
property alias x: window.x property alias x: window.x

View file

@ -8,23 +8,16 @@ Item {
property var subImage; property var subImage;
property int yOffset: 0 property int yOffset: 0
property int buttonState: 0 property int buttonState: 0
property int hoverOffset: 0 property int hoverState: -1
property int defaultState: -1
property var toolbar; property var toolbar;
property real size: 50 // toolbar ? toolbar.buttonSize : 50 property real size: 50 // toolbar ? toolbar.buttonSize : 50
width: size; height: size width: size; height: size
property bool pinned: false property bool pinned: false
clip: true clip: true
function updateOffset() {
yOffset = size * (buttonState + hoverOffset);
}
onButtonStateChanged: { onButtonStateChanged: {
hoverOffset = 0; // subtle: show the new state without hover. don't wait for mouse to be moved away yOffset = size * buttonState;
// 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: { Component.onCompleted: {
@ -57,12 +50,14 @@ Item {
anchors.fill: parent anchors.fill: parent
onClicked: asyncClickSender.start(); onClicked: asyncClickSender.start();
onEntered: { onEntered: {
hoverOffset = 2; if (hoverState > 0) {
updateOffset(); buttonState = hoverState;
}
} }
onExited: { onExited: {
hoverOffset = 0; if (defaultState > 0) {
updateOffset(); buttonState = defaultState;
}
} }
} }
} }

View file

@ -201,6 +201,7 @@ var toolBar = (function() {
function cleanup() { function cleanup() {
that.setActive(false); that.setActive(false);
systemToolbar.removeButton("com.highfidelity.interface.system.editButton");
} }
function addButton(name, image, handler) { function addButton(name, image, handler) {
@ -237,11 +238,10 @@ var toolBar = (function() {
systemToolbar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); systemToolbar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
activeButton = systemToolbar.addButton({ activeButton = systemToolbar.addButton({
objectName: "activeButton", objectName: "com.highfidelity.interface.system.editButton",
imageURL: TOOL_ICON_URL + "edit.svg", imageURL: TOOL_ICON_URL + "edit.svg",
visible: true, visible: true,
buttonState: 1, buttonState: 1,
alpha: 0.9,
}); });
activeButton.clicked.connect(function(){ activeButton.clicked.connect(function(){
that.setActive(!isActive); that.setActive(!isActive);
@ -418,9 +418,7 @@ var toolBar = (function() {
toolBar.writeProperty("shown", active); toolBar.writeProperty("shown", active);
var visible = toolBar.readProperty("visible"); var visible = toolBar.readProperty("visible");
if (active && !visible) { if (active && !visible) {
toolBar.writeProperty("visible", false);
toolBar.writeProperty("shown", false); toolBar.writeProperty("shown", false);
toolBar.writeProperty("visible", true);
toolBar.writeProperty("shown", true); toolBar.writeProperty("shown", true);
} }
//toolBar.selectTool(activeButton, isActive); //toolBar.selectTool(activeButton, isActive);