mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:52:26 +02:00
commit
e9476029fb
5 changed files with 157 additions and 163 deletions
|
@ -107,6 +107,10 @@ Item {
|
||||||
}
|
}
|
||||||
MenuItem { action: animations }
|
MenuItem { action: animations }
|
||||||
}
|
}
|
||||||
|
Menu {
|
||||||
|
title: "Long menu name top menu"
|
||||||
|
MenuItem { action: aboutApp }
|
||||||
|
}
|
||||||
Menu {
|
Menu {
|
||||||
title: "Help"
|
title: "Help"
|
||||||
MenuItem { action: aboutApp }
|
MenuItem { action: aboutApp }
|
||||||
|
|
|
@ -5,6 +5,7 @@ import QtQuick.Controls.Styles 1.3
|
||||||
import "controls"
|
import "controls"
|
||||||
import "styles"
|
import "styles"
|
||||||
|
|
||||||
|
|
||||||
Hifi.VrMenu {
|
Hifi.VrMenu {
|
||||||
id: root
|
id: root
|
||||||
HifiConstants { id: hifi }
|
HifiConstants { id: hifi }
|
||||||
|
@ -12,15 +13,14 @@ Hifi.VrMenu {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
objectName: "VrMenu"
|
objectName: "VrMenu"
|
||||||
|
|
||||||
enabled: false
|
enabled: false
|
||||||
opacity: 0.0
|
opacity: 0.0
|
||||||
|
z: 10000
|
||||||
|
|
||||||
property int animationDuration: 200
|
property int animationDuration: 200
|
||||||
property var models: []
|
property var models: []
|
||||||
property var columns: []
|
property var columns: []
|
||||||
|
|
||||||
z: 10000
|
|
||||||
|
|
||||||
onEnabledChanged: {
|
onEnabledChanged: {
|
||||||
if (enabled && columns.length == 0) {
|
if (enabled && columns.length == 0) {
|
||||||
|
@ -51,20 +51,22 @@ Hifi.VrMenu {
|
||||||
property var menuBuilder: Component {
|
property var menuBuilder: Component {
|
||||||
Border {
|
Border {
|
||||||
HifiConstants { id: hifi }
|
HifiConstants { id: hifi }
|
||||||
|
property int menuDepth
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
menuDepth = root.models.length - 1
|
menuDepth = root.models.length - 1
|
||||||
if (menuDepth == 0) {
|
if (menuDepth == 0) {
|
||||||
x = lastMousePosition.x - 20
|
x = lastMousePosition.x - 20
|
||||||
y = lastMousePosition.y - 20
|
y = lastMousePosition.y - 20
|
||||||
} else {
|
} else {
|
||||||
var lastColumn = root.columns[menuDepth - 1]
|
var lastColumn = root.columns[menuDepth - 1]
|
||||||
x = lastColumn.x + 64;
|
x = lastColumn.x + 64;
|
||||||
y = lastMousePosition.y - height / 2;
|
y = lastMousePosition.y - height / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
border.color: hifi.colors.hifiBlue
|
border.color: hifi.colors.hifiBlue
|
||||||
color: hifi.colors.window
|
color: hifi.colors.window
|
||||||
property int menuDepth
|
|
||||||
implicitHeight: listView.implicitHeight + 16
|
implicitHeight: listView.implicitHeight + 16
|
||||||
implicitWidth: listView.implicitWidth + 16
|
implicitWidth: listView.implicitWidth + 16
|
||||||
|
|
||||||
|
@ -84,167 +86,27 @@ Hifi.VrMenu {
|
||||||
model: root.models[menuDepth]
|
model: root.models[menuDepth]
|
||||||
delegate: Loader {
|
delegate: Loader {
|
||||||
id: loader
|
id: loader
|
||||||
sourceComponent: root.itemBuilder
|
source: "VrMenuItem.qml"
|
||||||
Binding {
|
Binding {
|
||||||
target: loader.item
|
target: loader.item
|
||||||
property: "root"
|
property: "menuContainer"
|
||||||
value: root
|
value: root
|
||||||
when: loader.status == Loader.Ready
|
when: loader.status == Loader.Ready
|
||||||
}
|
}
|
||||||
Binding {
|
Binding {
|
||||||
target: loader.item
|
target: loader.item
|
||||||
property: "source"
|
property: "source"
|
||||||
value: modelData
|
value: modelData
|
||||||
when: loader.status == Loader.Ready
|
when: loader.status == Loader.Ready
|
||||||
}
|
}
|
||||||
Binding {
|
|
||||||
target: loader.item
|
|
||||||
property: "border"
|
|
||||||
value: listView.parent
|
|
||||||
when: loader.status == Loader.Ready
|
|
||||||
}
|
|
||||||
Binding {
|
Binding {
|
||||||
target: loader.item
|
target: loader.item
|
||||||
property: "listView"
|
property: "listView"
|
||||||
value: listView
|
value: listView
|
||||||
when: loader.status == Loader.Ready
|
when: loader.status == Loader.Ready
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
property var itemBuilder: Component {
|
|
||||||
Item {
|
|
||||||
property var source
|
|
||||||
property var root
|
|
||||||
property var listView
|
|
||||||
property var border
|
|
||||||
implicitHeight: row.implicitHeight + 4
|
|
||||||
implicitWidth: row.implicitWidth + label.height
|
|
||||||
// FIXME uncommenting this line results in menus that have blank spots
|
|
||||||
// rather than having the correct size
|
|
||||||
// visible: source.visible
|
|
||||||
Row {
|
|
||||||
id: row
|
|
||||||
spacing: 2
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
topMargin: 2
|
|
||||||
}
|
|
||||||
Spacer { size: 4 }
|
|
||||||
FontAwesome {
|
|
||||||
id: check
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
y: 2
|
|
||||||
size: label.height
|
|
||||||
text: checkText()
|
|
||||||
color: label.color
|
|
||||||
function checkText() {
|
|
||||||
if (!source || source.type != 1 || !source.checkable) {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME this works for native QML menus but I don't think it will
|
|
||||||
// for proxied QML menus
|
|
||||||
if (source.exclusiveGroup) {
|
|
||||||
return source.checked ? "\uF05D" : "\uF10C"
|
|
||||||
}
|
|
||||||
return source.checked ? "\uF046" : "\uF096"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text {
|
|
||||||
id: label
|
|
||||||
text: typedText()
|
|
||||||
color: source.enabled ? hifi.colors.text : hifi.colors.disabledText
|
|
||||||
enabled: source.enabled && source.visible
|
|
||||||
function typedText() {
|
|
||||||
if (source) {
|
|
||||||
switch(source.type) {
|
|
||||||
case 2:
|
|
||||||
return source.title;
|
|
||||||
case 1:
|
|
||||||
return source.text;
|
|
||||||
case 0:
|
|
||||||
return "-----"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // row
|
|
||||||
|
|
||||||
FontAwesome {
|
|
||||||
anchors {
|
|
||||||
top: row.top
|
|
||||||
}
|
|
||||||
id: tag
|
|
||||||
size: label.height
|
|
||||||
width: implicitWidth
|
|
||||||
visible: source.type == 2
|
|
||||||
x: listView.width - width - 4
|
|
||||||
text: "\uF0DA"
|
|
||||||
color: label.color
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
bottom: parent.bottom
|
|
||||||
left: parent.left
|
|
||||||
right: tag.right
|
|
||||||
rightMargin: -4
|
|
||||||
}
|
|
||||||
acceptedButtons: Qt.LeftButton
|
|
||||||
hoverEnabled: true
|
|
||||||
Rectangle {
|
|
||||||
id: highlight
|
|
||||||
visible: false
|
|
||||||
anchors.fill: parent
|
|
||||||
color: "#7f0e7077"
|
|
||||||
}
|
|
||||||
Timer {
|
|
||||||
id: timer
|
|
||||||
interval: 1000
|
|
||||||
onTriggered: parent.select();
|
|
||||||
}
|
|
||||||
onEntered: {
|
|
||||||
/*
|
|
||||||
* Uncomment below to have menus auto-popup
|
|
||||||
*
|
|
||||||
* FIXME if we enabled timer based menu popup, either the timer has
|
|
||||||
* to be very very short or after auto popup there has to be a small
|
|
||||||
* amount of time, or a test if the mouse has moved before a click
|
|
||||||
* will be accepted, otherwise it's too easy to accidently click on
|
|
||||||
* something immediately after the auto-popup appears underneath your
|
|
||||||
* cursor
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
//if (source.type == 2 && enabled) {
|
|
||||||
// timer.start()
|
|
||||||
//}
|
|
||||||
highlight.visible = source.enabled
|
|
||||||
}
|
|
||||||
onExited: {
|
|
||||||
timer.stop()
|
|
||||||
highlight.visible = false
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
select();
|
|
||||||
}
|
|
||||||
function select() {
|
|
||||||
//timer.stop();
|
|
||||||
var popped = false;
|
|
||||||
while (columns.length - 1 > listView.parent.menuDepth) {
|
|
||||||
popColumn();
|
|
||||||
popped = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!popped || source.type != 1) {
|
|
||||||
parent.root.selectItem(parent.source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +121,7 @@ Hifi.VrMenu {
|
||||||
var oldColumn = lastColumn();
|
var oldColumn = lastColumn();
|
||||||
//oldColumn.enabled = false
|
//oldColumn.enabled = false
|
||||||
}
|
}
|
||||||
var newColumn = menuBuilder.createObject(root);
|
var newColumn = menuBuilder.createObject(root);
|
||||||
columns.push(newColumn);
|
columns.push(newColumn);
|
||||||
newColumn.forceActiveFocus();
|
newColumn.forceActiveFocus();
|
||||||
}
|
}
|
||||||
|
@ -292,11 +154,11 @@ Hifi.VrMenu {
|
||||||
source.trigger()
|
source.trigger()
|
||||||
enabled = false
|
enabled = false
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
while (columns.length > 0) {
|
while (columns.length > 0) {
|
||||||
popColumn();
|
popColumn();
|
||||||
|
|
130
interface/resources/qml/VrMenuItem.qml
Normal file
130
interface/resources/qml/VrMenuItem.qml
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
import QtQuick 2.4
|
||||||
|
import QtQuick.Controls 1.3
|
||||||
|
import QtQuick.Controls.Styles 1.3
|
||||||
|
import "controls"
|
||||||
|
import "styles"
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
HifiConstants {
|
||||||
|
id: hifi
|
||||||
|
}
|
||||||
|
|
||||||
|
property var source
|
||||||
|
property var menuContainer
|
||||||
|
property var listView
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: tag.right
|
||||||
|
anchors.rightMargin: -4
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
hoverEnabled: true
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: highlight
|
||||||
|
visible: false
|
||||||
|
anchors.fill: parent
|
||||||
|
color: "#7f0e7077"
|
||||||
|
}
|
||||||
|
|
||||||
|
onEntered: {
|
||||||
|
//if (source.type == 2 && enabled) {
|
||||||
|
// timer.start()
|
||||||
|
//}
|
||||||
|
highlight.visible = source.enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
timer.stop()
|
||||||
|
highlight.visible = false
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
select()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
implicitHeight: label.implicitHeight * 1.5
|
||||||
|
implicitWidth: label.implicitWidth + label.height * 2.5
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: timer
|
||||||
|
interval: 1000
|
||||||
|
onTriggered: parent.select()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FontAwesome {
|
||||||
|
clip: true
|
||||||
|
id: check
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
color: label.color
|
||||||
|
text: checkText()
|
||||||
|
size: label.height
|
||||||
|
font.pixelSize: size
|
||||||
|
function checkText() {
|
||||||
|
if (!source || source.type != 1 || !source.checkable) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
// FIXME this works for native QML menus but I don't think it will
|
||||||
|
// for proxied QML menus
|
||||||
|
if (source.exclusiveGroup) {
|
||||||
|
return source.checked ? "\uF05D" : "\uF10C"
|
||||||
|
}
|
||||||
|
return source.checked ? "\uF046" : "\uF096"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: label
|
||||||
|
text: typedText()
|
||||||
|
anchors.left: check.right
|
||||||
|
anchors.leftMargin: 4
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
color: source.enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||||
|
enabled: source.enabled && source.visible
|
||||||
|
function typedText() {
|
||||||
|
if (source) {
|
||||||
|
switch (source.type) {
|
||||||
|
case 2:
|
||||||
|
return source.title
|
||||||
|
case 1:
|
||||||
|
return source.text
|
||||||
|
case 0:
|
||||||
|
return "-----"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FontAwesome {
|
||||||
|
id: tag
|
||||||
|
x: listView.width - width - 4
|
||||||
|
size: label.height
|
||||||
|
width: implicitWidth
|
||||||
|
visible: source.type == 2
|
||||||
|
text: "\uF0DA"
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
color: label.color
|
||||||
|
}
|
||||||
|
|
||||||
|
function select() {
|
||||||
|
//timer.stop();
|
||||||
|
var popped = false
|
||||||
|
while (columns.length - 1 > listView.parent.menuDepth) {
|
||||||
|
popColumn()
|
||||||
|
popped = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!popped || source.type != 1) {
|
||||||
|
root.menuContainer.selectItem(source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -795,7 +795,6 @@ void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) {
|
||||||
glm::vec3 OculusManager::getRelativePosition() {
|
glm::vec3 OculusManager::getRelativePosition() {
|
||||||
ovrTrackingState trackingState = ovrHmd_GetTrackingState(_ovrHmd, ovr_GetTimeInSeconds());
|
ovrTrackingState trackingState = ovrHmd_GetTrackingState(_ovrHmd, ovr_GetTimeInSeconds());
|
||||||
ovrVector3f headPosition = trackingState.HeadPose.ThePose.Position;
|
ovrVector3f headPosition = trackingState.HeadPose.ThePose.Position;
|
||||||
|
|
||||||
return glm::vec3(headPosition.x, headPosition.y, headPosition.z);
|
return glm::vec3(headPosition.x, headPosition.y, headPosition.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#include "MessageDialog.h"
|
#include "MessageDialog.h"
|
||||||
#include "VrMenu.h"
|
#include "VrMenu.h"
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
|
||||||
class RateCounter {
|
class RateCounter {
|
||||||
std::vector<float> times;
|
std::vector<float> times;
|
||||||
|
@ -339,8 +340,14 @@ public:
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
|
|
||||||
offscreenUi->setProxyWindow(this);
|
offscreenUi->setProxyWindow(this);
|
||||||
setFramePosition(QPoint(-1000, 0));
|
QDesktopWidget* desktop = QApplication::desktop();
|
||||||
resize(QSize(800, 600));
|
QRect rect = desktop->availableGeometry(desktop->screenCount() - 1);
|
||||||
|
int height = rect.height();
|
||||||
|
//rect.setHeight(height / 2);
|
||||||
|
rect.setY(rect.y() + height / 2);
|
||||||
|
setGeometry(rect);
|
||||||
|
// setFramePosition(QPoint(-1000, 0));
|
||||||
|
// resize(QSize(800, 600));
|
||||||
|
|
||||||
#ifdef QML_CONTROL_GALLERY
|
#ifdef QML_CONTROL_GALLERY
|
||||||
offscreenUi->setBaseUrl(QUrl::fromLocalFile(getTestQmlDir()));
|
offscreenUi->setBaseUrl(QUrl::fromLocalFile(getTestQmlDir()));
|
||||||
|
@ -474,16 +481,8 @@ hifi.offscreen.focus.debug=false
|
||||||
qt.quick.mouse.debug=false
|
qt.quick.mouse.debug=false
|
||||||
)V0G0N";
|
)V0G0N";
|
||||||
|
|
||||||
//int main(int argc, char *argv[]) {
|
|
||||||
// QGuiApplication app(argc, argv);
|
|
||||||
// QQmlApplicationEngine engine;
|
|
||||||
// engine.setBaseUrl(QUrl::fromLocalFile(getQmlDir()));
|
|
||||||
// engine.load(QUrl("Main.qml"));
|
|
||||||
// return app.exec();
|
|
||||||
//}
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
QGuiApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
|
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
|
||||||
QTestWindow window;
|
QTestWindow window;
|
||||||
app.exec();
|
app.exec();
|
||||||
|
|
Loading…
Reference in a new issue