mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:47:30 +02:00
Fixed js interface after recent Tablet.qml changes
* TabletButton.inDebugMode defaults to false * TabletButton now listens to onIsActiveChanged event to flip state of button. * Fixed help.js and tabletTest.js to compensate for the removal of the TabletButton.color property
This commit is contained in:
parent
f808c0232f
commit
10f9233c90
4 changed files with 33 additions and 28 deletions
|
@ -172,7 +172,9 @@ Item {
|
||||||
var component = Qt.createComponent("TabletButton.qml");
|
var component = Qt.createComponent("TabletButton.qml");
|
||||||
var buttons = [];
|
var buttons = [];
|
||||||
for (var i = 0; i < 5; i++) {
|
for (var i = 0; i < 5; i++) {
|
||||||
buttons.push(component.createObject(flowMain));
|
var button = component.createObject(flowMain);
|
||||||
|
button.inDebugMode = true;
|
||||||
|
buttons.push(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set button text
|
// set button text
|
||||||
|
|
|
@ -7,7 +7,8 @@ Item {
|
||||||
property string text: "EDIT"
|
property string text: "EDIT"
|
||||||
property string icon: "icons/edit-icon.svg"
|
property string icon: "icons/edit-icon.svg"
|
||||||
property bool isActive: false
|
property bool isActive: false
|
||||||
property bool inDebugMode: true
|
property bool inDebugMode: false
|
||||||
|
property bool isEntered: false
|
||||||
width: 129
|
width: 129
|
||||||
height: 129
|
height: 129
|
||||||
|
|
||||||
|
@ -17,6 +18,14 @@ Item {
|
||||||
tabletButton[key] = value;
|
tabletButton[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onIsActiveChanged: {
|
||||||
|
if (tabletButton.isEntered) {
|
||||||
|
tabletButton.state = (tabletButton.isActive) ? "hover active state" : "hover sate";
|
||||||
|
} else {
|
||||||
|
tabletButton.state = (tabletButton.isActive) ? "active state" : "base sate";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: buttonBg
|
id: buttonBg
|
||||||
color: "#000000"
|
color: "#000000"
|
||||||
|
@ -51,19 +60,18 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
DropShadow {
|
DropShadow {
|
||||||
id: glow
|
id: glow
|
||||||
visible: false
|
visible: false
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
horizontalOffset: 0
|
horizontalOffset: 0
|
||||||
verticalOffset: 0
|
verticalOffset: 0
|
||||||
color: "#ffffff"
|
color: "#ffffff"
|
||||||
radius: 20
|
radius: 20
|
||||||
z: -1
|
z: -1
|
||||||
samples: 41
|
samples: 41
|
||||||
source: buttonOutline
|
source: buttonOutline
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: icon
|
id: icon
|
||||||
width: 50
|
width: 50
|
||||||
|
@ -102,10 +110,8 @@ Item {
|
||||||
console.log("Tablet Button Clicked!");
|
console.log("Tablet Button Clicked!");
|
||||||
if (tabletButton.inDebugMode) {
|
if (tabletButton.inDebugMode) {
|
||||||
if (tabletButton.isActive) {
|
if (tabletButton.isActive) {
|
||||||
tabletButton.state = "base state";
|
|
||||||
tabletButton.isActive = false;
|
tabletButton.isActive = false;
|
||||||
} else {
|
} else {
|
||||||
tabletButton.state = "active state";
|
|
||||||
tabletButton.isActive = true;
|
tabletButton.isActive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +119,7 @@ Item {
|
||||||
}
|
}
|
||||||
onEntered: {
|
onEntered: {
|
||||||
console.log("Tablet Button Hovered!");
|
console.log("Tablet Button Hovered!");
|
||||||
|
tabletButton.isEntered = true;
|
||||||
if (tabletButton.isActive) {
|
if (tabletButton.isActive) {
|
||||||
tabletButton.state = "hover active state";
|
tabletButton.state = "hover active state";
|
||||||
} else {
|
} else {
|
||||||
|
@ -121,6 +128,7 @@ Item {
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
console.log("Tablet Button Unhovered!");
|
console.log("Tablet Button Unhovered!");
|
||||||
|
tabletButton.isEntered = false;
|
||||||
if (tabletButton.isActive) {
|
if (tabletButton.isActive) {
|
||||||
tabletButton.state = "active state";
|
tabletButton.state = "active state";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -12,25 +12,22 @@
|
||||||
|
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
var button = tablet.addButton({
|
var button = tablet.addButton({
|
||||||
icon: "https://s3.amazonaws.com/hifi-public/tony/icons/hat-up.svg",
|
|
||||||
color: "#ff6f6f",
|
|
||||||
text: "BAM!!!"
|
text: "BAM!!!"
|
||||||
});
|
});
|
||||||
|
|
||||||
// change the color and name every second...
|
// change the name and isActive state every second...
|
||||||
var colors = ["#ff6f6f", "#6fff6f", "#6f6fff"];
|
var names = ["BAM!", "BAM!!", "BAM!!!", "BAM!!!!"];
|
||||||
var names = ["BAM!", "BAM!!", "BAM!!!"];
|
var nameIndex = 0;
|
||||||
var colorIndex = 0;
|
|
||||||
Script.setInterval(function () {
|
Script.setInterval(function () {
|
||||||
colorIndex = (colorIndex + 1) % colors.length;
|
nameIndex = (nameIndex + 1) % names.length;
|
||||||
button.editProperties({
|
button.editProperties({
|
||||||
color: colors[colorIndex],
|
isActive: (nameIndex & 0x1) == 0,
|
||||||
text: names[colorIndex]
|
text: names[nameIndex]
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
button.clicked.connect(function () {
|
button.clicked.connect(function () {
|
||||||
print("AJT: BAMM!!! CLICK from JS!");
|
print("AJT: BAM!!! CLICK from JS!");
|
||||||
});
|
});
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
|
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
var button = tablet.addButton({
|
var button = tablet.addButton({
|
||||||
//icon: "help.svg",
|
|
||||||
color: "#ff6f6f",
|
|
||||||
text: "HELP"
|
text: "HELP"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -28,7 +26,7 @@
|
||||||
button.clicked.connect(onClicked);
|
button.clicked.connect(onClicked);
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
tablet.removeButton(buttonName);
|
tablet.removeButton(button);
|
||||||
button.clicked.disconnect(onClicked);
|
button.clicked.disconnect(onClicked);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue