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
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

View file

@ -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;
}
}
}
}

View file

@ -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);