From b5f1793863506ed6b9518c7af325fd0530b6bf2d Mon Sep 17 00:00:00 2001 From: David Back Date: Mon, 23 Oct 2017 14:21:18 -0700 Subject: [PATCH 1/3] 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 }); From 80dc98b2c2403c71f1011fed6134292dd5dcae28 Mon Sep 17 00:00:00 2001 From: David Back Date: Mon, 23 Oct 2017 14:23:45 -0700 Subject: [PATCH 2/3] remove prints --- scripts/system/tablet-ui/tabletUI.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/system/tablet-ui/tabletUI.js b/scripts/system/tablet-ui/tabletUI.js index c10ded5774..17821c737e 100644 --- a/scripts/system/tablet-ui/tabletUI.js +++ b/scripts/system/tablet-ui/tabletUI.js @@ -124,10 +124,6 @@ print("TABLET in showTabletUI, already rezzed"); } var 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); } From 08a6eb4dd399ef4f5cdeca95ae4ab8fb50efe97f Mon Sep 17 00:00:00 2001 From: David Back Date: Tue, 24 Oct 2017 15:50:09 -0700 Subject: [PATCH 3/3] reset tablet contextual mode back to false when toggling tablet show/hide --- interface/src/scripting/HMDScriptingInterface.cpp | 9 +++++++++ interface/src/scripting/HMDScriptingInterface.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/interface/src/scripting/HMDScriptingInterface.cpp b/interface/src/scripting/HMDScriptingInterface.cpp index 0b6800395f..31b8f74e9e 100644 --- a/interface/src/scripting/HMDScriptingInterface.cpp +++ b/interface/src/scripting/HMDScriptingInterface.cpp @@ -108,6 +108,15 @@ void HMDScriptingInterface::openTablet(bool contextualMode) { _tabletContextualMode = contextualMode; } +void HMDScriptingInterface::toggleShouldShowTablet() { + setShouldShowTablet(!getShouldShowTablet()); +} + +void HMDScriptingInterface::setShouldShowTablet(bool value) { + _showTablet = value; + _tabletContextualMode = false; +} + QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) { glm::vec3 hudIntersection; auto instance = DependencyManager::get(); diff --git a/interface/src/scripting/HMDScriptingInterface.h b/interface/src/scripting/HMDScriptingInterface.h index 76bab77cbb..ef8ea95704 100644 --- a/interface/src/scripting/HMDScriptingInterface.h +++ b/interface/src/scripting/HMDScriptingInterface.h @@ -89,8 +89,8 @@ public: bool isMounted() const; - void toggleShouldShowTablet() { _showTablet = !_showTablet; } - void setShouldShowTablet(bool value) { _showTablet = value; } + void toggleShouldShowTablet(); + void setShouldShowTablet(bool value); bool getShouldShowTablet() const { return _showTablet; } bool getTabletContextualMode() const { return _tabletContextualMode; }