add a tablet contextual mode flag to HMDScriptingInterface used to keep tablet in place

This commit is contained in:
David Back 2017-10-23 14:21:18 -07:00
parent ea38b32dea
commit b5f1793863
4 changed files with 15 additions and 4 deletions

View file

@ -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()
}

View file

@ -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) {

View file

@ -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;

View file

@ -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 });