mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:49:24 +02:00
Simpler code!
This commit is contained in:
parent
bfb4c0c49a
commit
2c604d2c5b
1 changed files with 47 additions and 245 deletions
|
@ -22,14 +22,15 @@ Rectangle {
|
||||||
|
|
||||||
property int originalWidth: 48
|
property int originalWidth: 48
|
||||||
property int expandedWidth: mainEmojiContainer.width + drawerContainer.width
|
property int expandedWidth: mainEmojiContainer.width + drawerContainer.width
|
||||||
|
// For the below to work, the Repeater's Item's second child must be the individual button's `MouseArea`
|
||||||
property int requestedWidth: (drawerContainer.keepDrawerExpanded ||
|
property int requestedWidth: (drawerContainer.keepDrawerExpanded ||
|
||||||
emoteIndicatorMouseArea.containsMouse ||
|
emoteIndicatorMouseArea.containsMouse ||
|
||||||
happyButtonMouseArea.containsMouse ||
|
emoteButtonsRepeater.itemAt(0).children[1].containsMouse ||
|
||||||
sadButtonMouseArea.containsMouse ||
|
emoteButtonsRepeater.itemAt(1).children[1].containsMouse ||
|
||||||
raiseHandButtonMouseArea.containsMouse ||
|
emoteButtonsRepeater.itemAt(2).children[1].containsMouse ||
|
||||||
applaudButtonMouseArea.containsMouse ||
|
emoteButtonsRepeater.itemAt(3).children[1].containsMouse ||
|
||||||
pointButtonMouseArea.containsMouse ||
|
emoteButtonsRepeater.itemAt(4).children[1].containsMouse ||
|
||||||
emojiButtonMouseArea.containsMouse) ? expandedWidth : originalWidth;
|
emoteButtonsRepeater.itemAt(5).children[1].containsMouse) ? expandedWidth : originalWidth;
|
||||||
|
|
||||||
onRequestedWidthChanged: {
|
onRequestedWidthChanged: {
|
||||||
root.requestNewWidth(root.requestedWidth);
|
root.requestNewWidth(root.requestedWidth);
|
||||||
|
@ -83,254 +84,55 @@ Rectangle {
|
||||||
id: drawerContainer
|
id: drawerContainer
|
||||||
property bool keepDrawerExpanded: false
|
property bool keepDrawerExpanded: false
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
leftPadding: root.originalWidth
|
anchors.left: mainEmojiContainer.right
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
|
|
||||||
Rectangle {
|
Repeater {
|
||||||
id: happyButtonContainer
|
id: emoteButtonsRepeater
|
||||||
width: root.originalWidth
|
model: ListModel {
|
||||||
height: drawerContainer.height
|
id: buttonsModel
|
||||||
color: simplifiedUI.colors.white
|
ListElement { text: "Z"; method: "happyPressed" }
|
||||||
|
ListElement { text: "C"; method: "sadPressed" }
|
||||||
HifiStylesUit.GraphikRegular {
|
ListElement { text: "V"; method: "raiseHandPressed" }
|
||||||
text: "Z"
|
ListElement { text: "B"; method: "applaudPressed" }
|
||||||
anchors.fill: parent
|
ListElement { text: "N"; method: "pointPressed" }
|
||||||
anchors.rightMargin: 1
|
ListElement { text: "😊"; method: "toggleEmojiApp" }
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
size: 26
|
|
||||||
color: simplifiedUI.colors.text.black
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
Rectangle {
|
||||||
id: happyButtonMouseArea
|
width: mainEmojiContainer.width
|
||||||
anchors.fill: parent
|
height: drawerContainer.height
|
||||||
hoverEnabled: enabled
|
// For the below to work, the This Rectangle's second child must be the `MouseArea`
|
||||||
|
color: children[1].containsMouse ? "#CCCCCC" : simplifiedUI.colors.white
|
||||||
|
|
||||||
onClicked: {
|
HifiStylesUit.GraphikRegular {
|
||||||
Tablet.playSound(TabletEnums.ButtonClick);
|
text: model.text
|
||||||
sendToScript({
|
// Gotta special-case the below for the emoji button, or else it looks off-center.
|
||||||
"source": "EmoteAppBar.qml",
|
anchors.fill: text === "😊" ? undefined : parent
|
||||||
"method": "happyPressed"
|
anchors.horizontalCenter: text === "😊" ? parent.horizontalCenter : undefined
|
||||||
});
|
anchors.verticalCenter: text === "😊" ? parent.verticalCenter : undefined
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
anchors.horizontalCenterOffset: text === "😊" ? -2 : undefined
|
||||||
|
anchors.verticalCenterOffset: text === "😊" ? -2 : undefined
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
size: 26
|
||||||
|
color: simplifiedUI.colors.text.black
|
||||||
}
|
}
|
||||||
|
|
||||||
onEntered: {
|
MouseArea {
|
||||||
console.log("ENTERED BUTTON");
|
anchors.fill: parent
|
||||||
Tablet.playSound(TabletEnums.ButtonHover);
|
hoverEnabled: true
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
onClicked: {
|
||||||
}
|
Tablet.playSound(TabletEnums.ButtonClick);
|
||||||
|
sendToScript({
|
||||||
|
"source": "EmoteAppBar.qml",
|
||||||
|
"method": model.method
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onExited: {
|
onEntered: {
|
||||||
parent.color = simplifiedUI.colors.white
|
Tablet.playSound(TabletEnums.ButtonHover);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: sadButtonContainer
|
|
||||||
width: root.originalWidth
|
|
||||||
height: drawerContainer.height
|
|
||||||
color: simplifiedUI.colors.white
|
|
||||||
|
|
||||||
HifiStylesUit.GraphikRegular {
|
|
||||||
text: "C"
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.rightMargin: 1
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
size: 26
|
|
||||||
color: simplifiedUI.colors.text.black
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: sadButtonMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: enabled
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
Tablet.playSound(TabletEnums.ButtonClick);
|
|
||||||
sendToScript({
|
|
||||||
"source": "EmoteAppBar.qml",
|
|
||||||
"method": "sadPressed"
|
|
||||||
});
|
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
|
||||||
}
|
|
||||||
|
|
||||||
onEntered: {
|
|
||||||
console.log("ENTERED BUTTON");
|
|
||||||
Tablet.playSound(TabletEnums.ButtonHover);
|
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
|
||||||
}
|
|
||||||
|
|
||||||
onExited: {
|
|
||||||
parent.color = simplifiedUI.colors.white
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: raiseHandButtonContainer
|
|
||||||
width: root.originalWidth
|
|
||||||
height: drawerContainer.height
|
|
||||||
color: simplifiedUI.colors.white
|
|
||||||
|
|
||||||
HifiStylesUit.GraphikRegular {
|
|
||||||
text: "V"
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.rightMargin: 1
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
size: 26
|
|
||||||
color: simplifiedUI.colors.text.black
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: raiseHandButtonMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: enabled
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
Tablet.playSound(TabletEnums.ButtonClick);
|
|
||||||
sendToScript({
|
|
||||||
"source": "EmoteAppBar.qml",
|
|
||||||
"method": "raiseHandPressed"
|
|
||||||
});
|
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
|
||||||
}
|
|
||||||
|
|
||||||
onEntered: {
|
|
||||||
console.log("ENTERED BUTTON");
|
|
||||||
Tablet.playSound(TabletEnums.ButtonHover);
|
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
|
||||||
}
|
|
||||||
|
|
||||||
onExited: {
|
|
||||||
parent.color = simplifiedUI.colors.white
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: applaudButtonContainer
|
|
||||||
width: root.originalWidth
|
|
||||||
height: drawerContainer.height
|
|
||||||
color: simplifiedUI.colors.white
|
|
||||||
|
|
||||||
HifiStylesUit.GraphikRegular {
|
|
||||||
text: "B"
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.rightMargin: 1
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
size: 26
|
|
||||||
color: simplifiedUI.colors.text.black
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: applaudButtonMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: enabled
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
Tablet.playSound(TabletEnums.ButtonClick);
|
|
||||||
sendToScript({
|
|
||||||
"source": "EmoteAppBar.qml",
|
|
||||||
"method": "applaudPressed"
|
|
||||||
});
|
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
|
||||||
}
|
|
||||||
|
|
||||||
onEntered: {
|
|
||||||
console.log("ENTERED BUTTON");
|
|
||||||
Tablet.playSound(TabletEnums.ButtonHover);
|
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
|
||||||
}
|
|
||||||
|
|
||||||
onExited: {
|
|
||||||
parent.color = simplifiedUI.colors.white
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: pointButtonContainer
|
|
||||||
width: root.originalWidth
|
|
||||||
height: drawerContainer.height
|
|
||||||
color: simplifiedUI.colors.white
|
|
||||||
|
|
||||||
HifiStylesUit.GraphikRegular {
|
|
||||||
text: "N"
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.rightMargin: 1
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
size: 26
|
|
||||||
color: simplifiedUI.colors.text.black
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: pointButtonMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: enabled
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
Tablet.playSound(TabletEnums.ButtonClick);
|
|
||||||
sendToScript({
|
|
||||||
"source": "EmoteAppBar.qml",
|
|
||||||
"method": "pointPressed"
|
|
||||||
});
|
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
|
||||||
}
|
|
||||||
|
|
||||||
onEntered: {
|
|
||||||
console.log("ENTERED BUTTON");
|
|
||||||
Tablet.playSound(TabletEnums.ButtonHover);
|
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
|
||||||
}
|
|
||||||
|
|
||||||
onExited: {
|
|
||||||
parent.color = simplifiedUI.colors.white
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: emojiButtonContainer
|
|
||||||
width: root.originalWidth
|
|
||||||
height: drawerContainer.height
|
|
||||||
color: simplifiedUI.colors.white
|
|
||||||
|
|
||||||
HifiStylesUit.GraphikRegular {
|
|
||||||
text: "😊"
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.horizontalCenterOffset: -2
|
|
||||||
anchors.verticalCenterOffset: -2
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
size: 26
|
|
||||||
color: simplifiedUI.colors.text.black
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: emojiButtonMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: enabled
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
Tablet.playSound(TabletEnums.ButtonClick);
|
|
||||||
sendToScript({
|
|
||||||
"source": "EmoteAppBar.qml",
|
|
||||||
"method": "toggleEmojiApp"
|
|
||||||
});
|
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
|
||||||
}
|
|
||||||
|
|
||||||
onEntered: {
|
|
||||||
console.log("ENTERED BUTTON");
|
|
||||||
Tablet.playSound(TabletEnums.ButtonHover);
|
|
||||||
parent.color = simplifiedUI.colors.darkBackground
|
|
||||||
}
|
|
||||||
|
|
||||||
onExited: {
|
|
||||||
parent.color = simplifiedUI.colors.white
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue