diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index 59d5b435ba..e5ff849df8 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -25,6 +25,7 @@ FocusScope { property rect recommendedRect: Qt.rect(0,0,0,0); property var expectedChildren; property bool repositionLocked: true + property bool hmdHandMouseActive: false onRepositionLockedChanged: { if (!repositionLocked) { diff --git a/interface/resources/qml/windows/Decoration.qml b/interface/resources/qml/windows/Decoration.qml index 628a4d3370..edfb369c0f 100644 --- a/interface/resources/qml/windows/Decoration.qml +++ b/interface/resources/qml/windows/Decoration.qml @@ -17,6 +17,9 @@ import "../styles-uit" Rectangle { HifiConstants { id: hifi } + signal inflateDecorations(); + signal deflateDecorations(); + property int frameMargin: 9 property int frameMarginLeft: frameMargin property int frameMarginRight: frameMargin @@ -43,5 +46,26 @@ Rectangle { anchors.fill: parent drag.target: window } + Connections { + target: window + onMouseEntered: { + if (desktop.hmdHandMouseActive) { + root.inflateDecorations() + } + } + onMouseExited: root.deflateDecorations(); + } + Connections { + target: desktop + onHmdHandMouseActiveChanged: { + if (desktop.hmdHandMouseActive) { + if (window.activator.containsMouse) { + root.inflateDecorations(); + } + } else { + root.deflateDecorations(); + } + } + } } diff --git a/interface/resources/qml/windows/DefaultFrameDecoration.qml b/interface/resources/qml/windows/DefaultFrameDecoration.qml index ecb1760717..ce47b818b1 100644 --- a/interface/resources/qml/windows/DefaultFrameDecoration.qml +++ b/interface/resources/qml/windows/DefaultFrameDecoration.qml @@ -14,7 +14,6 @@ import QtGraphicalEffects 1.0 import "." import "../styles-uit" - Decoration { HifiConstants { id: hifi } @@ -28,23 +27,22 @@ Decoration { frameMarginTop: 2 * frameMargin + iconSize frameMarginBottom: iconSize + 11 - Connections { - target: window - onMouseEntered: { - if (!HMD.active) { - return; - } - root.frameMargin = 18 - titleText.size = hifi.fontSizes.overlayTitle * 2 - root.iconSize = hifi.dimensions.frameIconSize * 2 - } - onMouseExited: { - root.frameMargin = 9 - titleText.size = hifi.fontSizes.overlayTitle - root.iconSize = hifi.dimensions.frameIconSize + onInflateDecorations: { + if (!HMD.active) { + return; } + root.frameMargin = 18 + titleText.size = hifi.fontSizes.overlayTitle * 2 + root.iconSize = hifi.dimensions.frameIconSize * 2 } + onDeflateDecorations: { + root.frameMargin = 9 + titleText.size = hifi.fontSizes.overlayTitle + root.iconSize = hifi.dimensions.frameIconSize + } + + Row { id: controlsRow anchors { diff --git a/interface/resources/qml/windows/ToolFrameDecoration.qml b/interface/resources/qml/windows/ToolFrameDecoration.qml index a7068183c1..ba36a2a38c 100644 --- a/interface/resources/qml/windows/ToolFrameDecoration.qml +++ b/interface/resources/qml/windows/ToolFrameDecoration.qml @@ -32,23 +32,21 @@ Decoration { frameMarginBottom: frameMargin + (verticalSpacers ? spacerMargin : 0) radius: hifi.dimensions.borderRadius / 2 - Connections { - target: window - onMouseEntered: { - if (!HMD.active) { - return; - } - root.frameMargin = 18 - root.spacerWidth = 16 - root.spacerRadius = 8 - root.spacerMargin = 8 - } - onMouseExited: { - root.frameMargin = 6 - root.spacerWidth = 8 - root.spacerRadius = 4 - root.spacerMargin = 12 + onInflateDecorations: { + if (!HMD.active) { + return; } + root.frameMargin = 18 + root.spacerWidth = 16 + root.spacerRadius = 8 + root.spacerMargin = 8 + } + + onDeflateDecorations: { + root.frameMargin = 6 + root.spacerWidth = 8 + root.spacerRadius = 4 + root.spacerMargin = 12 } Rectangle { diff --git a/interface/src/scripting/HMDScriptingInterface.cpp b/interface/src/scripting/HMDScriptingInterface.cpp index e9677cc3c8..36cde378f8 100644 --- a/interface/src/scripting/HMDScriptingInterface.cpp +++ b/interface/src/scripting/HMDScriptingInterface.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include "Application.h" @@ -110,13 +111,17 @@ QString HMDScriptingInterface::preferredAudioOutput() const { } bool HMDScriptingInterface::setHandLasers(int hands, bool enabled, const glm::vec4& color, const glm::vec3& direction) const { + auto offscreenUi = DependencyManager::get(); + offscreenUi->executeOnUiThread([offscreenUi, enabled] { + offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled); + }); return qApp->getActiveDisplayPlugin()->setHandLaser(hands, enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None, color, direction); } void HMDScriptingInterface::disableHandLasers(int hands) const { - qApp->getActiveDisplayPlugin()->setHandLaser(hands, DisplayPlugin::HandLaserMode::None); + setHandLasers(hands, false, vec4(0), vec3(0)); } bool HMDScriptingInterface::suppressKeyboard() { diff --git a/tests/ui/qml/main.qml b/tests/ui/qml/main.qml index a23a1e3ade..8ca9399b74 100644 --- a/tests/ui/qml/main.qml +++ b/tests/ui/qml/main.qml @@ -33,6 +33,11 @@ ApplicationWindow { onClicked: HMD.active = !HMD.active } + Button { + text: desktop.hmdHandMouseActive ? "Disable HMD HandMouse" : "Enable HMD HandMouse" + onClicked: desktop.hmdHandMouseActive = !desktop.hmdHandMouseActive + } + // Window visibility Button { text: "toggle desktop"