From b5f1793863506ed6b9518c7af325fd0530b6bf2d Mon Sep 17 00:00:00 2001 From: David Back Date: Mon, 23 Oct 2017 14:21:18 -0700 Subject: [PATCH] add a tablet contextual mode flag to HMDScriptingInterface used to keep tablet in place --- interface/resources/qml/hifi/tablet/TabletRoot.qml | 2 +- interface/src/scripting/HMDScriptingInterface.cpp | 4 +++- interface/src/scripting/HMDScriptingInterface.h | 5 ++++- scripts/system/tablet-ui/tabletUI.js | 8 +++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/TabletRoot.qml b/interface/resources/qml/hifi/tablet/TabletRoot.qml index ba9d06eee3..a161741049 100644 --- a/interface/resources/qml/hifi/tablet/TabletRoot.qml +++ b/interface/resources/qml/hifi/tablet/TabletRoot.qml @@ -219,7 +219,7 @@ Item { function setShown(value) { if (value === true) { - HMD.openTablet() + HMD.openTablet(HMD.tabletContextualMode) // pass in current contextual mode flag to maintain flag (otherwise uses default false argument) } else { HMD.closeTablet() } diff --git a/interface/src/scripting/HMDScriptingInterface.cpp b/interface/src/scripting/HMDScriptingInterface.cpp index 39d3164f1f..0b6800395f 100644 --- a/interface/src/scripting/HMDScriptingInterface.cpp +++ b/interface/src/scripting/HMDScriptingInterface.cpp @@ -100,10 +100,12 @@ void HMDScriptingInterface::deactivateHMDHandMouse() { void HMDScriptingInterface::closeTablet() { _showTablet = false; + _tabletContextualMode = false; } -void HMDScriptingInterface::openTablet() { +void HMDScriptingInterface::openTablet(bool contextualMode) { _showTablet = true; + _tabletContextualMode = contextualMode; } QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) { diff --git a/interface/src/scripting/HMDScriptingInterface.h b/interface/src/scripting/HMDScriptingInterface.h index e5040b1f90..76bab77cbb 100644 --- a/interface/src/scripting/HMDScriptingInterface.h +++ b/interface/src/scripting/HMDScriptingInterface.h @@ -30,6 +30,7 @@ class HMDScriptingInterface : public AbstractHMDScriptingInterface, public Depen Q_PROPERTY(glm::quat orientation READ getOrientation) Q_PROPERTY(bool mounted READ isMounted NOTIFY mountedChanged) Q_PROPERTY(bool showTablet READ getShouldShowTablet) + Q_PROPERTY(bool tabletContextualMode READ getTabletContextualMode) Q_PROPERTY(QUuid tabletID READ getCurrentTabletFrameID WRITE setCurrentTabletFrameID) Q_PROPERTY(QUuid homeButtonID READ getCurrentHomeButtonID WRITE setCurrentHomeButtonID) Q_PROPERTY(QUuid homeButtonHighlightID READ getCurrentHomeButtonHightlightID WRITE setCurrentHomeButtonHightlightID) @@ -75,7 +76,7 @@ public: Q_INVOKABLE void closeTablet(); - Q_INVOKABLE void openTablet(); + Q_INVOKABLE void openTablet(bool contextualMode = false); signals: bool shouldShowHandControllersChanged(); @@ -91,6 +92,7 @@ public: void toggleShouldShowTablet() { _showTablet = !_showTablet; } void setShouldShowTablet(bool value) { _showTablet = value; } bool getShouldShowTablet() const { return _showTablet; } + bool getTabletContextualMode() const { return _tabletContextualMode; } void setCurrentTabletFrameID(QUuid tabletID) { _tabletUIID = tabletID; } QUuid getCurrentTabletFrameID() const { return _tabletUIID; } @@ -106,6 +108,7 @@ public: private: bool _showTablet { false }; + bool _tabletContextualMode { false }; QUuid _tabletUIID; // this is the entityID of the tablet frame QUuid _tabletScreenID; // this is the overlayID which is part of (a child of) the tablet-ui. QUuid _homeButtonID; diff --git a/scripts/system/tablet-ui/tabletUI.js b/scripts/system/tablet-ui/tabletUI.js index 554729f61e..c10ded5774 100644 --- a/scripts/system/tablet-ui/tabletUI.js +++ b/scripts/system/tablet-ui/tabletUI.js @@ -124,7 +124,13 @@ print("TABLET in showTabletUI, already rezzed"); } var tabletProperties = {}; - UIWebTablet.calculateTabletAttachmentProperties(activeHand, true, tabletProperties); + if (HMD.tabletContextualMode) + print("DBACK tabletContextualMode"); + else + print("DBACK NOT tabletContextualMode"); + if (!HMD.tabletContextualMode) { // contextual mode forces tablet in place -> don't update attachment + UIWebTablet.calculateTabletAttachmentProperties(activeHand, true, tabletProperties); + } tabletProperties.visible = true; Overlays.editOverlay(HMD.tabletID, tabletProperties); Overlays.editOverlay(HMD.homeButtonID, { visible: true });