Tweaking VR menu for PR

This commit is contained in:
Brad Davis 2015-04-27 11:35:57 -07:00
parent 1a912787c2
commit d55d467d3f
6 changed files with 42 additions and 17 deletions

View file

@ -94,6 +94,9 @@ Hifi.VrMenu {
var newWidth = minWidth; var newWidth = minWidth;
for (var i = 0; i < children.length; ++i) { for (var i = 0; i < children.length; ++i) {
var item = children[i]; var item = children[i];
if (!item.visible) {
continue
}
newHeight += item.height newHeight += item.height
} }
parent.height = newHeight + outerMargin * 2; parent.height = newHeight + outerMargin * 2;
@ -152,8 +155,23 @@ Hifi.VrMenu {
height: implicitHeight height: implicitHeight
width: implicitWidth width: implicitWidth
color: source.enabled ? hifi.colors.text : hifi.colors.disabledText color: source.enabled ? hifi.colors.text : hifi.colors.disabledText
enabled: source.enabled enabled: source.enabled && source.visible
// FIXME uncommenting this line results in menus that have blank spots
// rather than having the correct size
// visible: source.visible
onListViewChanged: {
if (listView) {
listView.minWidth = Math.max(listView.minWidth, implicitWidth + 64);
listView.recalculateSize();
}
}
onVisibleChanged: {
if (listView) {
listView.recalculateSize();
}
}
onImplicitWidthChanged: { onImplicitWidthChanged: {
if (listView) { if (listView) {

View file

@ -63,7 +63,7 @@
#include <GlowEffect.h> #include <GlowEffect.h>
#include <HFActionEvent.h> #include <HFActionEvent.h>
#include <HFBackEvent.h> #include <HFBackEvent.h>
#include <HifiMenu.h> #include <VrMenu.h>
#include <LogHandler.h> #include <LogHandler.h>
#include <MainWindow.h> #include <MainWindow.h>
#include <ModelEntityItem.h> #include <ModelEntityItem.h>
@ -1327,13 +1327,16 @@ void Application::keyPressEvent(QKeyEvent* event) {
} }
} }
//#define VR_MENU_ONLY_IN_HMD
void Application::keyReleaseEvent(QKeyEvent* event) { void Application::keyReleaseEvent(QKeyEvent* event) {
if (event->key() == Qt::Key_Alt && _altPressed && _window->isActiveWindow()) { if (event->key() == Qt::Key_Alt && _altPressed && _window->isActiveWindow()) {
#ifndef DEBUG #ifdef VR_MENU_ONLY_IN_HMD
if (OculusManager::isConnected()) { if (OculusManager::isConnected()) {
#endif #endif
VrMenu::toggle(); VrMenu::toggle();
#ifndef DEBUG #ifdef VR_MENU_ONLY_IN_HMD
} }
#endif #endif
} }

View file

@ -20,7 +20,7 @@
#include <PathUtils.h> #include <PathUtils.h>
#include <SettingHandle.h> #include <SettingHandle.h>
#include <UserActivityLogger.h> #include <UserActivityLogger.h>
#include <HifiMenu.h> #include <VrMenu.h>
#include "Application.h" #include "Application.h"
#include "AccountManager.h" #include "AccountManager.h"

View file

@ -1,5 +1,5 @@
// //
// HifiMenu.cpp // VrMenu.cpp
// //
// Created by Bradley Austin Davis on 2015/04/21 // Created by Bradley Austin Davis on 2015/04/21
// Copyright 2015 High Fidelity, Inc. // Copyright 2015 High Fidelity, Inc.
@ -8,11 +8,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "HifiMenu.h" #include "VrMenu.h"
#include <QtQml> #include <QtQml>
#include <QMenuBar> #include <QMenuBar>
// Binds together a Qt Action or Menu with the QML Menu or MenuItem // Binds together a Qt Action or Menu with the QML Menu or MenuItem
//
// TODO On reflection, it may be pointless to use the UUID. Perhaps
// simply creating the bidirectional link pointing to both the widget
// and qml object and inject the pointer into both objects
class MenuUserData : public QObjectUserData { class MenuUserData : public QObjectUserData {
static const int USER_DATA_ID; static const int USER_DATA_ID;
@ -69,7 +73,7 @@ VrMenu::VrMenu(QQuickItem* parent) : QQuickItem(parent) {
} }
// QML helper functions // QML helper functions
QObject* addMenu(QObject* parent, const QString & text) { QObject* addMenu(QObject* parent, const QString& text) {
// FIXME add more checking here to ensure no name conflicts // FIXME add more checking here to ensure no name conflicts
QVariant returnedValue; QVariant returnedValue;
QMetaObject::invokeMethod(parent, "addMenu", Qt::DirectConnection, QMetaObject::invokeMethod(parent, "addMenu", Qt::DirectConnection,
@ -94,7 +98,7 @@ QObject* addItem(QObject* parent, const QString& text) {
return result; return result;
} }
const QObject* VrMenu::findMenuObject(const QString & menuOption) const { const QObject* VrMenu::findMenuObject(const QString& menuOption) const {
if (menuOption.isEmpty()) { if (menuOption.isEmpty()) {
return _rootMenu; return _rootMenu;
} }
@ -102,7 +106,7 @@ const QObject* VrMenu::findMenuObject(const QString & menuOption) const {
return result; return result;
} }
QObject* VrMenu::findMenuObject(const QString & menuOption) { QObject* VrMenu::findMenuObject(const QString& menuOption) {
if (menuOption.isEmpty()) { if (menuOption.isEmpty()) {
return _rootMenu; return _rootMenu;
} }

View file

@ -1,5 +1,5 @@
// //
// HifiMenu.h // VrMenu.h
// //
// Created by Bradley Austin Davis on 2015/04/21 // Created by Bradley Austin Davis on 2015/04/21
// Copyright 2015 High Fidelity, Inc. // Copyright 2015 High Fidelity, Inc.
@ -9,8 +9,8 @@
// //
#pragma once #pragma once
#ifndef hifi_HifiMenu_h #ifndef hifi_VrMenu_h
#define hifi_HifiMenu_h #define hifi_VrMenu_h
#include <QQuickItem> #include <QQuickItem>
#include <QHash> #include <QHash>
@ -20,7 +20,7 @@
#include <QMenu> #include <QMenu>
#include "OffscreenUi.h" #include "OffscreenUi.h"
// FIXME rename the compilation files to VrMenu.h and VrMenu.cpp after upstream pull requests are merged. // FIXME break up the rendering code (VrMenu) and the code for mirroring a Widget based menu in QML
class VrMenu : public QQuickItem { class VrMenu : public QQuickItem {
Q_OBJECT Q_OBJECT
HIFI_QML_DECL_LAMBDA HIFI_QML_DECL_LAMBDA
@ -45,4 +45,4 @@ protected:
friend class MenuUserData; friend class MenuUserData;
}; };
#endif // hifi_HifiMenu_h #endif // hifi_VrMenu_h

View file

@ -35,7 +35,7 @@
#include <QDir> #include <QDir>
#include "MessageDialog.h" #include "MessageDialog.h"
#include "HifiMenu.h" #include "VrMenu.h"
class RateCounter { class RateCounter {
std::vector<float> times; std::vector<float> times;