From 0def39dbaac3debd75877a65f3ff4a6ba7c8f324 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 26 Feb 2019 18:14:56 -0800 Subject: [PATCH 01/60] adding user speaking level rotated vertically and muted symbol --- interface/resources/qml/hifi/audio/MicBar.qml | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index f51da9c381..51ddfb7f3e 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -13,13 +13,14 @@ import QtQuick 2.5 import QtGraphicalEffects 1.0 import stylesUit 1.0 +import stylesUit 1.0 import TabletScriptingInterface 1.0 Rectangle { HifiConstants { id: hifi; } readonly property var level: AudioScriptingInterface.inputLevel; - + readonly property var userSpeakingLevel: 0.4; property bool gated: false; Component.onCompleted: { AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; }); @@ -29,8 +30,8 @@ Rectangle { property bool standalone: false; property var dragTarget: null; - width: 240; - height: 50; + width: 44; + height: 44; radius: 5; @@ -43,8 +44,8 @@ Rectangle { // borders are painted over fill, so reduce the fill to fit inside the border Rectangle { color: standalone ? colors.fill : "#00000000"; - width: 236; - height: 46; + width: 40; + height: 40; radius: 5; @@ -101,7 +102,6 @@ Rectangle { anchors { left: parent.left; - leftMargin: 5; verticalCenter: parent.verticalCenter; } @@ -117,11 +117,11 @@ Rectangle { id: image; source: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? pushToTalkIcon : AudioScriptingInterface.muted ? mutedIcon : unmutedIcon; - width: 30; - height: 30; + width: 21; + height: 24; anchors { left: parent.left; - leftMargin: 5; + leftMargin: 7; top: parent.top; topMargin: 5; } @@ -138,20 +138,20 @@ Rectangle { Item { id: status; - readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted; + readonly property string color: colors.muted; - visible: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) || AudioScriptingInterface.muted; + visible: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) || (AudioScriptingInterface.muted && (level >= userSpeakingLevel)); anchors { left: parent.left; - leftMargin: 50; - verticalCenter: parent.verticalCenter; + top: parent.bottom + topMargin: 5 } - width: 170; + width: icon.width; height: 8 - Text { + RalewaySemiBold { anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter; @@ -189,11 +189,14 @@ Rectangle { Item { id: bar; - visible: !status.visible; + anchors { + right: parent.right; + rightMargin: 7; + verticalCenter: parent.verticalCenter; + } - anchors.fill: status; - - width: status.width; + width: 8; + height: 32; Rectangle { // base radius: 4; @@ -203,13 +206,12 @@ Rectangle { Rectangle { // mask id: mask; - width: gated ? 0 : parent.width * level; + height: parent.height * level; + width: parent.width; radius: 5; anchors { bottom: parent.bottom; bottomMargin: 0; - top: parent.top; - topMargin: 0; left: parent.left; leftMargin: 0; } @@ -219,10 +221,11 @@ Rectangle { anchors { fill: mask } source: mask start: Qt.point(0, 0); - end: Qt.point(170, 0); + end: Qt.point(0, bar.height); + rotation: 180 gradient: Gradient { GradientStop { - position: 0; + position: 0.0; color: colors.greenStart; } GradientStop { @@ -230,8 +233,8 @@ Rectangle { color: colors.greenEnd; } GradientStop { - position: 1; - color: colors.yellow; + position: 1.0; + color: colors.red; } } } From 1ba366c0d7074bec21df042f743b941f0dfbcd55 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 26 Feb 2019 18:19:23 -0800 Subject: [PATCH 02/60] moving file as MicBarApplication --- interface/resources/qml/hifi/audio/MicBar.qml | 67 +++-- .../qml/hifi/audio/MicBarApplication.qml | 241 ++++++++++++++++++ 2 files changed, 273 insertions(+), 35 deletions(-) create mode 100644 interface/resources/qml/hifi/audio/MicBarApplication.qml diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index 51ddfb7f3e..7ed9451a04 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -13,25 +13,24 @@ import QtQuick 2.5 import QtGraphicalEffects 1.0 import stylesUit 1.0 -import stylesUit 1.0 import TabletScriptingInterface 1.0 Rectangle { HifiConstants { id: hifi; } readonly property var level: AudioScriptingInterface.inputLevel; - readonly property var userSpeakingLevel: 0.4; + property bool gated: false; Component.onCompleted: { AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; }); AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; }); } - + property bool standalone: false; property var dragTarget: null; - width: 44; - height: 44; + width: 240; + height: 50; radius: 5; @@ -44,8 +43,8 @@ Rectangle { // borders are painted over fill, so reduce the fill to fit inside the border Rectangle { color: standalone ? colors.fill : "#00000000"; - width: 40; - height: 40; + width: 236; + height: 46; radius: 5; @@ -102,6 +101,7 @@ Rectangle { anchors { left: parent.left; + leftMargin: 5; verticalCenter: parent.verticalCenter; } @@ -117,11 +117,11 @@ Rectangle { id: image; source: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? pushToTalkIcon : AudioScriptingInterface.muted ? mutedIcon : unmutedIcon; - width: 21; - height: 24; + width: 30; + height: 30; anchors { left: parent.left; - leftMargin: 7; + leftMargin: 5; top: parent.top; topMargin: 5; } @@ -138,20 +138,20 @@ Rectangle { Item { id: status; - readonly property string color: colors.muted; + readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted; visible: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) || (AudioScriptingInterface.muted && (level >= userSpeakingLevel)); anchors { left: parent.left; - top: parent.bottom - topMargin: 5 + leftMargin: 50; + verticalCenter: parent.verticalCenter; } - width: icon.width; + width: 170; height: 8 - RalewaySemiBold { + Text { anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter; @@ -189,14 +189,11 @@ Rectangle { Item { id: bar; - anchors { - right: parent.right; - rightMargin: 7; - verticalCenter: parent.verticalCenter; - } + visible: !status.visible; - width: 8; - height: 32; + anchors.fill: status; + + width: status.width; Rectangle { // base radius: 4; @@ -206,12 +203,13 @@ Rectangle { Rectangle { // mask id: mask; - height: parent.height * level; - width: parent.width; + width: gated ? 0 : parent.width * level; radius: 5; anchors { bottom: parent.bottom; bottomMargin: 0; + top: parent.top; + topMargin: 0; left: parent.left; leftMargin: 0; } @@ -221,11 +219,10 @@ Rectangle { anchors { fill: mask } source: mask start: Qt.point(0, 0); - end: Qt.point(0, bar.height); - rotation: 180 + end: Qt.point(170, 0); gradient: Gradient { GradientStop { - position: 0.0; + position: 0; color: colors.greenStart; } GradientStop { @@ -233,17 +230,17 @@ Rectangle { color: colors.greenEnd; } GradientStop { - position: 1.0; - color: colors.red; + position: 1; + color: colors.yellow; } } } - + Rectangle { id: gatedIndicator; visible: gated && !AudioScriptingInterface.clipping - - radius: 4; + + radius: 4; width: 2 * radius; height: 2 * radius; color: "#0080FF"; @@ -252,12 +249,12 @@ Rectangle { verticalCenter: parent.verticalCenter; } } - + Rectangle { id: clippingIndicator; visible: AudioScriptingInterface.clipping - - radius: 4; + + radius: 4; width: 2 * radius; height: 2 * radius; color: colors.red; diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml new file mode 100644 index 0000000000..33824a3d86 --- /dev/null +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -0,0 +1,241 @@ +// +// MicBar.qml +// qml/hifi/audio +// +// Created by Zach Pomerantz on 6/14/2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtGraphicalEffects 1.0 + +import stylesUit 1.0 +import TabletScriptingInterface 1.0 + +Rectangle { + readonly property var level: AudioScriptingInterface.inputLevel; + readonly property var userSpeakingLevel: 0.4; + property bool gated: false; + Component.onCompleted: { + AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; }); + AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; }); + } + + property bool standalone: false; + property var dragTarget: null; + + width: 44; + height: 44; + + radius: 5; + + color: "#00000000"; + border { + width: mouseArea.containsMouse || mouseArea.containsPress ? 2 : 0; + color: colors.border; + } + + // borders are painted over fill, so reduce the fill to fit inside the border + Rectangle { + color: standalone ? colors.fill : "#00000000"; + width: 40; + height: 40; + + radius: 5; + + anchors { + verticalCenter: parent.verticalCenter; + horizontalCenter: parent.horizontalCenter; + } + } + + MouseArea { + id: mouseArea; + + anchors { + left: icon.left; + right: bar.right; + top: icon.top; + bottom: icon.bottom; + } + + hoverEnabled: true; + scrollGestureEnabled: false; + onClicked: { + AudioScriptingInterface.muted = !AudioScriptingInterface.muted; + Tablet.playSound(TabletEnums.ButtonClick); + } + drag.target: dragTarget; + onContainsMouseChanged: { + if (containsMouse) { + Tablet.playSound(TabletEnums.ButtonHover); + } + } + } + + QtObject { + id: colors; + + readonly property string unmuted: "#FFF"; + readonly property string muted: "#E2334D"; + readonly property string gutter: "#575757"; + readonly property string greenStart: "#39A38F"; + readonly property string greenEnd: "#1FC6A6"; + readonly property string yellow: "#C0C000"; + readonly property string red: colors.muted; + readonly property string fill: "#55000000"; + readonly property string border: standalone ? "#80FFFFFF" : "#55FFFFFF"; + readonly property string icon: AudioScriptingInterface.muted ? muted : unmuted; + } + + Item { + id: icon; + + anchors { + left: parent.left; + verticalCenter: parent.verticalCenter; + } + + width: 40; + height: 40; + + Item { + Image { + readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; + readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg"; + + id: image; + source: AudioScriptingInterface.muted ? mutedIcon : unmutedIcon; + + width: 21; + height: 24; + anchors { + left: parent.left; + leftMargin: 7; + top: parent.top; + topMargin: 5; + } + } + + ColorOverlay { + anchors { fill: image } + source: image; + color: colors.icon; + } + } + } + + Item { + id: status; + + readonly property string color: colors.muted; + + visible: AudioScriptingInterface.muted && (level >= userSpeakingLevel); + + anchors { + left: parent.left; + top: parent.bottom + topMargin: 5 + } + + width: icon.width; + height: 8 + + RalewaySemiBold { + anchors { + horizontalCenter: parent.horizontalCenter; + verticalCenter: parent.verticalCenter; + } + + color: parent.color; + + text: "MUTED"; + size: 12; + } + } + + Item { + id: bar; + + anchors { + right: parent.right; + rightMargin: 7; + verticalCenter: parent.verticalCenter; + } + + width: 8; + height: 32; + + Rectangle { // base + radius: 4; + anchors { fill: parent } + color: colors.gutter; + } + + Rectangle { // mask + id: mask; + height: parent.height * level; + width: parent.width; + radius: 5; + anchors { + bottom: parent.bottom; + bottomMargin: 0; + left: parent.left; + leftMargin: 0; + } + } + + LinearGradient { + anchors { fill: mask } + source: mask + start: Qt.point(0, 0); + end: Qt.point(0, bar.height); + rotation: 180 + gradient: Gradient { + GradientStop { + position: 0.0; + color: colors.greenStart; + } + GradientStop { + position: 0.5; + color: colors.greenEnd; + } + GradientStop { + position: 1.0; + color: colors.red; + } + } + } + + Rectangle { + id: gatedIndicator; + visible: gated && !AudioScriptingInterface.clipping + + radius: 4; + width: 2 * radius; + height: 2 * radius; + color: "#0080FF"; + anchors { + right: parent.left; + verticalCenter: parent.verticalCenter; + } + } + + Rectangle { + id: clippingIndicator; + visible: AudioScriptingInterface.clipping + + radius: 4; + width: 2 * radius; + height: 2 * radius; + color: colors.red; + anchors { + left: parent.right; + verticalCenter: parent.verticalCenter; + } + } + } +} From 915d22bb15328ae7ddb3563b654c3a4ede6db043 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 27 Feb 2019 10:38:26 -0800 Subject: [PATCH 03/60] adding bubble icon (not working) --- interface/resources/qml/AvatarInputsBar.qml | 24 +++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/AvatarInputsBar.qml b/interface/resources/qml/AvatarInputsBar.qml index 4a071d2d04..b17dfdcd65 100644 --- a/interface/resources/qml/AvatarInputsBar.qml +++ b/interface/resources/qml/AvatarInputsBar.qml @@ -8,6 +8,7 @@ import Hifi 1.0 as Hifi import QtQuick 2.4 +import QtGraphicalEffects 1.0 import "./hifi/audio" as HifiAudio @@ -21,10 +22,29 @@ Item { readonly property bool shouldReposition: true; - HifiAudio.MicBar { + HifiAudio.MicBarApplication { id: audio; visible: AvatarInputs.showAudioTools; standalone: true; - dragTarget: parent; + dragTarget: parent; + } + Image { + id: bubbleIcon + source: "../icons/tablet-icons/bubble-i.svg"; + width: 28; + height: 28; + anchors { + left: root.right + top: root.top + topMargin: (root.height - bubbleIcon.height) / 2 + } + } + ColorOverlay { + anchors.fill: bubbleIcon + source: bubbleIcon + color: Users.getIgnoreRadiusEnabled() ? Qt.rgba(31, 198, 166, 0.3) : Qt.rgba(255, 255, 255, 0.3); + onColorChanged: { + console.log("colorChanged") + } } } From 3ceb1598f614b18eb412c6962b459b79e8fcf376 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 27 Feb 2019 14:54:13 -0800 Subject: [PATCH 04/60] adding working bubble icon --- interface/resources/qml/AvatarInputsBar.qml | 9 ++++----- interface/src/ui/AvatarInputs.cpp | 6 ++++++ interface/src/ui/AvatarInputs.h | 11 ++++++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/AvatarInputsBar.qml b/interface/resources/qml/AvatarInputsBar.qml index b17dfdcd65..6375211a93 100644 --- a/interface/resources/qml/AvatarInputsBar.qml +++ b/interface/resources/qml/AvatarInputsBar.qml @@ -16,10 +16,10 @@ Item { id: root; objectName: "AvatarInputsBar" property int modality: Qt.NonModal + readonly property bool ignoreRadiusEnabled: AvatarInputs.ignoreRadiusEnabled width: audio.width; height: audio.height; x: 10; y: 5; - readonly property bool shouldReposition: true; HifiAudio.MicBarApplication { @@ -40,11 +40,10 @@ Item { } } ColorOverlay { + id: bubbleIconOverlay anchors.fill: bubbleIcon source: bubbleIcon - color: Users.getIgnoreRadiusEnabled() ? Qt.rgba(31, 198, 166, 0.3) : Qt.rgba(255, 255, 255, 0.3); - onColorChanged: { - console.log("colorChanged") - } + color: AvatarInputs.ignoreRadiusEnabled ? "#1FC6A6" : "#FFFFFF"; + opacity: 0.7 } } diff --git a/interface/src/ui/AvatarInputs.cpp b/interface/src/ui/AvatarInputs.cpp index 0aa352de23..6d43507a3e 100644 --- a/interface/src/ui/AvatarInputs.cpp +++ b/interface/src/ui/AvatarInputs.cpp @@ -30,6 +30,8 @@ AvatarInputs* AvatarInputs::getInstance() { AvatarInputs::AvatarInputs(QObject* parent) : QObject(parent) { _showAudioTools = showAudioToolsSetting.get(); + auto nodeList = DependencyManager::get(); + connect(nodeList.data(), &NodeList::ignoreRadiusEnabledChanged, this, &AvatarInputs::ignoreRadiusEnabledChanged); } #define AI_UPDATE(name, src) \ @@ -83,6 +85,10 @@ void AvatarInputs::setShowAudioTools(bool showAudioTools) { emit showAudioToolsChanged(_showAudioTools); } +bool AvatarInputs::getIgnoreRadiusEnabled() const { + return DependencyManager::get()->getIgnoreRadiusEnabled(); +} + void AvatarInputs::toggleCameraMute() { FaceTracker* faceTracker = qApp->getSelectedFaceTracker(); if (faceTracker) { diff --git a/interface/src/ui/AvatarInputs.h b/interface/src/ui/AvatarInputs.h index 6569792807..a41fd0485f 100644 --- a/interface/src/ui/AvatarInputs.h +++ b/interface/src/ui/AvatarInputs.h @@ -42,6 +42,7 @@ class AvatarInputs : public QObject { AI_PROPERTY(bool, isHMD, false) Q_PROPERTY(bool showAudioTools READ showAudioTools WRITE setShowAudioTools NOTIFY showAudioToolsChanged) + Q_PROPERTY(bool ignoreRadiusEnabled READ getIgnoreRadiusEnabled NOTIFY ignoreRadiusEnabledChanged) public: static AvatarInputs* getInstance(); @@ -55,7 +56,8 @@ public: AvatarInputs(QObject* parent = nullptr); void update(); - bool showAudioTools() const { return _showAudioTools; } + bool showAudioTools() const { return _showAudioTools; } + bool getIgnoreRadiusEnabled() const; public slots: @@ -93,6 +95,13 @@ signals: */ void showAudioToolsChanged(bool show); + /**jsdoc + * @function AvatarInputs.ignoreRadiusEnabledChanged + * @param {boolean} enabled + * @returns {Signal} + */ + void ignoreRadiusEnabledChanged(bool enabled); + protected: /**jsdoc From ddacc0ee60fc7169eeac98e83725b28c2b6dffdd Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 27 Feb 2019 14:56:21 -0800 Subject: [PATCH 05/60] bubble icon opacity to 0.3 --- interface/resources/qml/AvatarInputsBar.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/AvatarInputsBar.qml b/interface/resources/qml/AvatarInputsBar.qml index 6375211a93..d539d7ea9e 100644 --- a/interface/resources/qml/AvatarInputsBar.qml +++ b/interface/resources/qml/AvatarInputsBar.qml @@ -44,6 +44,6 @@ Item { anchors.fill: bubbleIcon source: bubbleIcon color: AvatarInputs.ignoreRadiusEnabled ? "#1FC6A6" : "#FFFFFF"; - opacity: 0.7 + opacity: 0.3 } } From e129201d2a04e2af0782d6f0b7b4e514805cbd0b Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 27 Feb 2019 17:38:11 -0800 Subject: [PATCH 06/60] adding more opacity, cleanup --- interface/resources/qml/AvatarInputsBar.qml | 69 +++++++++++++++---- .../qml/hifi/audio/MicBarApplication.qml | 10 +++ 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/interface/resources/qml/AvatarInputsBar.qml b/interface/resources/qml/AvatarInputsBar.qml index d539d7ea9e..615e260833 100644 --- a/interface/resources/qml/AvatarInputsBar.qml +++ b/interface/resources/qml/AvatarInputsBar.qml @@ -7,11 +7,13 @@ // import Hifi 1.0 as Hifi -import QtQuick 2.4 +import QtQuick 2.5 import QtGraphicalEffects 1.0 import "./hifi/audio" as HifiAudio +import TabletScriptingInterface 1.0 + Item { id: root; objectName: "AvatarInputsBar" @@ -19,7 +21,8 @@ Item { readonly property bool ignoreRadiusEnabled: AvatarInputs.ignoreRadiusEnabled width: audio.width; height: audio.height; - x: 10; y: 5; + x: 10; + y: 5; readonly property bool shouldReposition: true; HifiAudio.MicBarApplication { @@ -28,22 +31,58 @@ Item { standalone: true; dragTarget: parent; } - Image { - id: bubbleIcon - source: "../icons/tablet-icons/bubble-i.svg"; - width: 28; - height: 28; + Rectangle { + id: bubbleRect + width: bubbleIcon.width + 10 + height: parent.height + radius: 5; + opacity: 0.5; + + color: "#00000000"; + border { + width: mouseArea.containsMouse || mouseArea.containsPress ? 2 : 0; + color: "#80FFFFFF"; + } anchors { left: root.right top: root.top - topMargin: (root.height - bubbleIcon.height) / 2 + } + + MouseArea { + id: mouseArea; + anchors.fill: parent + + hoverEnabled: true; + scrollGestureEnabled: false; + onClicked: { + Tablet.playSound(TabletEnums.ButtonClick); + } + drag.target: root; + onContainsMouseChanged: { + if (containsMouse) { + Tablet.playSound(TabletEnums.ButtonHover); + bubbleRect.opacity = 0.7; + } else { + bubbleRect.opacity = 0.5; + } + } + } + Image { + id: bubbleIcon + source: "../icons/tablet-icons/bubble-i.svg"; + sourceSize: Qt.size(28, 28); + smooth: true; + visible: false + anchors.top: parent.top + anchors.topMargin: (parent.height - bubbleIcon.height) / 2 + anchors.left: parent.left + anchors.leftMargin: (parent.width - bubbleIcon.width) / 2 + } + ColorOverlay { + id: bubbleIconOverlay + anchors.fill: bubbleIcon + source: bubbleIcon + color: AvatarInputs.ignoreRadiusEnabled ? "#1FC6A6" : "#FFFFFF"; } } - ColorOverlay { - id: bubbleIconOverlay - anchors.fill: bubbleIcon - source: bubbleIcon - color: AvatarInputs.ignoreRadiusEnabled ? "#1FC6A6" : "#FFFFFF"; - opacity: 0.3 - } } diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 33824a3d86..ba6aeef7d8 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -32,6 +32,14 @@ Rectangle { radius: 5; + onLevelChanged: { + var rectOpacity = AudioScriptingInterface.muted && (level >= userSpeakingLevel)? 0.9 : 0.3; + if (mouseArea.containsMouse) { + rectOpacity = 0.5; + } + opacity = rectOpacity; + } + color: "#00000000"; border { width: mouseArea.containsMouse || mouseArea.containsPress ? 2 : 0; @@ -121,6 +129,7 @@ Rectangle { } ColorOverlay { + id: imageOverlay anchors { fill: image } source: image; color: colors.icon; @@ -170,6 +179,7 @@ Rectangle { height: 32; Rectangle { // base + id: baseBar radius: 4; anchors { fill: parent } color: colors.gutter; From 3be44e0a8ea30fc2500c2d3306e1487a4625e82f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 27 Feb 2019 18:04:09 -0800 Subject: [PATCH 07/60] adding privacy shield files --- interface/src/ui/PrivacyShield.cpp | 12 ++++++++++++ interface/src/ui/PrivacyShield.h | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 interface/src/ui/PrivacyShield.cpp create mode 100644 interface/src/ui/PrivacyShield.h diff --git a/interface/src/ui/PrivacyShield.cpp b/interface/src/ui/PrivacyShield.cpp new file mode 100644 index 0000000000..e1035ee5bb --- /dev/null +++ b/interface/src/ui/PrivacyShield.cpp @@ -0,0 +1,12 @@ +// +// PrivacyShield.h +// interface/src/ui +// +// Created by Wayne Chen on 2/27/19. +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "PrivacyShield.cpp" diff --git a/interface/src/ui/PrivacyShield.h b/interface/src/ui/PrivacyShield.h new file mode 100644 index 0000000000..a609f2775b --- /dev/null +++ b/interface/src/ui/PrivacyShield.h @@ -0,0 +1,12 @@ +// +// PrivacyShield.h +// interface/src/ui +// +// Created by Wayne Chen on 2/27/19. +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#pragma once From e1d03a23395d5f640b20f5544399305b34708bec Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 27 Feb 2019 18:04:58 -0800 Subject: [PATCH 08/60] fixing typos --- interface/src/ui/PrivacyShield.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/PrivacyShield.cpp b/interface/src/ui/PrivacyShield.cpp index e1035ee5bb..12687afbea 100644 --- a/interface/src/ui/PrivacyShield.cpp +++ b/interface/src/ui/PrivacyShield.cpp @@ -1,5 +1,5 @@ // -// PrivacyShield.h +// PrivacyShield.cpp // interface/src/ui // // Created by Wayne Chen on 2/27/19. @@ -9,4 +9,4 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "PrivacyShield.cpp" +#include "PrivacyShield.h" From 835153c0dfb7caef7912715589bafea88313d7d4 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Feb 2019 15:50:13 -0800 Subject: [PATCH 09/60] don't display gated state --- .../qml/hifi/audio/MicBarApplication.qml | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index ba6aeef7d8..451f410e1d 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -17,6 +17,8 @@ import TabletScriptingInterface 1.0 Rectangle { readonly property var level: AudioScriptingInterface.inputLevel; + readonly property var clipping: AudioScriptingInterface.clipping; + readonly property var muted: AudioScriptingInterface.muted; readonly property var userSpeakingLevel: 0.4; property bool gated: false; Component.onCompleted: { @@ -24,6 +26,9 @@ Rectangle { AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; }); } + readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; + readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg"; + readonly property string clippingIcon: "../../../icons/tablet-icons/mic-clip-i.svg"; property bool standalone: false; property var dragTarget: null; @@ -33,8 +38,8 @@ Rectangle { radius: 5; onLevelChanged: { - var rectOpacity = AudioScriptingInterface.muted && (level >= userSpeakingLevel)? 0.9 : 0.3; - if (mouseArea.containsMouse) { + var rectOpacity = muted && (level >= userSpeakingLevel) ? 0.9 : 0.3; + if (mouseArea.containsMouse && rectOpacity != 0.9) { rectOpacity = 0.5; } opacity = rectOpacity; @@ -87,8 +92,8 @@ Rectangle { QtObject { id: colors; - readonly property string unmuted: "#FFF"; - readonly property string muted: "#E2334D"; + readonly property string unmutedColor: "#FFF"; + readonly property string mutedColor: "#E2334D"; readonly property string gutter: "#575757"; readonly property string greenStart: "#39A38F"; readonly property string greenEnd: "#1FC6A6"; @@ -96,7 +101,7 @@ Rectangle { readonly property string red: colors.muted; readonly property string fill: "#55000000"; readonly property string border: standalone ? "#80FFFFFF" : "#55FFFFFF"; - readonly property string icon: AudioScriptingInterface.muted ? muted : unmuted; + readonly property string icon: muted ? mutedColor : unmutedColor; } Item { @@ -112,14 +117,11 @@ Rectangle { Item { Image { - readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; - readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg"; - id: image; - source: AudioScriptingInterface.muted ? mutedIcon : unmutedIcon; + source: muted ? mutedIcon : clipping ? clippingIcon : unmutedIcon; - width: 21; - height: 24; + width: 29; + height: 32; anchors { left: parent.left; leftMargin: 7; @@ -142,7 +144,8 @@ Rectangle { readonly property string color: colors.muted; - visible: AudioScriptingInterface.muted && (level >= userSpeakingLevel); + visible: muted && (level >= userSpeakingLevel); + opacity: 0.9 anchors { left: parent.left; @@ -215,14 +218,14 @@ Rectangle { } GradientStop { position: 1.0; - color: colors.red; + color: colors.yellow; } } } - +/* Rectangle { id: gatedIndicator; - visible: gated && !AudioScriptingInterface.clipping + visible: gated && !clipping radius: 4; width: 2 * radius; @@ -236,7 +239,7 @@ Rectangle { Rectangle { id: clippingIndicator; - visible: AudioScriptingInterface.clipping + visible: clipping radius: 4; width: 2 * radius; @@ -247,5 +250,6 @@ Rectangle { verticalCenter: parent.verticalCenter; } } +*/ } } From 26895e6f5d1a7dc37a9fa07b1d6be444c9ebfd80 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Feb 2019 15:53:24 -0800 Subject: [PATCH 10/60] don't display gated state --- interface/resources/icons/tablet-icons/mic-clip-i.svg | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 interface/resources/icons/tablet-icons/mic-clip-i.svg diff --git a/interface/resources/icons/tablet-icons/mic-clip-i.svg b/interface/resources/icons/tablet-icons/mic-clip-i.svg new file mode 100644 index 0000000000..d6f36427a9 --- /dev/null +++ b/interface/resources/icons/tablet-icons/mic-clip-i.svg @@ -0,0 +1,3 @@ + + + From 087f613d60d242602737a2f1872c04badd70d1a3 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Feb 2019 16:48:17 -0800 Subject: [PATCH 11/60] fixing muted text --- .../icons/tablet-icons/mic-clip-i.svg | 9 ++- .../resources/icons/tablet-icons/mic-mute.svg | 60 ------------------- .../icons/tablet-icons/mic-unmute-i.svg | 23 +------ .../qml/hifi/audio/MicBarApplication.qml | 6 +- 4 files changed, 11 insertions(+), 87 deletions(-) delete mode 100644 interface/resources/icons/tablet-icons/mic-mute.svg diff --git a/interface/resources/icons/tablet-icons/mic-clip-i.svg b/interface/resources/icons/tablet-icons/mic-clip-i.svg index d6f36427a9..8bc1b2b558 100644 --- a/interface/resources/icons/tablet-icons/mic-clip-i.svg +++ b/interface/resources/icons/tablet-icons/mic-clip-i.svg @@ -1,3 +1,10 @@ - + + + + + + + + diff --git a/interface/resources/icons/tablet-icons/mic-mute.svg b/interface/resources/icons/tablet-icons/mic-mute.svg deleted file mode 100644 index bd42fded05..0000000000 --- a/interface/resources/icons/tablet-icons/mic-mute.svg +++ /dev/null @@ -1,60 +0,0 @@ - - - -image/svg+xml \ No newline at end of file diff --git a/interface/resources/icons/tablet-icons/mic-unmute-i.svg b/interface/resources/icons/tablet-icons/mic-unmute-i.svg index c4eda55cbc..f577a65bc2 100644 --- a/interface/resources/icons/tablet-icons/mic-unmute-i.svg +++ b/interface/resources/icons/tablet-icons/mic-unmute-i.svg @@ -1,22 +1,3 @@ - - - - - - - - - - - - - + + diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 451f410e1d..2bf49aa83b 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -124,7 +124,6 @@ Rectangle { height: 32; anchors { left: parent.left; - leftMargin: 7; top: parent.top; topMargin: 5; } @@ -142,10 +141,7 @@ Rectangle { Item { id: status; - readonly property string color: colors.muted; - visible: muted && (level >= userSpeakingLevel); - opacity: 0.9 anchors { left: parent.left; @@ -162,7 +158,7 @@ Rectangle { verticalCenter: parent.verticalCenter; } - color: parent.color; + color: colors.mutedColor; text: "MUTED"; size: 12; From d382893e754cee57b27d1fe32b2d6c69e91b6dc2 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Feb 2019 16:51:19 -0800 Subject: [PATCH 12/60] staging avatar inputs for ignore radius --- interface/src/Application.cpp | 10 ++ interface/src/avatar/AvatarManager.cpp | 2 + interface/src/ui/AvatarInputs.cpp | 3 + interface/src/ui/AvatarInputs.h | 25 +++ interface/src/ui/PrivacyShield.cpp | 147 ++++++++++++++++++ interface/src/ui/PrivacyShield.h | 35 +++++ libraries/avatars/src/AvatarData.h | 1 + .../UserActivityLoggerScriptingInterface.cpp | 8 +- .../UserActivityLoggerScriptingInterface.h | 4 +- scripts/system/bubble.js | 6 +- 10 files changed, 232 insertions(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 635932ea1c..e34ae4bcba 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -211,6 +211,7 @@ #include "ui/UpdateDialog.h" #include "ui/DomainConnectionModel.h" #include "ui/Keyboard.h" +#include "ui/PrivacyShield.h" #include "Util.h" #include "InterfaceParentFinder.h" #include "ui/OctreeStatsProvider.h" @@ -927,6 +928,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); + DependencyManager::set(); return previousSessionCrashed; } @@ -2650,6 +2652,9 @@ void Application::cleanupBeforeQuit() { nodeList->getPacketReceiver().setShouldDropPackets(true); } + // destroy privacy shield before entity shutdown. + DependencyManager::get()->destroyPrivacyShield(); + getEntities()->shutdown(); // tell the entities system we're shutting down, so it will stop running scripts // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) @@ -2728,6 +2733,7 @@ void Application::cleanupBeforeQuit() { DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); + DependencyManager::destroy(); DependencyManager::destroy(); qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete"; @@ -5528,6 +5534,8 @@ void Application::resumeAfterLoginDialogActionTaken() { menu->getMenu("Developer")->setVisible(_developerMenuVisible); _myCamera.setMode(_previousCameraMode); cameraModeChanged(); + + DependencyManager::get()->createPrivacyShield(); } void Application::loadAvatarScripts(const QVector& urls) { @@ -6486,6 +6494,8 @@ void Application::update(float deltaTime) { updateLoginDialogPosition(); } + DependencyManager::get()->update(deltaTime); + { PROFILE_RANGE_EX(app, "Overlays", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); PerformanceTimer perfTimer("overlays"); diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 69f7054953..76612039db 100755 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include "Application.h" #include "InterfaceLogging.h" @@ -536,6 +537,7 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar avatar->removeAvatarEntitiesFromTree(); if (removalReason == KillAvatarReason::TheirAvatarEnteredYourBubble) { + emit AvatarInputs::getInstance()->avatarEnteredIgnoreRadius(avatar->getSessionUUID()); emit DependencyManager::get()->enteredIgnoreRadius(); } else if (removalReason == KillAvatarReason::AvatarDisconnected) { // remove from node sets, if present diff --git a/interface/src/ui/AvatarInputs.cpp b/interface/src/ui/AvatarInputs.cpp index 6d43507a3e..80604f354b 100644 --- a/interface/src/ui/AvatarInputs.cpp +++ b/interface/src/ui/AvatarInputs.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "Application.h" #include "Menu.h" @@ -31,7 +32,9 @@ AvatarInputs* AvatarInputs::getInstance() { AvatarInputs::AvatarInputs(QObject* parent) : QObject(parent) { _showAudioTools = showAudioToolsSetting.get(); auto nodeList = DependencyManager::get(); + auto usersScriptingInterface = DependencyManager::get(); connect(nodeList.data(), &NodeList::ignoreRadiusEnabledChanged, this, &AvatarInputs::ignoreRadiusEnabledChanged); + connect(usersScriptingInterface.data(), &UsersScriptingInterface::enteredIgnoreRadius, this, &AvatarInputs::enteredIgnoreRadiusChanged); } #define AI_UPDATE(name, src) \ diff --git a/interface/src/ui/AvatarInputs.h b/interface/src/ui/AvatarInputs.h index a41fd0485f..f53adc1749 100644 --- a/interface/src/ui/AvatarInputs.h +++ b/interface/src/ui/AvatarInputs.h @@ -43,6 +43,7 @@ class AvatarInputs : public QObject { Q_PROPERTY(bool showAudioTools READ showAudioTools WRITE setShowAudioTools NOTIFY showAudioToolsChanged) Q_PROPERTY(bool ignoreRadiusEnabled READ getIgnoreRadiusEnabled NOTIFY ignoreRadiusEnabledChanged) + //Q_PROPERTY(bool enteredIgnoreRadius READ getEnteredIgnoreRadius NOTIFY enteredIgnoreRadiusChanged) public: static AvatarInputs* getInstance(); @@ -58,6 +59,7 @@ public: void update(); bool showAudioTools() const { return _showAudioTools; } bool getIgnoreRadiusEnabled() const; + //bool getEnteredIgnoreRadius() const; public slots: @@ -95,6 +97,20 @@ signals: */ void showAudioToolsChanged(bool show); + /**jsdoc + * @function AvatarInputs.avatarEnteredIgnoreRadius + * @param {QUuid} avatarID + * @returns {Signal} + */ + void avatarEnteredIgnoreRadius(QUuid avatarID); + + /**jsdoc + * @function AvatarInputs.avatarLeftIgnoreRadius + * @param {QUuid} avatarID + * @returns {Signal} + */ + void avatarLeftIgnoreRadius(QUuid avatarID); + /**jsdoc * @function AvatarInputs.ignoreRadiusEnabledChanged * @param {boolean} enabled @@ -102,6 +118,13 @@ signals: */ void ignoreRadiusEnabledChanged(bool enabled); + /**jsdoc + * @function AvatarInputs.enteredIgnoreRadiusChanged + * @param {boolean} enabled + * @returns {Signal} + */ + void enteredIgnoreRadiusChanged(); + protected: /**jsdoc @@ -115,6 +138,8 @@ protected: Q_INVOKABLE void toggleCameraMute(); private: + void onAvatarEnteredIgnoreRadius(); + void onAvatarLeftIgnoreRadius(); float _trailingAudioLoudness{ 0 }; bool _showAudioTools { false }; }; diff --git a/interface/src/ui/PrivacyShield.cpp b/interface/src/ui/PrivacyShield.cpp index 12687afbea..e8f61ff5bf 100644 --- a/interface/src/ui/PrivacyShield.cpp +++ b/interface/src/ui/PrivacyShield.cpp @@ -10,3 +10,150 @@ // #include "PrivacyShield.h" + +#include +#include +#include +#include +#include +#include + +#include "Application.h" +#include "PathUtils.h" +#include "GLMHelpers.h" + +const int PRIVACY_SHIELD_VISIBLE_DURATION_MS = 3000; +const int PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS = 750; +const int PRIVACY_SHIELD_SOUND_RATE_LIMIT_MS = 15000; +const float PRIVACY_SHIELD_HEIGHT_SCALE = 0.15f; + +PrivacyShield::PrivacyShield() { + auto usersScriptingInterface = DependencyManager::get(); + //connect(usersScriptingInterface.data(), &UsersScriptingInterface::ignoreRadiusEnabledChanged, [this](bool enabled) { + // onPrivacyShieldToggled(enabled); + //}); + //connect(usersScriptingInterface.data(), &UsersScriptingInterface::enteredIgnoreRadius, this, &PrivacyShield::enteredIgnoreRadius); +} + +void PrivacyShield::createPrivacyShield() { + // Affects bubble height + auto myAvatar = DependencyManager::get()->getMyAvatar(); + auto avatarScale = myAvatar->getTargetScale(); + auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); + auto avatarWorldPosition = myAvatar->getWorldPosition(); + auto avatarWorldOrientation = myAvatar->getWorldOrientation(); + EntityItemProperties properties; + properties.setName("Privacy-Shield"); + properties.setModelURL(PathUtils::resourcesUrl("assets/models/Bubble-v14.fbx").toString()); + properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); + properties.setPosition(glm::vec3(avatarWorldPosition.x, + -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); + properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); + properties.setVisible(false); + + _localPrivacyShieldID = DependencyManager::get()->addEntityInternal(properties, entity::HostType::LOCAL); + //_bubbleActivateSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl() + "assets/sounds/bubble.wav"); + + //onPrivacyShieldToggled(DependencyManager::get()->getIgnoreRadiusEnabled(), true); +} + +void PrivacyShield::destroyPrivacyShield() { + DependencyManager::get()->deleteEntity(_localPrivacyShieldID); +} + +void PrivacyShield::update(float deltaTime) { + if (_updateConnected) { + auto now = usecTimestampNow(); + auto delay = (now - _privacyShieldTimestamp); + auto privacyShieldAlpha = 1.0 - (delay / PRIVACY_SHIELD_VISIBLE_DURATION_MS); + if (privacyShieldAlpha > 0) { + auto myAvatar = DependencyManager::get()->getMyAvatar(); + auto avatarScale = myAvatar->getTargetScale(); + auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); + auto avatarWorldPosition = myAvatar->getWorldPosition(); + auto avatarWorldOrientation = myAvatar->getWorldOrientation(); + EntityItemProperties properties; + properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); + properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); + if (delay < PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS) { + properties.setPosition(glm::vec3(avatarWorldPosition.x, + (-((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * avatarScale * 2.0 + + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + properties.setModelScale(glm::vec3(2.0, + ((1 - ((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * + (0.5 * (avatarScale + 1.0))), 2.0)); + } else { + properties.setPosition(glm::vec3(avatarWorldPosition.x, avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); + } + DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); + } + else { + hidePrivacyShield(); + if (_updateConnected) { + _updateConnected = false; + } + } + } +} + +void PrivacyShield::enteredIgnoreRadius() { + showPrivacyShield(); + DependencyManager::get()->privacyShieldActivated(); +} + +void PrivacyShield::onPrivacyShieldToggled(bool enabled, bool doNotLog) { + if (!doNotLog) { + DependencyManager::get()->privacyShieldToggled(enabled); + } + if (enabled) { + showPrivacyShield(); + } else { + hidePrivacyShield(); + if (_updateConnected) { + _updateConnected = false; + } + } +} + +void PrivacyShield::showPrivacyShield() { + auto now = usecTimestampNow(); + auto myAvatar = DependencyManager::get()->getMyAvatar(); + auto avatarScale = myAvatar->getTargetScale(); + auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); + auto avatarWorldPosition = myAvatar->getWorldPosition(); + auto avatarWorldOrientation = myAvatar->getWorldOrientation(); + if (now - _lastPrivacyShieldSoundTimestamp >= PRIVACY_SHIELD_SOUND_RATE_LIMIT_MS) { + AudioInjectorOptions options; + options.position = avatarWorldPosition; + options.localOnly = true; + options.volume = 0.2f; + AudioInjector::playSoundAndDelete(_bubbleActivateSound, options); + _lastPrivacyShieldSoundTimestamp = now; + } + hidePrivacyShield(); + if (_updateConnected) { + _updateConnected = false; + } + + EntityItemProperties properties; + properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); + properties.setPosition(glm::vec3(avatarWorldPosition.x, + -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); + properties.setVisible(true); + + DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); + + _privacyShieldTimestamp = now; + _updateConnected = true; +} + +void PrivacyShield::hidePrivacyShield() { + EntityTreePointer entityTree = qApp->getEntities()->getTree(); + EntityItemPointer privacyShieldEntity = entityTree->findEntityByEntityItemID(EntityItemID(_localPrivacyShieldID)); + if (privacyShieldEntity) { + privacyShieldEntity->setVisible(false); + } +} diff --git a/interface/src/ui/PrivacyShield.h b/interface/src/ui/PrivacyShield.h index a609f2775b..5aecb661f7 100644 --- a/interface/src/ui/PrivacyShield.h +++ b/interface/src/ui/PrivacyShield.h @@ -10,3 +10,38 @@ // #pragma once + +#include +#include +#include + +#include +#include + +class PrivacyShield : public QObject, public Dependency { + Q_OBJECT + SINGLETON_DEPENDENCY + +public: + PrivacyShield(); + void createPrivacyShield(); + void destroyPrivacyShield(); + + bool isVisible() const { return _visible; } + void update(float deltaTime); + +protected slots: + void enteredIgnoreRadius(); + void onPrivacyShieldToggled(bool enabled, bool doNotLog = false); + +private: + void showPrivacyShield(); + void hidePrivacyShield(); + + SharedSoundPointer _bubbleActivateSound; + QUuid _localPrivacyShieldID; + quint64 _privacyShieldTimestamp; + quint64 _lastPrivacyShieldSoundTimestamp; + bool _visible { false }; + bool _updateConnected { false }; +}; diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 95bbcbeb16..32f53f77a3 100755 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -1477,6 +1477,7 @@ protected: glm::vec3 _globalBoundingBoxOffset; AABox _defaultBubbleBox; + AABox _fitBoundingBox; mutable ReadWriteLockable _avatarEntitiesLock; AvatarEntityIDs _avatarEntityRemoved; // recently removed AvatarEntity ids diff --git a/libraries/networking/src/UserActivityLoggerScriptingInterface.cpp b/libraries/networking/src/UserActivityLoggerScriptingInterface.cpp index c63170de75..2f47ef5e00 100644 --- a/libraries/networking/src/UserActivityLoggerScriptingInterface.cpp +++ b/libraries/networking/src/UserActivityLoggerScriptingInterface.cpp @@ -71,12 +71,12 @@ void UserActivityLoggerScriptingInterface::makeUserConnection(QString otherID, b doLogAction("makeUserConnection", payload); } -void UserActivityLoggerScriptingInterface::bubbleToggled(bool newValue) { - doLogAction(newValue ? "bubbleOn" : "bubbleOff"); +void UserActivityLoggerScriptingInterface::privacyShieldToggled(bool newValue) { + doLogAction(newValue ? "privacyShieldOn" : "privacyShieldOff"); } -void UserActivityLoggerScriptingInterface::bubbleActivated() { - doLogAction("bubbleActivated"); +void UserActivityLoggerScriptingInterface::privacyShieldActivated() { + doLogAction("privacyShieldActivated"); } void UserActivityLoggerScriptingInterface::logAction(QString action, QVariantMap details) { diff --git a/libraries/networking/src/UserActivityLoggerScriptingInterface.h b/libraries/networking/src/UserActivityLoggerScriptingInterface.h index 71d411056d..1cda1235e9 100644 --- a/libraries/networking/src/UserActivityLoggerScriptingInterface.h +++ b/libraries/networking/src/UserActivityLoggerScriptingInterface.h @@ -30,8 +30,8 @@ public: Q_INVOKABLE void palAction(QString action, QString target); Q_INVOKABLE void palOpened(float secondsOpen); Q_INVOKABLE void makeUserConnection(QString otherUser, bool success, QString details = ""); - Q_INVOKABLE void bubbleToggled(bool newValue); - Q_INVOKABLE void bubbleActivated(); + Q_INVOKABLE void privacyShieldToggled(bool newValue); + Q_INVOKABLE void privacyShieldActivated(); Q_INVOKABLE void logAction(QString action, QVariantMap details = QVariantMap{}); Q_INVOKABLE void commercePurchaseSuccess(QString marketplaceID, QString contentCreator, int cost, bool firstPurchaseOfThisItem); Q_INVOKABLE void commercePurchaseFailure(QString marketplaceID, QString contentCreator, int cost, bool firstPurchaseOfThisItem, QString errorDetails); diff --git a/scripts/system/bubble.js b/scripts/system/bubble.js index 6ca624872e..eca3b3dcd4 100644 --- a/scripts/system/bubble.js +++ b/scripts/system/bubble.js @@ -90,7 +90,7 @@ // Called from the C++ scripting interface to show the bubble overlay function enteredIgnoreRadius() { createOverlays(); - UserActivityLogger.bubbleActivated(); + UserActivityLogger.privacyShieldActivated(); } // Used to set the state of the bubble HUD button @@ -160,7 +160,7 @@ function onBubbleToggled(enabled, doNotLog) { writeButtonProperties(enabled); if (doNotLog !== true) { - UserActivityLogger.bubbleToggled(enabled); + UserActivityLogger.privacyShieldToggled(enabled); } if (enabled) { createOverlays(); @@ -174,7 +174,7 @@ } // Setup the bubble button - var buttonName = "BUBBLE"; + var buttonName = "SHIELD"; var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); button = tablet.addButton({ icon: "icons/tablet-icons/bubble-i.svg", From 811fa8dcb29a3cb306fef95e49d98a5f824bd350 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 1 Mar 2019 09:12:03 -0800 Subject: [PATCH 13/60] allowing bubble icon to toggle --- interface/resources/qml/AvatarInputsBar.qml | 8 +- interface/src/ui/PrivacyShield.cpp | 96 ++++++++++----------- 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/interface/resources/qml/AvatarInputsBar.qml b/interface/resources/qml/AvatarInputsBar.qml index 615e260833..ead4fbc618 100644 --- a/interface/resources/qml/AvatarInputsBar.qml +++ b/interface/resources/qml/AvatarInputsBar.qml @@ -36,7 +36,7 @@ Item { width: bubbleIcon.width + 10 height: parent.height radius: 5; - opacity: 0.5; + opacity: AvatarInputs.ignoreRadiusEnabled ? 0.7 : 0.3; color: "#00000000"; border { @@ -56,14 +56,12 @@ Item { scrollGestureEnabled: false; onClicked: { Tablet.playSound(TabletEnums.ButtonClick); + Users.toggleIgnoreRadius(); } drag.target: root; onContainsMouseChanged: { if (containsMouse) { Tablet.playSound(TabletEnums.ButtonHover); - bubbleRect.opacity = 0.7; - } else { - bubbleRect.opacity = 0.5; } } } @@ -82,7 +80,7 @@ Item { id: bubbleIconOverlay anchors.fill: bubbleIcon source: bubbleIcon - color: AvatarInputs.ignoreRadiusEnabled ? "#1FC6A6" : "#FFFFFF"; + color: "#FFFFFF"; } } } diff --git a/interface/src/ui/PrivacyShield.cpp b/interface/src/ui/PrivacyShield.cpp index e8f61ff5bf..279c05ee2d 100644 --- a/interface/src/ui/PrivacyShield.cpp +++ b/interface/src/ui/PrivacyShield.cpp @@ -37,22 +37,22 @@ PrivacyShield::PrivacyShield() { void PrivacyShield::createPrivacyShield() { // Affects bubble height - auto myAvatar = DependencyManager::get()->getMyAvatar(); - auto avatarScale = myAvatar->getTargetScale(); - auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - auto avatarWorldPosition = myAvatar->getWorldPosition(); - auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - EntityItemProperties properties; - properties.setName("Privacy-Shield"); - properties.setModelURL(PathUtils::resourcesUrl("assets/models/Bubble-v14.fbx").toString()); - properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - properties.setPosition(glm::vec3(avatarWorldPosition.x, - -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); - properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - properties.setVisible(false); + //auto myAvatar = DependencyManager::get()->getMyAvatar(); + //auto avatarScale = myAvatar->getTargetScale(); + //auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); + //auto avatarWorldPosition = myAvatar->getWorldPosition(); + //auto avatarWorldOrientation = myAvatar->getWorldOrientation(); + //EntityItemProperties properties; + //properties.setName("Privacy-Shield"); + //properties.setModelURL(PathUtils::resourcesUrl("assets/models/Bubble-v14.fbx").toString()); + //properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); + //properties.setPosition(glm::vec3(avatarWorldPosition.x, + // -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + //properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); + //properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); + //properties.setVisible(false); - _localPrivacyShieldID = DependencyManager::get()->addEntityInternal(properties, entity::HostType::LOCAL); + //_localPrivacyShieldID = DependencyManager::get()->addEntityInternal(properties, entity::HostType::LOCAL); //_bubbleActivateSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl() + "assets/sounds/bubble.wav"); //onPrivacyShieldToggled(DependencyManager::get()->getIgnoreRadiusEnabled(), true); @@ -63,39 +63,39 @@ void PrivacyShield::destroyPrivacyShield() { } void PrivacyShield::update(float deltaTime) { - if (_updateConnected) { - auto now = usecTimestampNow(); - auto delay = (now - _privacyShieldTimestamp); - auto privacyShieldAlpha = 1.0 - (delay / PRIVACY_SHIELD_VISIBLE_DURATION_MS); - if (privacyShieldAlpha > 0) { - auto myAvatar = DependencyManager::get()->getMyAvatar(); - auto avatarScale = myAvatar->getTargetScale(); - auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - auto avatarWorldPosition = myAvatar->getWorldPosition(); - auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - EntityItemProperties properties; - properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); - if (delay < PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS) { - properties.setPosition(glm::vec3(avatarWorldPosition.x, - (-((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * avatarScale * 2.0 + - avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - properties.setModelScale(glm::vec3(2.0, - ((1 - ((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * - (0.5 * (avatarScale + 1.0))), 2.0)); - } else { - properties.setPosition(glm::vec3(avatarWorldPosition.x, avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - } - DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); - } - else { - hidePrivacyShield(); - if (_updateConnected) { - _updateConnected = false; - } - } - } + //if (_updateConnected) { + // auto now = usecTimestampNow(); + // auto delay = (now - _privacyShieldTimestamp); + // auto privacyShieldAlpha = 1.0 - (delay / PRIVACY_SHIELD_VISIBLE_DURATION_MS); + // if (privacyShieldAlpha > 0) { + // auto myAvatar = DependencyManager::get()->getMyAvatar(); + // auto avatarScale = myAvatar->getTargetScale(); + // auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); + // auto avatarWorldPosition = myAvatar->getWorldPosition(); + // auto avatarWorldOrientation = myAvatar->getWorldOrientation(); + // EntityItemProperties properties; + // properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); + // properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); + // if (delay < PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS) { + // properties.setPosition(glm::vec3(avatarWorldPosition.x, + // (-((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * avatarScale * 2.0 + + // avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + // properties.setModelScale(glm::vec3(2.0, + // ((1 - ((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * + // (0.5 * (avatarScale + 1.0))), 2.0)); + // } else { + // properties.setPosition(glm::vec3(avatarWorldPosition.x, avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + // properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); + // } + // DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); + // } + // else { + // hidePrivacyShield(); + // if (_updateConnected) { + // _updateConnected = false; + // } + // } + //} } void PrivacyShield::enteredIgnoreRadius() { From 5b6ce8736d3a46c0f12a40aff572f048e8b7c971 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 1 Mar 2019 11:28:00 -0800 Subject: [PATCH 14/60] adding new icons with gated icon --- .../icons/tablet-icons/mic-clip-i.svg | 5 ++- .../icons/tablet-icons/mic-gate-i.svg | 6 ++++ .../icons/tablet-icons/mic-mute-i.svg | 32 +++++-------------- .../icons/tablet-icons/mic-unmute-i.svg | 6 +++- .../qml/hifi/audio/MicBarApplication.qml | 3 +- 5 files changed, 25 insertions(+), 27 deletions(-) create mode 100644 interface/resources/icons/tablet-icons/mic-gate-i.svg diff --git a/interface/resources/icons/tablet-icons/mic-clip-i.svg b/interface/resources/icons/tablet-icons/mic-clip-i.svg index 8bc1b2b558..c1989db2d6 100644 --- a/interface/resources/icons/tablet-icons/mic-clip-i.svg +++ b/interface/resources/icons/tablet-icons/mic-clip-i.svg @@ -1,6 +1,9 @@ - + + + + diff --git a/interface/resources/icons/tablet-icons/mic-gate-i.svg b/interface/resources/icons/tablet-icons/mic-gate-i.svg new file mode 100644 index 0000000000..a5a5a621d7 --- /dev/null +++ b/interface/resources/icons/tablet-icons/mic-gate-i.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/interface/resources/icons/tablet-icons/mic-mute-i.svg b/interface/resources/icons/tablet-icons/mic-mute-i.svg index 9dc2c53443..0da394a5a2 100644 --- a/interface/resources/icons/tablet-icons/mic-mute-i.svg +++ b/interface/resources/icons/tablet-icons/mic-mute-i.svg @@ -1,25 +1,9 @@ - - - - - - - - - - - - - - - + + + + + + + + diff --git a/interface/resources/icons/tablet-icons/mic-unmute-i.svg b/interface/resources/icons/tablet-icons/mic-unmute-i.svg index f577a65bc2..ebfcc21e37 100644 --- a/interface/resources/icons/tablet-icons/mic-unmute-i.svg +++ b/interface/resources/icons/tablet-icons/mic-unmute-i.svg @@ -1,3 +1,7 @@ - + + + + + diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 2bf49aa83b..30cef44bce 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -29,6 +29,7 @@ Rectangle { readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg"; readonly property string clippingIcon: "../../../icons/tablet-icons/mic-clip-i.svg"; + readonly property string gatedIcon: "../../../icons/tablet-icons/mic-gate-i.svg"; property bool standalone: false; property var dragTarget: null; @@ -118,7 +119,7 @@ Rectangle { Item { Image { id: image; - source: muted ? mutedIcon : clipping ? clippingIcon : unmutedIcon; + source: muted ? mutedIcon : clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; width: 29; height: 32; From 4dca4cbc40f421d63836a45b8bbe4d214fcffc45 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 1 Mar 2019 11:38:32 -0800 Subject: [PATCH 15/60] update icons again --- .../icons/tablet-icons/mic-clip-i.svg | 5 +- .../icons/tablet-icons/mic-gate-i.svg | 5 +- .../icons/tablet-icons/mic-mute-a.svg | 26 +------ .../icons/tablet-icons/mic-mute-i.svg | 8 +- .../icons/tablet-icons/mic-unmute-a.svg | 73 +------------------ .../icons/tablet-icons/mic-unmute-i.svg | 6 +- 6 files changed, 9 insertions(+), 114 deletions(-) diff --git a/interface/resources/icons/tablet-icons/mic-clip-i.svg b/interface/resources/icons/tablet-icons/mic-clip-i.svg index c1989db2d6..f912c1e744 100644 --- a/interface/resources/icons/tablet-icons/mic-clip-i.svg +++ b/interface/resources/icons/tablet-icons/mic-clip-i.svg @@ -1,9 +1,6 @@ - - - - + diff --git a/interface/resources/icons/tablet-icons/mic-gate-i.svg b/interface/resources/icons/tablet-icons/mic-gate-i.svg index a5a5a621d7..8255174532 100644 --- a/interface/resources/icons/tablet-icons/mic-gate-i.svg +++ b/interface/resources/icons/tablet-icons/mic-gate-i.svg @@ -1,6 +1,3 @@ - - - - + diff --git a/interface/resources/icons/tablet-icons/mic-mute-a.svg b/interface/resources/icons/tablet-icons/mic-mute-a.svg index 9dc2c53443..67eafc27c8 100644 --- a/interface/resources/icons/tablet-icons/mic-mute-a.svg +++ b/interface/resources/icons/tablet-icons/mic-mute-a.svg @@ -1,25 +1,3 @@ - - - - - - - - - - - - - - - + + diff --git a/interface/resources/icons/tablet-icons/mic-mute-i.svg b/interface/resources/icons/tablet-icons/mic-mute-i.svg index 0da394a5a2..63af1b0da8 100644 --- a/interface/resources/icons/tablet-icons/mic-mute-i.svg +++ b/interface/resources/icons/tablet-icons/mic-mute-i.svg @@ -1,9 +1,3 @@ - - - - - - - + diff --git a/interface/resources/icons/tablet-icons/mic-unmute-a.svg b/interface/resources/icons/tablet-icons/mic-unmute-a.svg index b1464f207d..0bf7677017 100644 --- a/interface/resources/icons/tablet-icons/mic-unmute-a.svg +++ b/interface/resources/icons/tablet-icons/mic-unmute-a.svg @@ -1,70 +1,3 @@ - - - -image/svg+xml \ No newline at end of file + + + diff --git a/interface/resources/icons/tablet-icons/mic-unmute-i.svg b/interface/resources/icons/tablet-icons/mic-unmute-i.svg index ebfcc21e37..0bf7677017 100644 --- a/interface/resources/icons/tablet-icons/mic-unmute-i.svg +++ b/interface/resources/icons/tablet-icons/mic-unmute-i.svg @@ -1,7 +1,3 @@ - - - - - + From 77b7cc2457cf9f9412116d51e59edc7c9c2461cb Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 14 Mar 2019 10:28:18 -0700 Subject: [PATCH 16/60] separating out bubble icon qml - adding support for transparency --- interface/resources/qml/AvatarInputsBar.qml | 53 +----- interface/resources/qml/BubbleIcon.qml | 82 +++++++++ interface/resources/qml/hifi/audio/MicBar.qml | 34 ++-- .../qml/hifi/audio/MicBarApplication.qml | 80 ++++----- interface/src/Application.cpp | 65 +++++-- interface/src/Application.h | 7 +- interface/src/scripting/Audio.cpp | 8 +- interface/src/ui/PrivacyShield.cpp | 159 ------------------ interface/src/ui/PrivacyShield.h | 47 ------ scripts/defaultScripts.js | 3 +- 10 files changed, 204 insertions(+), 334 deletions(-) create mode 100644 interface/resources/qml/BubbleIcon.qml delete mode 100644 interface/src/ui/PrivacyShield.cpp delete mode 100644 interface/src/ui/PrivacyShield.h diff --git a/interface/resources/qml/AvatarInputsBar.qml b/interface/resources/qml/AvatarInputsBar.qml index ead4fbc618..dfff103aa0 100644 --- a/interface/resources/qml/AvatarInputsBar.qml +++ b/interface/resources/qml/AvatarInputsBar.qml @@ -31,56 +31,7 @@ Item { standalone: true; dragTarget: parent; } - Rectangle { - id: bubbleRect - width: bubbleIcon.width + 10 - height: parent.height - radius: 5; - opacity: AvatarInputs.ignoreRadiusEnabled ? 0.7 : 0.3; - - color: "#00000000"; - border { - width: mouseArea.containsMouse || mouseArea.containsPress ? 2 : 0; - color: "#80FFFFFF"; - } - anchors { - left: root.right - top: root.top - } - - MouseArea { - id: mouseArea; - anchors.fill: parent - - hoverEnabled: true; - scrollGestureEnabled: false; - onClicked: { - Tablet.playSound(TabletEnums.ButtonClick); - Users.toggleIgnoreRadius(); - } - drag.target: root; - onContainsMouseChanged: { - if (containsMouse) { - Tablet.playSound(TabletEnums.ButtonHover); - } - } - } - Image { - id: bubbleIcon - source: "../icons/tablet-icons/bubble-i.svg"; - sourceSize: Qt.size(28, 28); - smooth: true; - visible: false - anchors.top: parent.top - anchors.topMargin: (parent.height - bubbleIcon.height) / 2 - anchors.left: parent.left - anchors.leftMargin: (parent.width - bubbleIcon.width) / 2 - } - ColorOverlay { - id: bubbleIconOverlay - anchors.fill: bubbleIcon - source: bubbleIcon - color: "#FFFFFF"; - } + BubbleIcon { + dragTarget: parent } } diff --git a/interface/resources/qml/BubbleIcon.qml b/interface/resources/qml/BubbleIcon.qml new file mode 100644 index 0000000000..f9c57697f0 --- /dev/null +++ b/interface/resources/qml/BubbleIcon.qml @@ -0,0 +1,82 @@ +// +// Created by Bradley Austin Davis on 2015/06/19 +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import Hifi 1.0 as Hifi +import QtQuick 2.5 +import QtGraphicalEffects 1.0 + +import "./hifi/audio" as HifiAudio + +import TabletScriptingInterface 1.0 + +Rectangle { + id: bubbleRect + width: bubbleIcon.width + 10 + height: bubbleIcon.height + 10 + radius: 5; + opacity: AvatarInputs.ignoreRadiusEnabled ? 0.7 : 0.3; + property var dragTarget: null; + + color: "#00000000"; + border { + width: mouseArea.containsMouse || mouseArea.containsPress ? 2 : 0; + color: "#80FFFFFF"; + } + anchors { + left: dragTarget ? dragTarget.right : undefined + top: dragTarget ? dragTarget.top : undefined + } + + // borders are painted over fill, so reduce the fill to fit inside the border + Rectangle { + color: "#55000000"; + width: 40; + height: 40; + + radius: 5; + + anchors { + verticalCenter: parent.verticalCenter; + horizontalCenter: parent.horizontalCenter; + } + } + + MouseArea { + id: mouseArea; + anchors.fill: parent + + hoverEnabled: true; + scrollGestureEnabled: false; + onClicked: { + Tablet.playSound(TabletEnums.ButtonClick); + Users.toggleIgnoreRadius(); + } + drag.target: dragTarget; + onContainsMouseChanged: { + if (containsMouse) { + Tablet.playSound(TabletEnums.ButtonHover); + } + } + } + Image { + id: bubbleIcon + source: "../icons/tablet-icons/bubble-i.svg"; + sourceSize: Qt.size(28, 28); + smooth: true; + anchors.top: parent.top + anchors.topMargin: (parent.height - bubbleIcon.height) / 2 + anchors.left: parent.left + anchors.leftMargin: (parent.width - bubbleIcon.width) / 2 + } + ColorOverlay { + id: bubbleIconOverlay + anchors.fill: bubbleIcon + source: bubbleIcon + color: "#FFFFFF"; + } +} diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index 7ed9451a04..fba06ac987 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -19,13 +19,18 @@ Rectangle { HifiConstants { id: hifi; } readonly property var level: AudioScriptingInterface.inputLevel; - + readonly property var clipping: AudioScriptingInterface.clipping; + readonly property var muted: AudioScriptingInterface.muted; + readonly property var pushToTalk: AudioScriptingInterface.pushToTalk; + readonly property var pushingToTalk: AudioScriptingInterface.pushingToTalk; + + readonly property var userSpeakingLevel: 0.4; property bool gated: false; Component.onCompleted: { AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; }); AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; }); } - + property bool standalone: false; property var dragTarget: null; @@ -70,7 +75,7 @@ Rectangle { if (AudioScriptingInterface.pushToTalk) { return; } - AudioScriptingInterface.muted = !AudioScriptingInterface.muted; + muted = !muted; Tablet.playSound(TabletEnums.ButtonClick); } drag.target: dragTarget; @@ -113,9 +118,12 @@ Rectangle { readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg"; readonly property string pushToTalkIcon: "../../../icons/tablet-icons/mic-ptt-i.svg"; + readonly property string clippingIcon: "../../../icons/tablet-icons/mic-clip-i.svg"; + readonly property string gatedIcon: "../../../icons/tablet-icons/mic-gate-i.svg"; id: image; - source: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? pushToTalkIcon : AudioScriptingInterface.muted ? mutedIcon : unmutedIcon; + source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : + clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; width: 30; height: 30; @@ -138,9 +146,9 @@ Rectangle { Item { id: status; - readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted; + readonly property string color: muted ? colors.muted : colors.unmuted; - visible: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) || (AudioScriptingInterface.muted && (level >= userSpeakingLevel)); + visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); anchors { left: parent.left; @@ -159,7 +167,7 @@ Rectangle { color: parent.color; - text: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? (HMD.active ? "MUTED PTT" : "MUTED PTT-(T)") : (AudioScriptingInterface.muted ? "MUTED" : "MUTE"); + text: (pushToTalk && !pushingToTalk) ? (HMD.active ? "MUTED PTT" : "MUTED PTT-(T)") : (muted ? "MUTED" : "MUTE"); font.pointSize: 12; } @@ -235,12 +243,12 @@ Rectangle { } } } - + Rectangle { id: gatedIndicator; visible: gated && !AudioScriptingInterface.clipping - - radius: 4; + + radius: 4; width: 2 * radius; height: 2 * radius; color: "#0080FF"; @@ -249,12 +257,12 @@ Rectangle { verticalCenter: parent.verticalCenter; } } - + Rectangle { id: clippingIndicator; visible: AudioScriptingInterface.clipping - - radius: 4; + + radius: 4; width: 2 * radius; height: 2 * radius; color: colors.red; diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 30cef44bce..bfac278ee4 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -1,5 +1,5 @@ // -// MicBar.qml +// MicBarApplication.qml // qml/hifi/audio // // Created by Zach Pomerantz on 6/14/2017 @@ -16,9 +16,12 @@ import stylesUit 1.0 import TabletScriptingInterface 1.0 Rectangle { + id: micBar; readonly property var level: AudioScriptingInterface.inputLevel; readonly property var clipping: AudioScriptingInterface.clipping; readonly property var muted: AudioScriptingInterface.muted; + readonly property var pushToTalk: AudioScriptingInterface.pushToTalk; + readonly property var pushingToTalk: AudioScriptingInterface.pushingToTalk; readonly property var userSpeakingLevel: 0.4; property bool gated: false; Component.onCompleted: { @@ -28,6 +31,7 @@ Rectangle { readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg"; + readonly property string pushToTalkIcon: "../../../icons/tablet-icons/mic-ptt-i.svg"; readonly property string clippingIcon: "../../../icons/tablet-icons/mic-clip-i.svg"; readonly property string gatedIcon: "../../../icons/tablet-icons/mic-gate-i.svg"; property bool standalone: false; @@ -37,13 +41,16 @@ Rectangle { height: 44; radius: 5; + opacity: 0.7 onLevelChanged: { var rectOpacity = muted && (level >= userSpeakingLevel) ? 0.9 : 0.3; - if (mouseArea.containsMouse && rectOpacity != 0.9) { + if (pushToTalk && !pushingToTalk) { + rectOpacity = (level >= userSpeakingLevel) ? 0.9 : 0.7; + } else if (mouseArea.containsMouse && rectOpacity != 0.9) { rectOpacity = 0.5; } - opacity = rectOpacity; + micBar.opacity = rectOpacity; } color: "#00000000"; @@ -94,15 +101,15 @@ Rectangle { id: colors; readonly property string unmutedColor: "#FFF"; + readonly property string gatedColor: "#00BDFF"; readonly property string mutedColor: "#E2334D"; readonly property string gutter: "#575757"; readonly property string greenStart: "#39A38F"; readonly property string greenEnd: "#1FC6A6"; readonly property string yellow: "#C0C000"; - readonly property string red: colors.muted; readonly property string fill: "#55000000"; readonly property string border: standalone ? "#80FFFFFF" : "#55FFFFFF"; - readonly property string icon: muted ? mutedColor : unmutedColor; + readonly property string icon: (muted || clipping) ? mutedColor : gated ? gatedColor : unmutedColor; } Item { @@ -110,7 +117,7 @@ Rectangle { anchors { left: parent.left; - verticalCenter: parent.verticalCenter; + top: parent.top; } width: 40; @@ -119,8 +126,8 @@ Rectangle { Item { Image { id: image; - source: muted ? mutedIcon : clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; - + source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : + clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; width: 29; height: 32; anchors { @@ -134,7 +141,8 @@ Rectangle { id: imageOverlay anchors { fill: image } source: image; - color: colors.icon; + color: (pushToTalk && !pushingToTalk) ? ((level >= userSpeakingLevel) ? colors.mutedColor : + colors.unmutedColor) : colors.icon; } } } @@ -142,26 +150,34 @@ Rectangle { Item { id: status; - visible: muted && (level >= userSpeakingLevel); + visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); anchors { left: parent.left; - top: parent.bottom - topMargin: 5 + top: icon.bottom; + topMargin: 5; } - width: icon.width; - height: 8 + width: parent.width; + height: statusTextMetrics.height; + + TextMetrics { + id: statusTextMetrics + text: statusText.text + font: statusText.font + } RalewaySemiBold { + id: statusText anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter; } - color: colors.mutedColor; + color: (level >= userSpeakingLevel && muted) ? colors.mutedColor : colors.unmutedColor; + font.bold: true - text: "MUTED"; + text: (pushToTalk && !pushingToTalk) ? (HMD.active ? "PTT" : "PTT-(T)") : (muted ? "MUTED" : "MUTE"); size: 12; } } @@ -172,7 +188,8 @@ Rectangle { anchors { right: parent.right; rightMargin: 7; - verticalCenter: parent.verticalCenter; + top: parent.top + topMargin: 5 } width: 8; @@ -219,34 +236,5 @@ Rectangle { } } } -/* - Rectangle { - id: gatedIndicator; - visible: gated && !clipping - - radius: 4; - width: 2 * radius; - height: 2 * radius; - color: "#0080FF"; - anchors { - right: parent.left; - verticalCenter: parent.verticalCenter; - } - } - - Rectangle { - id: clippingIndicator; - visible: clipping - - radius: 4; - width: 2 * radius; - height: 2 * radius; - color: colors.red; - anchors { - left: parent.right; - verticalCenter: parent.verticalCenter; - } - } -*/ } } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e34ae4bcba..9fd0781eef 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -211,7 +211,6 @@ #include "ui/UpdateDialog.h" #include "ui/DomainConnectionModel.h" #include "ui/Keyboard.h" -#include "ui/PrivacyShield.h" #include "Util.h" #include "InterfaceParentFinder.h" #include "ui/OctreeStatsProvider.h" @@ -339,6 +338,10 @@ Setting::Handle maxOctreePacketsPerSecond{"maxOctreePPS", DEFAULT_MAX_OCTRE Setting::Handle loginDialogPoppedUp{"loginDialogPoppedUp", false}; +static const QUrl AVATAR_INPUTS_BAR_QML = PathUtils::qmlUrl("AvatarInputsBar.qml"); +static const QUrl MIC_BAR_ENTITY_QML = PathUtils::qmlUrl("hifi/audio/MicBarApplication.qml"); +static const QUrl BUBBLE_ICON_QML = PathUtils::qmlUrl("BubbleIcon.qml"); + static const QString STANDARD_TO_ACTION_MAPPING_NAME = "Standard to Action"; static const QString NO_MOVEMENT_MAPPING_NAME = "Standard to Action (No Movement)"; static const QString NO_MOVEMENT_MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/standard_nomovement.json"; @@ -928,7 +931,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); - DependencyManager::set(); return previousSessionCrashed; } @@ -1293,6 +1295,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo setCrashAnnotation("display_plugin", displayPlugin->getName().toStdString()); setCrashAnnotation("hmd", displayPlugin->isHmd() ? "1" : "0"); }); + connect(this, &Application::activeDisplayPluginChanged, this, [&](){ +#if !defined(Q_OS_ANDROID) + if (!getLoginDialogPoppedUp() && _desktopRootItemCreated) { + if (isHMDMode()) { + createAvatarInputsBar(); + auto offscreenUi = getOffscreenUI(); + offscreenUi->hide(AVATAR_INPUTS_BAR_QML.toString()); + } else { + destroyAvatarInputsBar(); + auto offscreenUi = getOffscreenUI(); + offscreenUi->show(AVATAR_INPUTS_BAR_QML.toString(), "AvatarInputsBar"); + } + } +#endif + }); connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode); connect(this, &Application::activeDisplayPluginChanged, this, [&](){ if (getLoginDialogPoppedUp()) { @@ -2378,7 +2395,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo }); }); auto rootItemLoadedFunctor = [webSurface, url, isTablet] { - Application::setupQmlSurface(webSurface->getSurfaceContext(), isTablet || url == LOGIN_DIALOG.toString()); + Application::setupQmlSurface(webSurface->getSurfaceContext(), isTablet || url == LOGIN_DIALOG.toString() || url == AVATAR_INPUTS_BAR_QML.toString() || + url == BUBBLE_ICON_QML.toString() || url == MIC_BAR_ENTITY_QML.toString() ); }; if (webSurface->getRootItem()) { rootItemLoadedFunctor(); @@ -2652,9 +2670,6 @@ void Application::cleanupBeforeQuit() { nodeList->getPacketReceiver().setShouldDropPackets(true); } - // destroy privacy shield before entity shutdown. - DependencyManager::get()->destroyPrivacyShield(); - getEntities()->shutdown(); // tell the entities system we're shutting down, so it will stop running scripts // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) @@ -2733,7 +2748,6 @@ void Application::cleanupBeforeQuit() { DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); - DependencyManager::destroy(); DependencyManager::destroy(); qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete"; @@ -3301,6 +3315,7 @@ void Application::onDesktopRootItemCreated(QQuickItem* rootItem) { auto qml = PathUtils::qmlUrl("AvatarInputsBar.qml"); offscreenUi->show(qml, "AvatarInputsBar"); #endif + _desktopRootItemCreated = true; } void Application::userKickConfirmation(const QUuid& nodeID) { @@ -5534,8 +5549,6 @@ void Application::resumeAfterLoginDialogActionTaken() { menu->getMenu("Developer")->setVisible(_developerMenuVisible); _myCamera.setMode(_previousCameraMode); cameraModeChanged(); - - DependencyManager::get()->createPrivacyShield(); } void Application::loadAvatarScripts(const QVector& urls) { @@ -6494,8 +6507,6 @@ void Application::update(float deltaTime) { updateLoginDialogPosition(); } - DependencyManager::get()->update(deltaTime); - { PROFILE_RANGE_EX(app, "Overlays", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); PerformanceTimer perfTimer("overlays"); @@ -8986,6 +8997,38 @@ void Application::updateLoginDialogPosition() { } } +void Application::createAvatarInputsBar() { + const glm::vec3 LOCAL_POSITION { 0.0, 0.0, -1.0 }; + // DEFAULT_DPI / tablet scale percentage + const float DPI = 31.0f / (75.0f / 100.0f); + + EntityItemProperties properties; + properties.setType(EntityTypes::Web); + properties.setName("AvatarInputsBarEntity"); + properties.setSourceUrl(AVATAR_INPUTS_BAR_QML.toString()); + properties.setParentID(getMyAvatar()->getSelfID()); + properties.setParentJointIndex(getMyAvatar()->getJointIndex("_CAMERA_MATRIX")); + properties.setPosition(LOCAL_POSITION); + properties.setLocalRotation(Quaternions::IDENTITY); + //properties.setDimensions(LOGIN_DIMENSIONS); + properties.setPrimitiveMode(PrimitiveMode::SOLID); + properties.getGrab().setGrabbable(false); + properties.setIgnorePickIntersection(false); + properties.setAlpha(1.0f); + properties.setDPI(DPI); + properties.setVisible(true); + + auto entityScriptingInterface = DependencyManager::get(); + _avatarInputsBarID = entityScriptingInterface->addEntityInternal(properties, entity::HostType::LOCAL); +} + +void Application::destroyAvatarInputsBar() { + auto entityScriptingInterface = DependencyManager::get(); + if (!_avatarInputsBarID.isNull()) { + entityScriptingInterface->deleteEntity(_avatarInputsBarID); + } +} + bool Application::hasRiftControllers() { return PluginUtils::isOculusTouchControllerAvailable(); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 762ac9585a..99e57f1866 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -330,6 +330,9 @@ public: void createLoginDialog(); void updateLoginDialogPosition(); + void createAvatarInputsBar(); + void destroyAvatarInputsBar(); + // Check if a headset is connected bool hasRiftControllers(); bool hasViveControllers(); @@ -704,12 +707,14 @@ private: int _maxOctreePPS = DEFAULT_MAX_OCTREE_PPS; bool _interstitialModeEnabled{ false }; - bool _loginDialogPoppedUp = false; + bool _loginDialogPoppedUp{ false }; + bool _desktopRootItemCreated{ false }; bool _developerMenuVisible{ false }; QString _previousAvatarSkeletonModel; float _previousAvatarTargetScale; CameraMode _previousCameraMode; QUuid _loginDialogID; + QUuid _avatarInputsBarID; LoginStateManager _loginStateManager; quint64 _lastFaceTrackerUpdate; diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index bf43db3044..434688e474 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -224,10 +224,10 @@ void Audio::saveData() { } void Audio::loadData() { - _desktopMuted = _desktopMutedSetting.get(); - _hmdMuted = _hmdMutedSetting.get(); - _pttDesktop = _pttDesktopSetting.get(); - _pttHMD = _pttHMDSetting.get(); + setMutedDesktop(_desktopMutedSetting.get()); + setMutedHMD(_hmdMutedSetting.get()); + setPTTDesktop(_pttDesktopSetting.get()); + setPTTHMD(_pttHMDSetting.get()); } bool Audio::getPTTHMD() const { diff --git a/interface/src/ui/PrivacyShield.cpp b/interface/src/ui/PrivacyShield.cpp deleted file mode 100644 index 279c05ee2d..0000000000 --- a/interface/src/ui/PrivacyShield.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// -// PrivacyShield.cpp -// interface/src/ui -// -// Created by Wayne Chen on 2/27/19. -// Copyright 2019 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "PrivacyShield.h" - -#include -#include -#include -#include -#include -#include - -#include "Application.h" -#include "PathUtils.h" -#include "GLMHelpers.h" - -const int PRIVACY_SHIELD_VISIBLE_DURATION_MS = 3000; -const int PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS = 750; -const int PRIVACY_SHIELD_SOUND_RATE_LIMIT_MS = 15000; -const float PRIVACY_SHIELD_HEIGHT_SCALE = 0.15f; - -PrivacyShield::PrivacyShield() { - auto usersScriptingInterface = DependencyManager::get(); - //connect(usersScriptingInterface.data(), &UsersScriptingInterface::ignoreRadiusEnabledChanged, [this](bool enabled) { - // onPrivacyShieldToggled(enabled); - //}); - //connect(usersScriptingInterface.data(), &UsersScriptingInterface::enteredIgnoreRadius, this, &PrivacyShield::enteredIgnoreRadius); -} - -void PrivacyShield::createPrivacyShield() { - // Affects bubble height - //auto myAvatar = DependencyManager::get()->getMyAvatar(); - //auto avatarScale = myAvatar->getTargetScale(); - //auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - //auto avatarWorldPosition = myAvatar->getWorldPosition(); - //auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - //EntityItemProperties properties; - //properties.setName("Privacy-Shield"); - //properties.setModelURL(PathUtils::resourcesUrl("assets/models/Bubble-v14.fbx").toString()); - //properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - //properties.setPosition(glm::vec3(avatarWorldPosition.x, - // -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - //properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); - //properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - //properties.setVisible(false); - - //_localPrivacyShieldID = DependencyManager::get()->addEntityInternal(properties, entity::HostType::LOCAL); - //_bubbleActivateSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl() + "assets/sounds/bubble.wav"); - - //onPrivacyShieldToggled(DependencyManager::get()->getIgnoreRadiusEnabled(), true); -} - -void PrivacyShield::destroyPrivacyShield() { - DependencyManager::get()->deleteEntity(_localPrivacyShieldID); -} - -void PrivacyShield::update(float deltaTime) { - //if (_updateConnected) { - // auto now = usecTimestampNow(); - // auto delay = (now - _privacyShieldTimestamp); - // auto privacyShieldAlpha = 1.0 - (delay / PRIVACY_SHIELD_VISIBLE_DURATION_MS); - // if (privacyShieldAlpha > 0) { - // auto myAvatar = DependencyManager::get()->getMyAvatar(); - // auto avatarScale = myAvatar->getTargetScale(); - // auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - // auto avatarWorldPosition = myAvatar->getWorldPosition(); - // auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - // EntityItemProperties properties; - // properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - // properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); - // if (delay < PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS) { - // properties.setPosition(glm::vec3(avatarWorldPosition.x, - // (-((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * avatarScale * 2.0 + - // avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - // properties.setModelScale(glm::vec3(2.0, - // ((1 - ((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * - // (0.5 * (avatarScale + 1.0))), 2.0)); - // } else { - // properties.setPosition(glm::vec3(avatarWorldPosition.x, avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - // properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - // } - // DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); - // } - // else { - // hidePrivacyShield(); - // if (_updateConnected) { - // _updateConnected = false; - // } - // } - //} -} - -void PrivacyShield::enteredIgnoreRadius() { - showPrivacyShield(); - DependencyManager::get()->privacyShieldActivated(); -} - -void PrivacyShield::onPrivacyShieldToggled(bool enabled, bool doNotLog) { - if (!doNotLog) { - DependencyManager::get()->privacyShieldToggled(enabled); - } - if (enabled) { - showPrivacyShield(); - } else { - hidePrivacyShield(); - if (_updateConnected) { - _updateConnected = false; - } - } -} - -void PrivacyShield::showPrivacyShield() { - auto now = usecTimestampNow(); - auto myAvatar = DependencyManager::get()->getMyAvatar(); - auto avatarScale = myAvatar->getTargetScale(); - auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - auto avatarWorldPosition = myAvatar->getWorldPosition(); - auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - if (now - _lastPrivacyShieldSoundTimestamp >= PRIVACY_SHIELD_SOUND_RATE_LIMIT_MS) { - AudioInjectorOptions options; - options.position = avatarWorldPosition; - options.localOnly = true; - options.volume = 0.2f; - AudioInjector::playSoundAndDelete(_bubbleActivateSound, options); - _lastPrivacyShieldSoundTimestamp = now; - } - hidePrivacyShield(); - if (_updateConnected) { - _updateConnected = false; - } - - EntityItemProperties properties; - properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - properties.setPosition(glm::vec3(avatarWorldPosition.x, - -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - properties.setVisible(true); - - DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); - - _privacyShieldTimestamp = now; - _updateConnected = true; -} - -void PrivacyShield::hidePrivacyShield() { - EntityTreePointer entityTree = qApp->getEntities()->getTree(); - EntityItemPointer privacyShieldEntity = entityTree->findEntityByEntityItemID(EntityItemID(_localPrivacyShieldID)); - if (privacyShieldEntity) { - privacyShieldEntity->setVisible(false); - } -} diff --git a/interface/src/ui/PrivacyShield.h b/interface/src/ui/PrivacyShield.h deleted file mode 100644 index 5aecb661f7..0000000000 --- a/interface/src/ui/PrivacyShield.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// PrivacyShield.h -// interface/src/ui -// -// Created by Wayne Chen on 2/27/19. -// Copyright 2019 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#pragma once - -#include -#include -#include - -#include -#include - -class PrivacyShield : public QObject, public Dependency { - Q_OBJECT - SINGLETON_DEPENDENCY - -public: - PrivacyShield(); - void createPrivacyShield(); - void destroyPrivacyShield(); - - bool isVisible() const { return _visible; } - void update(float deltaTime); - -protected slots: - void enteredIgnoreRadius(); - void onPrivacyShieldToggled(bool enabled, bool doNotLog = false); - -private: - void showPrivacyShield(); - void hidePrivacyShield(); - - SharedSoundPointer _bubbleActivateSound; - QUuid _localPrivacyShieldID; - quint64 _privacyShieldTimestamp; - quint64 _lastPrivacyShieldSoundTimestamp; - bool _visible { false }; - bool _updateConnected { false }; -}; diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index e392680df9..bd7e79dffc 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -32,8 +32,7 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/firstPersonHMD.js", "system/tablet-ui/tabletUI.js", "system/emote.js", - "system/miniTablet.js", - "system/audioMuteOverlay.js" + "system/miniTablet.js" ]; var DEFAULT_SCRIPTS_SEPARATE = [ "system/controllers/controllerScripts.js", From d834c5aca1c7f7d98ff895f0e7356d50a876d998 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 14 Mar 2019 15:05:26 -0700 Subject: [PATCH 17/60] adding test script for creating avatar input bar --- scripts/defaultScripts.js | 3 +- scripts/system/createAvatarInputsBarEntity.js | 76 +++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 scripts/system/createAvatarInputsBarEntity.js diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index bd7e79dffc..0d9799a035 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -32,7 +32,8 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/firstPersonHMD.js", "system/tablet-ui/tabletUI.js", "system/emote.js", - "system/miniTablet.js" + "system/miniTablet.js", + "system/createAvatarInputsBarEntity.js" ]; var DEFAULT_SCRIPTS_SEPARATE = [ "system/controllers/controllerScripts.js", diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js new file mode 100644 index 0000000000..babf519035 --- /dev/null +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -0,0 +1,76 @@ +"use strict"; + +(function(){ + + var button; + var buttonName = "AVBAR"; + var onCreateAvatarInputsBarEntity = false; + var micBarEntity, bubbleIconEntity; + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + + function onClicked(){ + onCreateAvatarInputsBarEntity = !onCreateAvatarInputsBarEntity; + button.editProperties({isActive: onCreateAvatarInputsBarEntity}); + var micBarDimensions = {x: 0.036, y: 0.048, z: 0.3}; + var bubbleIconDimensions = {x: 0.036, y: 0.036, z: 0.3}; + var micBarLocalPosition = {x: (-(micBarDimensions.x / 2)) - 0.2, y: -0.125, z: -0.5}; + var bubbleIconLocalPosition = {x: (micBarDimensions.x * 1.2 / 2) - 0.2, y: ((micBarDimensions.y - bubbleIconDimensions.y) / 2 - 0.125), z: -0.5}; + if (onCreateAvatarInputsBarEntity) { + var props = { + type: "Web", + parentID: MyAvatar.SELF_ID, + parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), + localPosition: micBarLocalPosition, + localRotation: Quat.lookAtSimple(Camera.orientation, micBarLocalPosition), + sourceUrl: Script.resourcesPath() + "qml/hifi/audio/MicBarApplication.qml", + dimensions: micBarDimensions, + userData: { + grabbable: false + }, + }; + micBarEntity = Entities.addEntity(props, "local"); + var props = { + type: "Web", + parentID: MyAvatar.SELF_ID, + parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), + // y is 0.01 - (0.048 + 0.036) / 2 + // have 10% spacing separation between the entities + localPosition: bubbleIconLocalPosition, + localRotation: Quat.lookAtSimple(Camera.orientation, bubbleIconLocalPosition), + sourceUrl: Script.resourcesPath() + "qml/BubbleIcon.qml", + dimensions: bubbleIconDimensions, + userData: { + grabbable: false + }, + }; + bubbleIconEntity = Entities.addEntity(props, "local"); + console.log("creating entity"); + } else { + console.log("deleting entity"); + Entities.deleteEntity(micBarEntity); + Entities.deleteEntity(bubbleIconEntity); + } + }; + + function setup() { + button = tablet.addButton({ + icon: "icons/tablet-icons/edit-i.svg", + activeIcon: "icons/tablet-icons/edit-a.svg", + text: buttonName + }); + button.clicked.connect(onClicked); + }; + + setup(); + + Script.scriptEnding.connect(function() { + if (micBarEntity) { + Entities.deleteEntity(micBarEntity); + } + if (bubbleIconEntity) { + Entities.deleteEntity(bubbleIconEntity); + } + tablet.removeButton(button); + }); + +}()); From d063882d3747cb42d665f6b9a4d479dd5a3420a4 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 26 Feb 2019 18:14:56 -0800 Subject: [PATCH 18/60] adding user speaking level rotated vertically and muted symbol --- interface/resources/qml/hifi/audio/MicBar.qml | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index fba06ac987..6d428d9ab8 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -13,6 +13,7 @@ import QtQuick 2.5 import QtGraphicalEffects 1.0 import stylesUit 1.0 +import stylesUit 1.0 import TabletScriptingInterface 1.0 Rectangle { @@ -34,8 +35,8 @@ Rectangle { property bool standalone: false; property var dragTarget: null; - width: 240; - height: 50; + width: 44; + height: 44; radius: 5; @@ -48,8 +49,8 @@ Rectangle { // borders are painted over fill, so reduce the fill to fit inside the border Rectangle { color: standalone ? colors.fill : "#00000000"; - width: 236; - height: 46; + width: 40; + height: 40; radius: 5; @@ -98,7 +99,7 @@ Rectangle { readonly property string red: colors.muted; readonly property string fill: "#55000000"; readonly property string border: standalone ? "#80FFFFFF" : "#55FFFFFF"; - readonly property string icon: AudioScriptingInterface.muted ? muted : unmuted; + readonly property string icon: muted ? muted : unmuted; } Item { @@ -106,7 +107,6 @@ Rectangle { anchors { left: parent.left; - leftMargin: 5; verticalCenter: parent.verticalCenter; } @@ -125,11 +125,11 @@ Rectangle { source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; - width: 30; - height: 30; + width: 21; + height: 24; anchors { left: parent.left; - leftMargin: 5; + leftMargin: 7; top: parent.top; topMargin: 5; } @@ -146,20 +146,20 @@ Rectangle { Item { id: status; - readonly property string color: muted ? colors.muted : colors.unmuted; + readonly property string color: colors.muted; visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); anchors { left: parent.left; - leftMargin: 50; - verticalCenter: parent.verticalCenter; + top: parent.bottom + topMargin: 5 } - width: 170; + width: icon.width; height: 8 - Text { + RalewaySemiBold { anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter; @@ -197,11 +197,14 @@ Rectangle { Item { id: bar; - visible: !status.visible; + anchors { + right: parent.right; + rightMargin: 7; + verticalCenter: parent.verticalCenter; + } - anchors.fill: status; - - width: status.width; + width: 8; + height: 32; Rectangle { // base radius: 4; @@ -211,13 +214,12 @@ Rectangle { Rectangle { // mask id: mask; - width: gated ? 0 : parent.width * level; + height: parent.height * level; + width: parent.width; radius: 5; anchors { bottom: parent.bottom; bottomMargin: 0; - top: parent.top; - topMargin: 0; left: parent.left; leftMargin: 0; } @@ -227,10 +229,11 @@ Rectangle { anchors { fill: mask } source: mask start: Qt.point(0, 0); - end: Qt.point(170, 0); + end: Qt.point(0, bar.height); + rotation: 180 gradient: Gradient { GradientStop { - position: 0; + position: 0.0; color: colors.greenStart; } GradientStop { @@ -238,8 +241,8 @@ Rectangle { color: colors.greenEnd; } GradientStop { - position: 1; - color: colors.yellow; + position: 1.0; + color: colors.red; } } } From 8e8ceaac475e6affd5ca199b035be171db28b8d6 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 26 Feb 2019 18:19:23 -0800 Subject: [PATCH 19/60] moving file as MicBarApplication --- interface/resources/qml/hifi/audio/MicBar.qml | 65 +++++++++---------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index 6d428d9ab8..cad64b9b74 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -13,7 +13,6 @@ import QtQuick 2.5 import QtGraphicalEffects 1.0 import stylesUit 1.0 -import stylesUit 1.0 import TabletScriptingInterface 1.0 Rectangle { @@ -31,12 +30,12 @@ Rectangle { AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; }); AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; }); } - + property bool standalone: false; property var dragTarget: null; - width: 44; - height: 44; + width: 240; + height: 50; radius: 5; @@ -49,8 +48,8 @@ Rectangle { // borders are painted over fill, so reduce the fill to fit inside the border Rectangle { color: standalone ? colors.fill : "#00000000"; - width: 40; - height: 40; + width: 236; + height: 46; radius: 5; @@ -107,6 +106,7 @@ Rectangle { anchors { left: parent.left; + leftMargin: 5; verticalCenter: parent.verticalCenter; } @@ -125,11 +125,11 @@ Rectangle { source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; - width: 21; - height: 24; + width: 30; + height: 30; anchors { left: parent.left; - leftMargin: 7; + leftMargin: 5; top: parent.top; topMargin: 5; } @@ -146,20 +146,20 @@ Rectangle { Item { id: status; - readonly property string color: colors.muted; + readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted; visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); anchors { left: parent.left; - top: parent.bottom - topMargin: 5 + leftMargin: 50; + verticalCenter: parent.verticalCenter; } - width: icon.width; + width: 170; height: 8 - RalewaySemiBold { + Text { anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter; @@ -197,14 +197,11 @@ Rectangle { Item { id: bar; - anchors { - right: parent.right; - rightMargin: 7; - verticalCenter: parent.verticalCenter; - } + visible: !status.visible; - width: 8; - height: 32; + anchors.fill: status; + + width: status.width; Rectangle { // base radius: 4; @@ -214,12 +211,13 @@ Rectangle { Rectangle { // mask id: mask; - height: parent.height * level; - width: parent.width; + width: gated ? 0 : parent.width * level; radius: 5; anchors { bottom: parent.bottom; bottomMargin: 0; + top: parent.top; + topMargin: 0; left: parent.left; leftMargin: 0; } @@ -229,11 +227,10 @@ Rectangle { anchors { fill: mask } source: mask start: Qt.point(0, 0); - end: Qt.point(0, bar.height); - rotation: 180 + end: Qt.point(170, 0); gradient: Gradient { GradientStop { - position: 0.0; + position: 0; color: colors.greenStart; } GradientStop { @@ -241,17 +238,17 @@ Rectangle { color: colors.greenEnd; } GradientStop { - position: 1.0; - color: colors.red; + position: 1; + color: colors.yellow; } } } - + Rectangle { id: gatedIndicator; visible: gated && !AudioScriptingInterface.clipping - - radius: 4; + + radius: 4; width: 2 * radius; height: 2 * radius; color: "#0080FF"; @@ -260,12 +257,12 @@ Rectangle { verticalCenter: parent.verticalCenter; } } - + Rectangle { id: clippingIndicator; visible: AudioScriptingInterface.clipping - - radius: 4; + + radius: 4; width: 2 * radius; height: 2 * radius; color: colors.red; From db6bf46ee7deb17c6c0f5988b0f95f90ad84a912 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 27 Feb 2019 17:38:11 -0800 Subject: [PATCH 20/60] adding more opacity, cleanup --- interface/resources/qml/hifi/audio/MicBarApplication.qml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index bfac278ee4..592843467b 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -53,6 +53,14 @@ Rectangle { micBar.opacity = rectOpacity; } + onLevelChanged: { + var rectOpacity = AudioScriptingInterface.muted && (level >= userSpeakingLevel)? 0.9 : 0.3; + if (mouseArea.containsMouse) { + rectOpacity = 0.5; + } + opacity = rectOpacity; + } + color: "#00000000"; border { width: mouseArea.containsMouse || mouseArea.containsPress ? 2 : 0; From 3b6c0b5b18219a46c7c9baab95ccb3cf65497d46 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 27 Feb 2019 18:04:09 -0800 Subject: [PATCH 21/60] adding privacy shield files --- interface/src/ui/PrivacyShield.cpp | 12 ++++++++++++ interface/src/ui/PrivacyShield.h | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 interface/src/ui/PrivacyShield.cpp create mode 100644 interface/src/ui/PrivacyShield.h diff --git a/interface/src/ui/PrivacyShield.cpp b/interface/src/ui/PrivacyShield.cpp new file mode 100644 index 0000000000..e1035ee5bb --- /dev/null +++ b/interface/src/ui/PrivacyShield.cpp @@ -0,0 +1,12 @@ +// +// PrivacyShield.h +// interface/src/ui +// +// Created by Wayne Chen on 2/27/19. +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "PrivacyShield.cpp" diff --git a/interface/src/ui/PrivacyShield.h b/interface/src/ui/PrivacyShield.h new file mode 100644 index 0000000000..a609f2775b --- /dev/null +++ b/interface/src/ui/PrivacyShield.h @@ -0,0 +1,12 @@ +// +// PrivacyShield.h +// interface/src/ui +// +// Created by Wayne Chen on 2/27/19. +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#pragma once From 49c3dfa52c67ede93e7cc30f03a23022a55e00f5 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 27 Feb 2019 18:04:58 -0800 Subject: [PATCH 22/60] fixing typos --- interface/src/ui/PrivacyShield.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/PrivacyShield.cpp b/interface/src/ui/PrivacyShield.cpp index e1035ee5bb..12687afbea 100644 --- a/interface/src/ui/PrivacyShield.cpp +++ b/interface/src/ui/PrivacyShield.cpp @@ -1,5 +1,5 @@ // -// PrivacyShield.h +// PrivacyShield.cpp // interface/src/ui // // Created by Wayne Chen on 2/27/19. @@ -9,4 +9,4 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "PrivacyShield.cpp" +#include "PrivacyShield.h" From 48b4fe37b4ccb53ac35de6028377aa199bb23b65 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Feb 2019 15:50:13 -0800 Subject: [PATCH 23/60] don't display gated state --- interface/resources/qml/hifi/audio/MicBarApplication.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 592843467b..812e581fe1 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -54,8 +54,8 @@ Rectangle { } onLevelChanged: { - var rectOpacity = AudioScriptingInterface.muted && (level >= userSpeakingLevel)? 0.9 : 0.3; - if (mouseArea.containsMouse) { + var rectOpacity = muted && (level >= userSpeakingLevel) ? 0.9 : 0.3; + if (mouseArea.containsMouse && rectOpacity != 0.9) { rectOpacity = 0.5; } opacity = rectOpacity; From 20e181cd82f9b6d180617dad1ac8c05de7fca98f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Feb 2019 16:51:19 -0800 Subject: [PATCH 24/60] staging avatar inputs for ignore radius --- interface/src/Application.cpp | 10 ++ interface/src/ui/PrivacyShield.cpp | 147 +++++++++++++++++++++++++++++ interface/src/ui/PrivacyShield.h | 35 +++++++ 3 files changed, 192 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9fd0781eef..bd8107793a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -211,6 +211,7 @@ #include "ui/UpdateDialog.h" #include "ui/DomainConnectionModel.h" #include "ui/Keyboard.h" +#include "ui/PrivacyShield.h" #include "Util.h" #include "InterfaceParentFinder.h" #include "ui/OctreeStatsProvider.h" @@ -931,6 +932,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); + DependencyManager::set(); return previousSessionCrashed; } @@ -2670,6 +2672,9 @@ void Application::cleanupBeforeQuit() { nodeList->getPacketReceiver().setShouldDropPackets(true); } + // destroy privacy shield before entity shutdown. + DependencyManager::get()->destroyPrivacyShield(); + getEntities()->shutdown(); // tell the entities system we're shutting down, so it will stop running scripts // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) @@ -2748,6 +2753,7 @@ void Application::cleanupBeforeQuit() { DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); + DependencyManager::destroy(); DependencyManager::destroy(); qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete"; @@ -5549,6 +5555,8 @@ void Application::resumeAfterLoginDialogActionTaken() { menu->getMenu("Developer")->setVisible(_developerMenuVisible); _myCamera.setMode(_previousCameraMode); cameraModeChanged(); + + DependencyManager::get()->createPrivacyShield(); } void Application::loadAvatarScripts(const QVector& urls) { @@ -6507,6 +6515,8 @@ void Application::update(float deltaTime) { updateLoginDialogPosition(); } + DependencyManager::get()->update(deltaTime); + { PROFILE_RANGE_EX(app, "Overlays", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); PerformanceTimer perfTimer("overlays"); diff --git a/interface/src/ui/PrivacyShield.cpp b/interface/src/ui/PrivacyShield.cpp index 12687afbea..e8f61ff5bf 100644 --- a/interface/src/ui/PrivacyShield.cpp +++ b/interface/src/ui/PrivacyShield.cpp @@ -10,3 +10,150 @@ // #include "PrivacyShield.h" + +#include +#include +#include +#include +#include +#include + +#include "Application.h" +#include "PathUtils.h" +#include "GLMHelpers.h" + +const int PRIVACY_SHIELD_VISIBLE_DURATION_MS = 3000; +const int PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS = 750; +const int PRIVACY_SHIELD_SOUND_RATE_LIMIT_MS = 15000; +const float PRIVACY_SHIELD_HEIGHT_SCALE = 0.15f; + +PrivacyShield::PrivacyShield() { + auto usersScriptingInterface = DependencyManager::get(); + //connect(usersScriptingInterface.data(), &UsersScriptingInterface::ignoreRadiusEnabledChanged, [this](bool enabled) { + // onPrivacyShieldToggled(enabled); + //}); + //connect(usersScriptingInterface.data(), &UsersScriptingInterface::enteredIgnoreRadius, this, &PrivacyShield::enteredIgnoreRadius); +} + +void PrivacyShield::createPrivacyShield() { + // Affects bubble height + auto myAvatar = DependencyManager::get()->getMyAvatar(); + auto avatarScale = myAvatar->getTargetScale(); + auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); + auto avatarWorldPosition = myAvatar->getWorldPosition(); + auto avatarWorldOrientation = myAvatar->getWorldOrientation(); + EntityItemProperties properties; + properties.setName("Privacy-Shield"); + properties.setModelURL(PathUtils::resourcesUrl("assets/models/Bubble-v14.fbx").toString()); + properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); + properties.setPosition(glm::vec3(avatarWorldPosition.x, + -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); + properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); + properties.setVisible(false); + + _localPrivacyShieldID = DependencyManager::get()->addEntityInternal(properties, entity::HostType::LOCAL); + //_bubbleActivateSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl() + "assets/sounds/bubble.wav"); + + //onPrivacyShieldToggled(DependencyManager::get()->getIgnoreRadiusEnabled(), true); +} + +void PrivacyShield::destroyPrivacyShield() { + DependencyManager::get()->deleteEntity(_localPrivacyShieldID); +} + +void PrivacyShield::update(float deltaTime) { + if (_updateConnected) { + auto now = usecTimestampNow(); + auto delay = (now - _privacyShieldTimestamp); + auto privacyShieldAlpha = 1.0 - (delay / PRIVACY_SHIELD_VISIBLE_DURATION_MS); + if (privacyShieldAlpha > 0) { + auto myAvatar = DependencyManager::get()->getMyAvatar(); + auto avatarScale = myAvatar->getTargetScale(); + auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); + auto avatarWorldPosition = myAvatar->getWorldPosition(); + auto avatarWorldOrientation = myAvatar->getWorldOrientation(); + EntityItemProperties properties; + properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); + properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); + if (delay < PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS) { + properties.setPosition(glm::vec3(avatarWorldPosition.x, + (-((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * avatarScale * 2.0 + + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + properties.setModelScale(glm::vec3(2.0, + ((1 - ((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * + (0.5 * (avatarScale + 1.0))), 2.0)); + } else { + properties.setPosition(glm::vec3(avatarWorldPosition.x, avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); + } + DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); + } + else { + hidePrivacyShield(); + if (_updateConnected) { + _updateConnected = false; + } + } + } +} + +void PrivacyShield::enteredIgnoreRadius() { + showPrivacyShield(); + DependencyManager::get()->privacyShieldActivated(); +} + +void PrivacyShield::onPrivacyShieldToggled(bool enabled, bool doNotLog) { + if (!doNotLog) { + DependencyManager::get()->privacyShieldToggled(enabled); + } + if (enabled) { + showPrivacyShield(); + } else { + hidePrivacyShield(); + if (_updateConnected) { + _updateConnected = false; + } + } +} + +void PrivacyShield::showPrivacyShield() { + auto now = usecTimestampNow(); + auto myAvatar = DependencyManager::get()->getMyAvatar(); + auto avatarScale = myAvatar->getTargetScale(); + auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); + auto avatarWorldPosition = myAvatar->getWorldPosition(); + auto avatarWorldOrientation = myAvatar->getWorldOrientation(); + if (now - _lastPrivacyShieldSoundTimestamp >= PRIVACY_SHIELD_SOUND_RATE_LIMIT_MS) { + AudioInjectorOptions options; + options.position = avatarWorldPosition; + options.localOnly = true; + options.volume = 0.2f; + AudioInjector::playSoundAndDelete(_bubbleActivateSound, options); + _lastPrivacyShieldSoundTimestamp = now; + } + hidePrivacyShield(); + if (_updateConnected) { + _updateConnected = false; + } + + EntityItemProperties properties; + properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); + properties.setPosition(glm::vec3(avatarWorldPosition.x, + -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); + properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); + properties.setVisible(true); + + DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); + + _privacyShieldTimestamp = now; + _updateConnected = true; +} + +void PrivacyShield::hidePrivacyShield() { + EntityTreePointer entityTree = qApp->getEntities()->getTree(); + EntityItemPointer privacyShieldEntity = entityTree->findEntityByEntityItemID(EntityItemID(_localPrivacyShieldID)); + if (privacyShieldEntity) { + privacyShieldEntity->setVisible(false); + } +} diff --git a/interface/src/ui/PrivacyShield.h b/interface/src/ui/PrivacyShield.h index a609f2775b..5aecb661f7 100644 --- a/interface/src/ui/PrivacyShield.h +++ b/interface/src/ui/PrivacyShield.h @@ -10,3 +10,38 @@ // #pragma once + +#include +#include +#include + +#include +#include + +class PrivacyShield : public QObject, public Dependency { + Q_OBJECT + SINGLETON_DEPENDENCY + +public: + PrivacyShield(); + void createPrivacyShield(); + void destroyPrivacyShield(); + + bool isVisible() const { return _visible; } + void update(float deltaTime); + +protected slots: + void enteredIgnoreRadius(); + void onPrivacyShieldToggled(bool enabled, bool doNotLog = false); + +private: + void showPrivacyShield(); + void hidePrivacyShield(); + + SharedSoundPointer _bubbleActivateSound; + QUuid _localPrivacyShieldID; + quint64 _privacyShieldTimestamp; + quint64 _lastPrivacyShieldSoundTimestamp; + bool _visible { false }; + bool _updateConnected { false }; +}; From 84fcd50b3b3e0b3231b6fe80cc56b19af8895515 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 26 Feb 2019 18:14:56 -0800 Subject: [PATCH 25/60] adding user speaking level rotated vertically and muted symbol --- interface/resources/qml/hifi/audio/MicBar.qml | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index cad64b9b74..4734da8771 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -13,6 +13,7 @@ import QtQuick 2.5 import QtGraphicalEffects 1.0 import stylesUit 1.0 +import stylesUit 1.0 import TabletScriptingInterface 1.0 Rectangle { @@ -34,8 +35,8 @@ Rectangle { property bool standalone: false; property var dragTarget: null; - width: 240; - height: 50; + width: 44; + height: 44; radius: 5; @@ -48,8 +49,8 @@ Rectangle { // borders are painted over fill, so reduce the fill to fit inside the border Rectangle { color: standalone ? colors.fill : "#00000000"; - width: 236; - height: 46; + width: 40; + height: 40; radius: 5; @@ -106,7 +107,6 @@ Rectangle { anchors { left: parent.left; - leftMargin: 5; verticalCenter: parent.verticalCenter; } @@ -125,11 +125,11 @@ Rectangle { source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; - width: 30; - height: 30; + width: 21; + height: 24; anchors { left: parent.left; - leftMargin: 5; + leftMargin: 7; top: parent.top; topMargin: 5; } @@ -146,20 +146,20 @@ Rectangle { Item { id: status; - readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted; + readonly property string color: colors.muted; visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); anchors { left: parent.left; - leftMargin: 50; - verticalCenter: parent.verticalCenter; + top: parent.bottom + topMargin: 5 } - width: 170; + width: icon.width; height: 8 - Text { + RalewaySemiBold { anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter; @@ -197,11 +197,14 @@ Rectangle { Item { id: bar; - visible: !status.visible; + anchors { + right: parent.right; + rightMargin: 7; + verticalCenter: parent.verticalCenter; + } - anchors.fill: status; - - width: status.width; + width: 8; + height: 32; Rectangle { // base radius: 4; @@ -211,13 +214,12 @@ Rectangle { Rectangle { // mask id: mask; - width: gated ? 0 : parent.width * level; + height: parent.height * level; + width: parent.width; radius: 5; anchors { bottom: parent.bottom; bottomMargin: 0; - top: parent.top; - topMargin: 0; left: parent.left; leftMargin: 0; } @@ -227,10 +229,11 @@ Rectangle { anchors { fill: mask } source: mask start: Qt.point(0, 0); - end: Qt.point(170, 0); + end: Qt.point(0, bar.height); + rotation: 180 gradient: Gradient { GradientStop { - position: 0; + position: 0.0; color: colors.greenStart; } GradientStop { @@ -238,8 +241,8 @@ Rectangle { color: colors.greenEnd; } GradientStop { - position: 1; - color: colors.yellow; + position: 1.0; + color: colors.red; } } } From cd7b6e7ed08a6ac6d8c02a582ecb69c25b5c2e18 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 26 Feb 2019 18:19:23 -0800 Subject: [PATCH 26/60] moving file as MicBarApplication --- interface/resources/qml/hifi/audio/MicBar.qml | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index 4734da8771..cad64b9b74 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -13,7 +13,6 @@ import QtQuick 2.5 import QtGraphicalEffects 1.0 import stylesUit 1.0 -import stylesUit 1.0 import TabletScriptingInterface 1.0 Rectangle { @@ -35,8 +34,8 @@ Rectangle { property bool standalone: false; property var dragTarget: null; - width: 44; - height: 44; + width: 240; + height: 50; radius: 5; @@ -49,8 +48,8 @@ Rectangle { // borders are painted over fill, so reduce the fill to fit inside the border Rectangle { color: standalone ? colors.fill : "#00000000"; - width: 40; - height: 40; + width: 236; + height: 46; radius: 5; @@ -107,6 +106,7 @@ Rectangle { anchors { left: parent.left; + leftMargin: 5; verticalCenter: parent.verticalCenter; } @@ -125,11 +125,11 @@ Rectangle { source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; - width: 21; - height: 24; + width: 30; + height: 30; anchors { left: parent.left; - leftMargin: 7; + leftMargin: 5; top: parent.top; topMargin: 5; } @@ -146,20 +146,20 @@ Rectangle { Item { id: status; - readonly property string color: colors.muted; + readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted; visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); anchors { left: parent.left; - top: parent.bottom - topMargin: 5 + leftMargin: 50; + verticalCenter: parent.verticalCenter; } - width: icon.width; + width: 170; height: 8 - RalewaySemiBold { + Text { anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter; @@ -197,14 +197,11 @@ Rectangle { Item { id: bar; - anchors { - right: parent.right; - rightMargin: 7; - verticalCenter: parent.verticalCenter; - } + visible: !status.visible; - width: 8; - height: 32; + anchors.fill: status; + + width: status.width; Rectangle { // base radius: 4; @@ -214,12 +211,13 @@ Rectangle { Rectangle { // mask id: mask; - height: parent.height * level; - width: parent.width; + width: gated ? 0 : parent.width * level; radius: 5; anchors { bottom: parent.bottom; bottomMargin: 0; + top: parent.top; + topMargin: 0; left: parent.left; leftMargin: 0; } @@ -229,11 +227,10 @@ Rectangle { anchors { fill: mask } source: mask start: Qt.point(0, 0); - end: Qt.point(0, bar.height); - rotation: 180 + end: Qt.point(170, 0); gradient: Gradient { GradientStop { - position: 0.0; + position: 0; color: colors.greenStart; } GradientStop { @@ -241,8 +238,8 @@ Rectangle { color: colors.greenEnd; } GradientStop { - position: 1.0; - color: colors.red; + position: 1; + color: colors.yellow; } } } From f80f4b2fd4db894e2b0f07d48a8ba9b98bdd2d0f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 27 Feb 2019 14:54:13 -0800 Subject: [PATCH 27/60] adding working bubble icon --- interface/src/ui/AvatarInputs.cpp | 2 -- interface/src/ui/AvatarInputs.h | 23 ----------------------- 2 files changed, 25 deletions(-) diff --git a/interface/src/ui/AvatarInputs.cpp b/interface/src/ui/AvatarInputs.cpp index 80604f354b..352db37a78 100644 --- a/interface/src/ui/AvatarInputs.cpp +++ b/interface/src/ui/AvatarInputs.cpp @@ -32,9 +32,7 @@ AvatarInputs* AvatarInputs::getInstance() { AvatarInputs::AvatarInputs(QObject* parent) : QObject(parent) { _showAudioTools = showAudioToolsSetting.get(); auto nodeList = DependencyManager::get(); - auto usersScriptingInterface = DependencyManager::get(); connect(nodeList.data(), &NodeList::ignoreRadiusEnabledChanged, this, &AvatarInputs::ignoreRadiusEnabledChanged); - connect(usersScriptingInterface.data(), &UsersScriptingInterface::enteredIgnoreRadius, this, &AvatarInputs::enteredIgnoreRadiusChanged); } #define AI_UPDATE(name, src) \ diff --git a/interface/src/ui/AvatarInputs.h b/interface/src/ui/AvatarInputs.h index f53adc1749..1feb054147 100644 --- a/interface/src/ui/AvatarInputs.h +++ b/interface/src/ui/AvatarInputs.h @@ -43,7 +43,6 @@ class AvatarInputs : public QObject { Q_PROPERTY(bool showAudioTools READ showAudioTools WRITE setShowAudioTools NOTIFY showAudioToolsChanged) Q_PROPERTY(bool ignoreRadiusEnabled READ getIgnoreRadiusEnabled NOTIFY ignoreRadiusEnabledChanged) - //Q_PROPERTY(bool enteredIgnoreRadius READ getEnteredIgnoreRadius NOTIFY enteredIgnoreRadiusChanged) public: static AvatarInputs* getInstance(); @@ -59,7 +58,6 @@ public: void update(); bool showAudioTools() const { return _showAudioTools; } bool getIgnoreRadiusEnabled() const; - //bool getEnteredIgnoreRadius() const; public slots: @@ -97,20 +95,6 @@ signals: */ void showAudioToolsChanged(bool show); - /**jsdoc - * @function AvatarInputs.avatarEnteredIgnoreRadius - * @param {QUuid} avatarID - * @returns {Signal} - */ - void avatarEnteredIgnoreRadius(QUuid avatarID); - - /**jsdoc - * @function AvatarInputs.avatarLeftIgnoreRadius - * @param {QUuid} avatarID - * @returns {Signal} - */ - void avatarLeftIgnoreRadius(QUuid avatarID); - /**jsdoc * @function AvatarInputs.ignoreRadiusEnabledChanged * @param {boolean} enabled @@ -118,13 +102,6 @@ signals: */ void ignoreRadiusEnabledChanged(bool enabled); - /**jsdoc - * @function AvatarInputs.enteredIgnoreRadiusChanged - * @param {boolean} enabled - * @returns {Signal} - */ - void enteredIgnoreRadiusChanged(); - protected: /**jsdoc From e5133d6f4d3fbccba641e088a2be5e03fd91ef43 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Feb 2019 16:48:17 -0800 Subject: [PATCH 28/60] fixing muted text --- interface/resources/icons/tablet-icons/mic.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/icons/tablet-icons/mic.svg b/interface/resources/icons/tablet-icons/mic.svg index 30b46d18dd..c961351b14 100644 --- a/interface/resources/icons/tablet-icons/mic.svg +++ b/interface/resources/icons/tablet-icons/mic.svg @@ -59,4 +59,4 @@ d="m 27.9,20.9 c 0,0 0,-3.6 0,-3.8 0,-0.7 -0.6,-1.2 -1.3,-1.2 -0.7,0 -1.2,0.6 -1.2,1.3 0,0.2 0,3.4 0,3.7 0,2.6 -2.4,4.8 -5.3,4.8 -2.9,0 -5.3,-2.1 -5.3,-4.8 0,-0.3 0,-3.5 0,-3.8 0,-0.7 -0.5,-1.3 -1.2,-1.3 -0.7,0 -1.3,0.5 -1.3,1.2 0,0.2 0,3.9 0,3.9 0,3.6 2.9,6.6 6.6,7.2 l 0,2.4 -3.1,0 c -0.7,0 -1.3,0.6 -1.3,1.3 0,0.7 0.6,1.3 1.3,1.3 l 8.8,0 c 0.7,0 1.3,-0.6 1.3,-1.3 0,-0.7 -0.6,-1.3 -1.3,-1.3 l -3.2,0 0,-2.4 c 3.6,-0.5 6.5,-3.5 6.5,-7.2 z" id="path6952" inkscape:connector-curvature="0" - style="fill:#ffffff" /> \ No newline at end of file + style="fill:#ffffff" /> From 8e6913dde1ae7b3803a829b041263cf698b1418d Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Feb 2019 16:51:19 -0800 Subject: [PATCH 29/60] staging avatar inputs for ignore radius --- interface/src/ui/AvatarInputs.cpp | 2 ++ interface/src/ui/AvatarInputs.h | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/interface/src/ui/AvatarInputs.cpp b/interface/src/ui/AvatarInputs.cpp index 352db37a78..80604f354b 100644 --- a/interface/src/ui/AvatarInputs.cpp +++ b/interface/src/ui/AvatarInputs.cpp @@ -32,7 +32,9 @@ AvatarInputs* AvatarInputs::getInstance() { AvatarInputs::AvatarInputs(QObject* parent) : QObject(parent) { _showAudioTools = showAudioToolsSetting.get(); auto nodeList = DependencyManager::get(); + auto usersScriptingInterface = DependencyManager::get(); connect(nodeList.data(), &NodeList::ignoreRadiusEnabledChanged, this, &AvatarInputs::ignoreRadiusEnabledChanged); + connect(usersScriptingInterface.data(), &UsersScriptingInterface::enteredIgnoreRadius, this, &AvatarInputs::enteredIgnoreRadiusChanged); } #define AI_UPDATE(name, src) \ diff --git a/interface/src/ui/AvatarInputs.h b/interface/src/ui/AvatarInputs.h index 1feb054147..f53adc1749 100644 --- a/interface/src/ui/AvatarInputs.h +++ b/interface/src/ui/AvatarInputs.h @@ -43,6 +43,7 @@ class AvatarInputs : public QObject { Q_PROPERTY(bool showAudioTools READ showAudioTools WRITE setShowAudioTools NOTIFY showAudioToolsChanged) Q_PROPERTY(bool ignoreRadiusEnabled READ getIgnoreRadiusEnabled NOTIFY ignoreRadiusEnabledChanged) + //Q_PROPERTY(bool enteredIgnoreRadius READ getEnteredIgnoreRadius NOTIFY enteredIgnoreRadiusChanged) public: static AvatarInputs* getInstance(); @@ -58,6 +59,7 @@ public: void update(); bool showAudioTools() const { return _showAudioTools; } bool getIgnoreRadiusEnabled() const; + //bool getEnteredIgnoreRadius() const; public slots: @@ -95,6 +97,20 @@ signals: */ void showAudioToolsChanged(bool show); + /**jsdoc + * @function AvatarInputs.avatarEnteredIgnoreRadius + * @param {QUuid} avatarID + * @returns {Signal} + */ + void avatarEnteredIgnoreRadius(QUuid avatarID); + + /**jsdoc + * @function AvatarInputs.avatarLeftIgnoreRadius + * @param {QUuid} avatarID + * @returns {Signal} + */ + void avatarLeftIgnoreRadius(QUuid avatarID); + /**jsdoc * @function AvatarInputs.ignoreRadiusEnabledChanged * @param {boolean} enabled @@ -102,6 +118,13 @@ signals: */ void ignoreRadiusEnabledChanged(bool enabled); + /**jsdoc + * @function AvatarInputs.enteredIgnoreRadiusChanged + * @param {boolean} enabled + * @returns {Signal} + */ + void enteredIgnoreRadiusChanged(); + protected: /**jsdoc From d0116abc5271fccc15ae8e6f9371faf92120332c Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 14 Mar 2019 10:28:18 -0700 Subject: [PATCH 30/60] separating out bubble icon qml - adding support for transparency --- interface/resources/qml/hifi/audio/MicBar.qml | 16 +++---- .../qml/hifi/audio/MicBarApplication.qml | 6 ++- interface/src/Application.cpp | 10 ---- interface/src/ui/PrivacyShield.h | 47 ------------------- scripts/defaultScripts.js | 3 +- 5 files changed, 13 insertions(+), 69 deletions(-) delete mode 100644 interface/src/ui/PrivacyShield.h diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index cad64b9b74..fb52f8bc5e 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -30,7 +30,7 @@ Rectangle { AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; }); AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; }); } - + property bool standalone: false; property var dragTarget: null; @@ -146,7 +146,7 @@ Rectangle { Item { id: status; - readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted; + readonly property string color: muted ? colors.muted : colors.unmuted; visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); @@ -243,12 +243,12 @@ Rectangle { } } } - + Rectangle { id: gatedIndicator; visible: gated && !AudioScriptingInterface.clipping - - radius: 4; + + radius: 4; width: 2 * radius; height: 2 * radius; color: "#0080FF"; @@ -257,12 +257,12 @@ Rectangle { verticalCenter: parent.verticalCenter; } } - + Rectangle { id: clippingIndicator; visible: AudioScriptingInterface.clipping - - radius: 4; + + radius: 4; width: 2 * radius; height: 2 * radius; color: colors.red; diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 812e581fe1..f2839aee1a 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -55,10 +55,12 @@ Rectangle { onLevelChanged: { var rectOpacity = muted && (level >= userSpeakingLevel) ? 0.9 : 0.3; - if (mouseArea.containsMouse && rectOpacity != 0.9) { + if (pushToTalk && !pushingToTalk) { + rectOpacity = (level >= userSpeakingLevel) ? 0.9 : 0.7; + } else if (mouseArea.containsMouse && rectOpacity != 0.9) { rectOpacity = 0.5; } - opacity = rectOpacity; + micBar.opacity = rectOpacity; } color: "#00000000"; diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index bd8107793a..9fd0781eef 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -211,7 +211,6 @@ #include "ui/UpdateDialog.h" #include "ui/DomainConnectionModel.h" #include "ui/Keyboard.h" -#include "ui/PrivacyShield.h" #include "Util.h" #include "InterfaceParentFinder.h" #include "ui/OctreeStatsProvider.h" @@ -932,7 +931,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); - DependencyManager::set(); return previousSessionCrashed; } @@ -2672,9 +2670,6 @@ void Application::cleanupBeforeQuit() { nodeList->getPacketReceiver().setShouldDropPackets(true); } - // destroy privacy shield before entity shutdown. - DependencyManager::get()->destroyPrivacyShield(); - getEntities()->shutdown(); // tell the entities system we're shutting down, so it will stop running scripts // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) @@ -2753,7 +2748,6 @@ void Application::cleanupBeforeQuit() { DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); - DependencyManager::destroy(); DependencyManager::destroy(); qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete"; @@ -5555,8 +5549,6 @@ void Application::resumeAfterLoginDialogActionTaken() { menu->getMenu("Developer")->setVisible(_developerMenuVisible); _myCamera.setMode(_previousCameraMode); cameraModeChanged(); - - DependencyManager::get()->createPrivacyShield(); } void Application::loadAvatarScripts(const QVector& urls) { @@ -6515,8 +6507,6 @@ void Application::update(float deltaTime) { updateLoginDialogPosition(); } - DependencyManager::get()->update(deltaTime); - { PROFILE_RANGE_EX(app, "Overlays", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); PerformanceTimer perfTimer("overlays"); diff --git a/interface/src/ui/PrivacyShield.h b/interface/src/ui/PrivacyShield.h deleted file mode 100644 index 5aecb661f7..0000000000 --- a/interface/src/ui/PrivacyShield.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// PrivacyShield.h -// interface/src/ui -// -// Created by Wayne Chen on 2/27/19. -// Copyright 2019 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#pragma once - -#include -#include -#include - -#include -#include - -class PrivacyShield : public QObject, public Dependency { - Q_OBJECT - SINGLETON_DEPENDENCY - -public: - PrivacyShield(); - void createPrivacyShield(); - void destroyPrivacyShield(); - - bool isVisible() const { return _visible; } - void update(float deltaTime); - -protected slots: - void enteredIgnoreRadius(); - void onPrivacyShieldToggled(bool enabled, bool doNotLog = false); - -private: - void showPrivacyShield(); - void hidePrivacyShield(); - - SharedSoundPointer _bubbleActivateSound; - QUuid _localPrivacyShieldID; - quint64 _privacyShieldTimestamp; - quint64 _lastPrivacyShieldSoundTimestamp; - bool _visible { false }; - bool _updateConnected { false }; -}; diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 0d9799a035..bd7e79dffc 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -32,8 +32,7 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/firstPersonHMD.js", "system/tablet-ui/tabletUI.js", "system/emote.js", - "system/miniTablet.js", - "system/createAvatarInputsBarEntity.js" + "system/miniTablet.js" ]; var DEFAULT_SCRIPTS_SEPARATE = [ "system/controllers/controllerScripts.js", From 87de95c63b47bf23b24cc71662db9e6dc7ddfbdd Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 14 Mar 2019 15:05:26 -0700 Subject: [PATCH 31/60] adding test script for creating avatar input bar --- scripts/defaultScripts.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index bd7e79dffc..0d9799a035 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -32,7 +32,8 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/firstPersonHMD.js", "system/tablet-ui/tabletUI.js", "system/emote.js", - "system/miniTablet.js" + "system/miniTablet.js", + "system/createAvatarInputsBarEntity.js" ]; var DEFAULT_SCRIPTS_SEPARATE = [ "system/controllers/controllerScripts.js", From 44ed9e607b24a59892ec7b066772ea85adae9998 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 19 Mar 2019 09:33:38 -0700 Subject: [PATCH 32/60] cancelling out roll and pitch --- scripts/system/createAvatarInputsBarEntity.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js index babf519035..b32085da86 100644 --- a/scripts/system/createAvatarInputsBarEntity.js +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -21,7 +21,7 @@ parentID: MyAvatar.SELF_ID, parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), localPosition: micBarLocalPosition, - localRotation: Quat.lookAtSimple(Camera.orientation, micBarLocalPosition), + localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, micBarLocalPosition)), sourceUrl: Script.resourcesPath() + "qml/hifi/audio/MicBarApplication.qml", dimensions: micBarDimensions, userData: { @@ -36,7 +36,7 @@ // y is 0.01 - (0.048 + 0.036) / 2 // have 10% spacing separation between the entities localPosition: bubbleIconLocalPosition, - localRotation: Quat.lookAtSimple(Camera.orientation, bubbleIconLocalPosition), + localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, bubbleIconLocalPosition)), sourceUrl: Script.resourcesPath() + "qml/BubbleIcon.qml", dimensions: bubbleIconDimensions, userData: { @@ -44,9 +44,7 @@ }, }; bubbleIconEntity = Entities.addEntity(props, "local"); - console.log("creating entity"); } else { - console.log("deleting entity"); Entities.deleteEntity(micBarEntity); Entities.deleteEntity(bubbleIconEntity); } From ee1a14505a67f2cbbfe10ba5d7f59063a252eb2f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 19 Mar 2019 09:44:08 -0700 Subject: [PATCH 33/60] adding constants, removing entity creation in cpp --- interface/src/Application.cpp | 18 +++++++++--------- scripts/system/createAvatarInputsBarEntity.js | 16 ++++++++++------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9fd0781eef..5b0c379c64 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1298,15 +1298,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(this, &Application::activeDisplayPluginChanged, this, [&](){ #if !defined(Q_OS_ANDROID) if (!getLoginDialogPoppedUp() && _desktopRootItemCreated) { - if (isHMDMode()) { - createAvatarInputsBar(); - auto offscreenUi = getOffscreenUI(); - offscreenUi->hide(AVATAR_INPUTS_BAR_QML.toString()); - } else { - destroyAvatarInputsBar(); - auto offscreenUi = getOffscreenUI(); - offscreenUi->show(AVATAR_INPUTS_BAR_QML.toString(), "AvatarInputsBar"); - } +/* if (isHMDMode()) {*/ + //createAvatarInputsBar(); + //auto offscreenUi = getOffscreenUI(); + //offscreenUi->hide(AVATAR_INPUTS_BAR_QML.toString()); + //} else { + //destroyAvatarInputsBar(); + //auto offscreenUi = getOffscreenUI(); + //offscreenUi->show(AVATAR_INPUTS_BAR_QML.toString(), "AvatarInputsBar"); + /*}*/ } #endif }); diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js index b32085da86..8c4d78d32d 100644 --- a/scripts/system/createAvatarInputsBarEntity.js +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -11,10 +11,16 @@ function onClicked(){ onCreateAvatarInputsBarEntity = !onCreateAvatarInputsBarEntity; button.editProperties({isActive: onCreateAvatarInputsBarEntity}); - var micBarDimensions = {x: 0.036, y: 0.048, z: 0.3}; - var bubbleIconDimensions = {x: 0.036, y: 0.036, z: 0.3}; - var micBarLocalPosition = {x: (-(micBarDimensions.x / 2)) - 0.2, y: -0.125, z: -0.5}; - var bubbleIconLocalPosition = {x: (micBarDimensions.x * 1.2 / 2) - 0.2, y: ((micBarDimensions.y - bubbleIconDimensions.y) / 2 - 0.125), z: -0.5}; + // QML NATURAL DIMENSIONS + var MIC_BAR_DIMENSIONS = {x: 0.036, y: 0.048, z: 0.3}; + var BUBBLE_ICON_DIMENSIONS = {x: 0.036, y: 0.036, z: 0.3}; + // CONSTANTS + var LOCAL_POSITION_X_OFFSET = -0.2; + var LOCAL_POSITION_Y_OFFSET = -0.125; + var LOCAL_POSITION_Z_OFFSET = -0.5; + // POSITIONS + var micBarLocalPosition = {x: (-(micBarDimensions.x / 2)) + LOCAL_POSITION_X_OFFSET, y: LOCAL_POSITION_Y_OFFSET, z: LOCAL_POSITION_Z_OFFSET}; + var bubbleIconLocalPosition = {x: (micBarDimensions.x * 1.2 / 2) + LOCAL_POSITION_X_OFFSET, y: ((micBarDimensions.y - bubbleIconDimensions.y) / 2 + LOCAL_POSITION_Y_OFFSET), z: LOCAL_POSITION_Z_OFFSET}; if (onCreateAvatarInputsBarEntity) { var props = { type: "Web", @@ -33,8 +39,6 @@ type: "Web", parentID: MyAvatar.SELF_ID, parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), - // y is 0.01 - (0.048 + 0.036) / 2 - // have 10% spacing separation between the entities localPosition: bubbleIconLocalPosition, localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, bubbleIconLocalPosition)), sourceUrl: Script.resourcesPath() + "qml/BubbleIcon.qml", From 4cbe8cd4d1b39989c4a3c5a81d1a9b445f1f41f6 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 19 Mar 2019 10:55:00 -0700 Subject: [PATCH 34/60] Adding alpha to entities to enable transparency --- scripts/system/createAvatarInputsBarEntity.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js index 8c4d78d32d..c14bf433d7 100644 --- a/scripts/system/createAvatarInputsBarEntity.js +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -29,6 +29,7 @@ localPosition: micBarLocalPosition, localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, micBarLocalPosition)), sourceUrl: Script.resourcesPath() + "qml/hifi/audio/MicBarApplication.qml", + alpha: 0.9, dimensions: micBarDimensions, userData: { grabbable: false @@ -42,6 +43,7 @@ localPosition: bubbleIconLocalPosition, localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, bubbleIconLocalPosition)), sourceUrl: Script.resourcesPath() + "qml/BubbleIcon.qml", + alpha: 0.9, dimensions: bubbleIconDimensions, userData: { grabbable: false From b6ebdb5315fdc24f18255182175acdbd9791f104 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 19 Mar 2019 13:49:59 -0700 Subject: [PATCH 35/60] alpha to max value of detecting transparency --- scripts/system/createAvatarInputsBarEntity.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js index c14bf433d7..c64c8e35c5 100644 --- a/scripts/system/createAvatarInputsBarEntity.js +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -29,7 +29,8 @@ localPosition: micBarLocalPosition, localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, micBarLocalPosition)), sourceUrl: Script.resourcesPath() + "qml/hifi/audio/MicBarApplication.qml", - alpha: 0.9, + // cutoff alpha for detecting transparency + alpha: 0.98, dimensions: micBarDimensions, userData: { grabbable: false @@ -43,7 +44,8 @@ localPosition: bubbleIconLocalPosition, localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, bubbleIconLocalPosition)), sourceUrl: Script.resourcesPath() + "qml/BubbleIcon.qml", - alpha: 0.9, + // cutoff alpha for detecting transparency + alpha: 0.98, dimensions: bubbleIconDimensions, userData: { grabbable: false From cb715c3e55ee84f8ab2047853f34f7e031b1bf24 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 20 Mar 2019 09:39:14 -0700 Subject: [PATCH 36/60] fixing typos --- scripts/system/createAvatarInputsBarEntity.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js index c64c8e35c5..064bfa33e8 100644 --- a/scripts/system/createAvatarInputsBarEntity.js +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -19,8 +19,8 @@ var LOCAL_POSITION_Y_OFFSET = -0.125; var LOCAL_POSITION_Z_OFFSET = -0.5; // POSITIONS - var micBarLocalPosition = {x: (-(micBarDimensions.x / 2)) + LOCAL_POSITION_X_OFFSET, y: LOCAL_POSITION_Y_OFFSET, z: LOCAL_POSITION_Z_OFFSET}; - var bubbleIconLocalPosition = {x: (micBarDimensions.x * 1.2 / 2) + LOCAL_POSITION_X_OFFSET, y: ((micBarDimensions.y - bubbleIconDimensions.y) / 2 + LOCAL_POSITION_Y_OFFSET), z: LOCAL_POSITION_Z_OFFSET}; + var micBarLocalPosition = {x: (-(MIC_BAR_DIMENSIONS.x / 2)) + LOCAL_POSITION_X_OFFSET, y: LOCAL_POSITION_Y_OFFSET, z: LOCAL_POSITION_Z_OFFSET}; + var bubbleIconLocalPosition = {x: (MIC_BAR_DIMENSIONS.x * 1.2 / 2) + LOCAL_POSITION_X_OFFSET, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + LOCAL_POSITION_Y_OFFSET), z: LOCAL_POSITION_Z_OFFSET}; if (onCreateAvatarInputsBarEntity) { var props = { type: "Web", @@ -31,7 +31,7 @@ sourceUrl: Script.resourcesPath() + "qml/hifi/audio/MicBarApplication.qml", // cutoff alpha for detecting transparency alpha: 0.98, - dimensions: micBarDimensions, + dimensions: MIC_BAR_DIMENSIONS, userData: { grabbable: false }, @@ -46,7 +46,7 @@ sourceUrl: Script.resourcesPath() + "qml/BubbleIcon.qml", // cutoff alpha for detecting transparency alpha: 0.98, - dimensions: bubbleIconDimensions, + dimensions: BUBBLE_ICON_DIMENSIONS, userData: { grabbable: false }, From 6cf8b06c6daa06c18e64b36af439ab6b64b45112 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 20 Mar 2019 17:39:32 -0700 Subject: [PATCH 37/60] more wip on adding qml to adjusting ui position --- .../qml/hifi/EditAvatarInputsBar.qml | 37 +++++++++++++++++++ scripts/system/createAvatarInputsBarEntity.js | 13 +++++++ 2 files changed, 50 insertions(+) create mode 100644 interface/resources/qml/hifi/EditAvatarInputsBar.qml diff --git a/interface/resources/qml/hifi/EditAvatarInputsBar.qml b/interface/resources/qml/hifi/EditAvatarInputsBar.qml new file mode 100644 index 0000000000..d9ba3a6fcc --- /dev/null +++ b/interface/resources/qml/hifi/EditAvatarInputsBar.qml @@ -0,0 +1,37 @@ +// +// EditAvatarInputsBar.qml +// qml/hifi +// +// Audio setup +// +// Created by Wayne Chen on 3/20/2019 +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +import stylesUit 1.0 +import controlsUit 1.0 as HifiControlsUit +import "../windows" + +Rectangle { + id: editRect + + HifiConstants { id: hifi; } + + color: hifi.colors.baseGray; + + signal sendToScript(var message); + function emitSendToScript(message) { + sendToScript(message); + } + + function fromScript(message) { + } + +} diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js index 064bfa33e8..0b8fde4bb3 100644 --- a/scripts/system/createAvatarInputsBarEntity.js +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -1,12 +1,20 @@ "use strict"; (function(){ + var AppUi = Script.require("appUi"); + + var ui; var button; var buttonName = "AVBAR"; var onCreateAvatarInputsBarEntity = false; var micBarEntity, bubbleIconEntity; var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + var AVATAR_INPUTS_EDIT_QML_SOURCE = "hifi/EditAvatarInputsBar.qml"; + + function fromQml(message) { + console.log("message from QML: " + JSON.stringify(message)); + }; function onClicked(){ onCreateAvatarInputsBarEntity = !onCreateAvatarInputsBarEntity; @@ -24,6 +32,7 @@ if (onCreateAvatarInputsBarEntity) { var props = { type: "Web", + name: "AvatarInputsMicBarEntity", parentID: MyAvatar.SELF_ID, parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), localPosition: micBarLocalPosition, @@ -32,6 +41,7 @@ // cutoff alpha for detecting transparency alpha: 0.98, dimensions: MIC_BAR_DIMENSIONS, + drawInFront: true, userData: { grabbable: false }, @@ -39,6 +49,7 @@ micBarEntity = Entities.addEntity(props, "local"); var props = { type: "Web", + name: "AvatarInputsBubbleIconEntity", parentID: MyAvatar.SELF_ID, parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), localPosition: bubbleIconLocalPosition, @@ -47,11 +58,13 @@ // cutoff alpha for detecting transparency alpha: 0.98, dimensions: BUBBLE_ICON_DIMENSIONS, + drawInFront: true, userData: { grabbable: false }, }; bubbleIconEntity = Entities.addEntity(props, "local"); + tablet.loadQMLSource(AVATAR_INPUTS_EDIT_QML_SOURCE); } else { Entities.deleteEntity(micBarEntity); Entities.deleteEntity(bubbleIconEntity); From 584fa1f17b1c8b98c8b9d9324b2ab51fe0982a50 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 20 Mar 2019 18:07:50 -0700 Subject: [PATCH 38/60] more wip --- .../qml/hifi/EditAvatarInputsBar.qml | 83 +++++++++++++++++++ scripts/system/createAvatarInputsBarEntity.js | 17 ++-- 2 files changed, 95 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/hifi/EditAvatarInputsBar.qml b/interface/resources/qml/hifi/EditAvatarInputsBar.qml index d9ba3a6fcc..d34537bb0e 100644 --- a/interface/resources/qml/hifi/EditAvatarInputsBar.qml +++ b/interface/resources/qml/hifi/EditAvatarInputsBar.qml @@ -28,10 +28,93 @@ Rectangle { signal sendToScript(var message); function emitSendToScript(message) { + console.log("sending to script"); + console.log(JSON.stringify(message)); sendToScript(message); } function fromScript(message) { } + RalewayRegular { + id: title; + color: hifi.colors.white; + text: qsTr("Avatar Inputs Persistent UI Settings") + size: 20 + font.bold: true + anchors { + top: parent.top + left: parent.left + leftMargin: (parent.width - width) / 2 + } + } + + HifiControlsUit.Slider { + id: xSlider + anchors { + top: title.bottom + topMargin: 50 + left: parent.left + } + label: "X OFFSET" + maximumValue: 1.0 + minimumValue: -1.0 + stepSize: 0.05 + value: -0.2 + width: 300 + onValueChanged: { + emitSendToScript({ + "method": "reposition", + "x": value + }); + } + } + + HifiControlsUit.Slider { + id: ySlider + anchors { + top: xSlider.bottom + topMargin: 50 + left: parent.left + } + label: "Y OFFSET" + maximumValue: 1.0 + minimumValue: -1.0 + stepSize: 0.05 + value: -0.125 + width: 300 + onValueChanged: { + emitSendToScript({ + "method": "reposition", + "y": value + }); + } + } + + HifiControlsUit.Slider { + anchors { + top: ySlider.bottom + topMargin: 50 + left: parent.left + } + label: "Y OFFSET" + maximumValue: 0.0 + minimumValue: -1.0 + stepSize: 0.05 + value: -0.5 + width: 300 + onValueChanged: { + emitSendToScript({ + "method": "reposition", + "z": value + }); + } + } + + HifiControlsUit.Button { + id: setVisibleButton + } + + HifiControlsUit.Button { + } } diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js index 0b8fde4bb3..5ffba2c029 100644 --- a/scripts/system/createAvatarInputsBarEntity.js +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -13,7 +13,7 @@ var AVATAR_INPUTS_EDIT_QML_SOURCE = "hifi/EditAvatarInputsBar.qml"; function fromQml(message) { - console.log("message from QML: " + JSON.stringify(message)); + print("message from QML: " + JSON.stringify(message)); }; function onClicked(){ @@ -72,10 +72,17 @@ }; function setup() { - button = tablet.addButton({ - icon: "icons/tablet-icons/edit-i.svg", - activeIcon: "icons/tablet-icons/edit-a.svg", - text: buttonName + // button = tablet.addButton({ + // icon: "icons/tablet-icons/edit-i.svg", + // activeIcon: "icons/tablet-icons/edit-a.svg", + // text: buttonName + // }); + ui = new AppUi({ + buttonName: "AVBAR", + home: Script.resourcesPath() + "qml/hifi/EditAvatarInputsBar.qml", + onMessage: fromQml, + // normalButton: "icons/tablet-icons/avatar-i.svg", + // activeButton: "icons/tablet-icons/avatar-a.svg", }); button.clicked.connect(onClicked); }; From 554a144b0efc43ed435fae9c2011502dddc4cfc4 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 20 Mar 2019 21:55:36 -0700 Subject: [PATCH 39/60] adding tool to change avatar inputs properties --- .../qml/hifi/EditAvatarInputsBar.qml | 38 +++- scripts/system/createAvatarInputsBarEntity.js | 175 ++++++++++-------- 2 files changed, 138 insertions(+), 75 deletions(-) diff --git a/interface/resources/qml/hifi/EditAvatarInputsBar.qml b/interface/resources/qml/hifi/EditAvatarInputsBar.qml index d34537bb0e..bbf3652a92 100644 --- a/interface/resources/qml/hifi/EditAvatarInputsBar.qml +++ b/interface/resources/qml/hifi/EditAvatarInputsBar.qml @@ -55,6 +55,7 @@ Rectangle { top: title.bottom topMargin: 50 left: parent.left + leftMargin: 20 } label: "X OFFSET" maximumValue: 1.0 @@ -76,6 +77,7 @@ Rectangle { top: xSlider.bottom topMargin: 50 left: parent.left + leftMargin: 20 } label: "Y OFFSET" maximumValue: 1.0 @@ -92,12 +94,14 @@ Rectangle { } HifiControlsUit.Slider { + id: zSlider anchors { top: ySlider.bottom topMargin: 50 left: parent.left + leftMargin: 20 } - label: "Y OFFSET" + label: "Z OFFSET" maximumValue: 0.0 minimumValue: -1.0 stepSize: 0.05 @@ -112,9 +116,39 @@ Rectangle { } HifiControlsUit.Button { - id: setVisibleButton + id: setVisibleButton; + text: setVisible ? "SET INVISIBLE" : "SET VISIBLE"; + width: 300; + property bool setVisible: true; + anchors { + top: zSlider.bottom + topMargin: 50 + left: parent.left + leftMargin: 20 + } + onClicked: { + setVisible = !setVisible; + emitSendToScript({ + "method": "setVisible", + "visible": setVisible + }); + } } HifiControlsUit.Button { + id: printButton; + text: "PRINT POSITIONS"; + width: 300; + anchors { + top: setVisibleButton.bottom + topMargin: 50 + left: parent.left + leftMargin: 20 + } + onClicked: { + emitSendToScript({ + "method": "print", + }); + } } } diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js index 5ffba2c029..35c50416ed 100644 --- a/scripts/system/createAvatarInputsBarEntity.js +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -5,98 +5,127 @@ var ui; - var button; - var buttonName = "AVBAR"; var onCreateAvatarInputsBarEntity = false; var micBarEntity, bubbleIconEntity; var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var AVATAR_INPUTS_EDIT_QML_SOURCE = "hifi/EditAvatarInputsBar.qml"; - function fromQml(message) { - print("message from QML: " + JSON.stringify(message)); - }; + // QML NATURAL DIMENSIONS + var MIC_BAR_DIMENSIONS = {x: 0.036, y: 0.048, z: 0.3}; + var BUBBLE_ICON_DIMENSIONS = {x: 0.036, y: 0.036, z: 0.3}; + // CONSTANTS + var LOCAL_POSITION_X_OFFSET = -0.2; + var LOCAL_POSITION_Y_OFFSET = -0.125; + var LOCAL_POSITION_Z_OFFSET = -0.5; - function onClicked(){ - onCreateAvatarInputsBarEntity = !onCreateAvatarInputsBarEntity; - button.editProperties({isActive: onCreateAvatarInputsBarEntity}); - // QML NATURAL DIMENSIONS - var MIC_BAR_DIMENSIONS = {x: 0.036, y: 0.048, z: 0.3}; - var BUBBLE_ICON_DIMENSIONS = {x: 0.036, y: 0.036, z: 0.3}; - // CONSTANTS - var LOCAL_POSITION_X_OFFSET = -0.2; - var LOCAL_POSITION_Y_OFFSET = -0.125; - var LOCAL_POSITION_Z_OFFSET = -0.5; - // POSITIONS - var micBarLocalPosition = {x: (-(MIC_BAR_DIMENSIONS.x / 2)) + LOCAL_POSITION_X_OFFSET, y: LOCAL_POSITION_Y_OFFSET, z: LOCAL_POSITION_Z_OFFSET}; - var bubbleIconLocalPosition = {x: (MIC_BAR_DIMENSIONS.x * 1.2 / 2) + LOCAL_POSITION_X_OFFSET, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + LOCAL_POSITION_Y_OFFSET), z: LOCAL_POSITION_Z_OFFSET}; - if (onCreateAvatarInputsBarEntity) { - var props = { - type: "Web", - name: "AvatarInputsMicBarEntity", - parentID: MyAvatar.SELF_ID, - parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), - localPosition: micBarLocalPosition, - localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, micBarLocalPosition)), - sourceUrl: Script.resourcesPath() + "qml/hifi/audio/MicBarApplication.qml", - // cutoff alpha for detecting transparency - alpha: 0.98, - dimensions: MIC_BAR_DIMENSIONS, - drawInFront: true, - userData: { - grabbable: false - }, + function fromQml(message) { + if (message.method === "reposition") { + var micBarLocalPosition = Entities.getEntityProperties(micBarEntity).localPosition; + var bubbleIconLocalPosition = Entities.getEntityProperties(bubbleIconEntity).localPosition; + var newMicBarLocalPosition, newBubbleIconLocalPosition; + if (message.x !== undefined) { + newMicBarLocalPosition = { x: -((MIC_BAR_DIMENSIONS.x) / 2) - message.x, y: micBarLocalPosition.y, z: micBarLocalPosition.z }; + newBubbleIconLocalPosition = { x: ((MIC_BAR_DIMENSIONS.x) * 1.2 / 2) - message.x, y: bubbleIconLocalPosition.y, z: bubbleIconLocalPosition.z }; + } else if (message.y !== undefined) { + newMicBarLocalPosition = { x: micBarLocalPosition.x, y: message.y, z: micBarLocalPosition.z }; + newBubbleIconLocalPosition = { x: bubbleIconLocalPosition.x, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + message.y), z: bubbleIconLocalPosition.z }; + } else if (message.z !== undefined) { + newMicBarLocalPosition = { x: micBarLocalPosition.x, y: micBarLocalPosition.y, z: message.z }; + newBubbleIconLocalPosition = { x: bubbleIconLocalPosition.x, y: bubbleIconLocalPosition.y, z: message.z }; + } + var micBarProps = { + localPosition: newMicBarLocalPosition }; - micBarEntity = Entities.addEntity(props, "local"); - var props = { - type: "Web", - name: "AvatarInputsBubbleIconEntity", - parentID: MyAvatar.SELF_ID, - parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), - localPosition: bubbleIconLocalPosition, - localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, bubbleIconLocalPosition)), - sourceUrl: Script.resourcesPath() + "qml/BubbleIcon.qml", - // cutoff alpha for detecting transparency - alpha: 0.98, - dimensions: BUBBLE_ICON_DIMENSIONS, - drawInFront: true, - userData: { - grabbable: false - }, + var bubbleIconProps = { + localPosition: newBubbleIconLocalPosition }; - bubbleIconEntity = Entities.addEntity(props, "local"); - tablet.loadQMLSource(AVATAR_INPUTS_EDIT_QML_SOURCE); - } else { + + Entities.editEntity(micBarEntity, micBarProps); + Entities.editEntity(bubbleIconEntity, bubbleIconProps); + } else if (message.method === "setVisible") { + if (message.visible !== undefined) { + var props = { + visible: message.visible + }; + Entities.editEntity(micBarEntity, props); + Entities.editEntity(bubbleIconEntity, props); + } + } else if (message.method === "print") { + // prints the local position into the hifi log. + var micBarLocalPosition = Entities.getEntityProperties(micBarEntity).localPosition; + var bubbleIconLocalPosition = Entities.getEntityProperties(bubbleIconEntity).localPosition; + console.log("mic bar local position is at " + JSON.stringify(micBarLocalPosition)); + console.log("bubble icon local position is at " + JSON.stringify(bubbleIconLocalPosition)); + } else if (message.method === "destroy") { + console.log("destroying"); Entities.deleteEntity(micBarEntity); Entities.deleteEntity(bubbleIconEntity); } }; - function setup() { - // button = tablet.addButton({ - // icon: "icons/tablet-icons/edit-i.svg", - // activeIcon: "icons/tablet-icons/edit-a.svg", - // text: buttonName - // }); - ui = new AppUi({ - buttonName: "AVBAR", - home: Script.resourcesPath() + "qml/hifi/EditAvatarInputsBar.qml", - onMessage: fromQml, - // normalButton: "icons/tablet-icons/avatar-i.svg", - // activeButton: "icons/tablet-icons/avatar-a.svg", - }); - button.clicked.connect(onClicked); + function createEntities(){ + // POSITIONS + var micBarLocalPosition = {x: (-(MIC_BAR_DIMENSIONS.x / 2)) + LOCAL_POSITION_X_OFFSET, y: LOCAL_POSITION_Y_OFFSET, z: LOCAL_POSITION_Z_OFFSET}; + var bubbleIconLocalPosition = {x: (MIC_BAR_DIMENSIONS.x * 1.2 / 2) + LOCAL_POSITION_X_OFFSET, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + LOCAL_POSITION_Y_OFFSET), z: LOCAL_POSITION_Z_OFFSET}; + var props = { + type: "Web", + name: "AvatarInputsMicBarEntity", + parentID: MyAvatar.SELF_ID, + parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), + localPosition: micBarLocalPosition, + localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, micBarLocalPosition)), + sourceUrl: Script.resourcesPath() + "qml/hifi/audio/MicBarApplication.qml", + // cutoff alpha for detecting transparency + alpha: 0.98, + dimensions: MIC_BAR_DIMENSIONS, + drawInFront: true, + userData: { + grabbable: false + }, + }; + micBarEntity = Entities.addEntity(props, "local"); + var props = { + type: "Web", + name: "AvatarInputsBubbleIconEntity", + parentID: MyAvatar.SELF_ID, + parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), + localPosition: bubbleIconLocalPosition, + localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, bubbleIconLocalPosition)), + sourceUrl: Script.resourcesPath() + "qml/BubbleIcon.qml", + // cutoff alpha for detecting transparency + alpha: 0.98, + dimensions: BUBBLE_ICON_DIMENSIONS, + drawInFront: true, + userData: { + grabbable: false + }, + }; + bubbleIconEntity = Entities.addEntity(props, "local"); + tablet.loadQMLSource(AVATAR_INPUTS_EDIT_QML_SOURCE); }; - - setup(); - - Script.scriptEnding.connect(function() { + function cleanup() { if (micBarEntity) { Entities.deleteEntity(micBarEntity); } if (bubbleIconEntity) { Entities.deleteEntity(bubbleIconEntity); } - tablet.removeButton(button); - }); + }; + + function setup() { + ui = new AppUi({ + buttonName: "AVBAR", + home: Script.resourcesPath() + "qml/hifi/EditAvatarInputsBar.qml", + onMessage: fromQml, + onOpened: createEntities, + onClosed: cleanup, + // normalButton: "icons/tablet-icons/avatar-i.svg", + // activeButton: "icons/tablet-icons/avatar-a.svg", + }); + }; + + setup(); + + Script.scriptEnding.connect(cleanup); }()); From 1f71a291a5fe968f6b35dd1e8accc1876044d4c9 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 21 Mar 2019 08:38:31 -0700 Subject: [PATCH 40/60] displaying offset values --- .../qml/hifi/EditAvatarInputsBar.qml | 8 +++--- scripts/system/createAvatarInputsBarEntity.js | 25 +++++++++++-------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/interface/resources/qml/hifi/EditAvatarInputsBar.qml b/interface/resources/qml/hifi/EditAvatarInputsBar.qml index bbf3652a92..b27b0c8db2 100644 --- a/interface/resources/qml/hifi/EditAvatarInputsBar.qml +++ b/interface/resources/qml/hifi/EditAvatarInputsBar.qml @@ -28,8 +28,6 @@ Rectangle { signal sendToScript(var message); function emitSendToScript(message) { - console.log("sending to script"); - console.log(JSON.stringify(message)); sendToScript(message); } @@ -57,7 +55,7 @@ Rectangle { left: parent.left leftMargin: 20 } - label: "X OFFSET" + label: "X OFFSET: " + value.toFixed(2); maximumValue: 1.0 minimumValue: -1.0 stepSize: 0.05 @@ -79,7 +77,7 @@ Rectangle { left: parent.left leftMargin: 20 } - label: "Y OFFSET" + label: "Y OFFSET: " + value.toFixed(2); maximumValue: 1.0 minimumValue: -1.0 stepSize: 0.05 @@ -101,7 +99,7 @@ Rectangle { left: parent.left leftMargin: 20 } - label: "Z OFFSET" + label: "Z OFFSET: " + value.toFixed(2); maximumValue: 0.0 minimumValue: -1.0 stepSize: 0.05 diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js index 35c50416ed..500f8563fb 100644 --- a/scripts/system/createAvatarInputsBarEntity.js +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -6,13 +6,17 @@ var ui; var onCreateAvatarInputsBarEntity = false; - var micBarEntity, bubbleIconEntity; + var micBarEntity = null; + var bubbleIconEntity = null; var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var AVATAR_INPUTS_EDIT_QML_SOURCE = "hifi/EditAvatarInputsBar.qml"; // QML NATURAL DIMENSIONS var MIC_BAR_DIMENSIONS = {x: 0.036, y: 0.048, z: 0.3}; var BUBBLE_ICON_DIMENSIONS = {x: 0.036, y: 0.036, z: 0.3}; + // ENTITY NAMES + var MIC_BAR_NAME = "AvatarInputsMicBarEntity"; + var BUBBLE_ICON_NAME = "AvatarInputsBubbleIconEntity"; // CONSTANTS var LOCAL_POSITION_X_OFFSET = -0.2; var LOCAL_POSITION_Y_OFFSET = -0.125; @@ -56,20 +60,19 @@ var bubbleIconLocalPosition = Entities.getEntityProperties(bubbleIconEntity).localPosition; console.log("mic bar local position is at " + JSON.stringify(micBarLocalPosition)); console.log("bubble icon local position is at " + JSON.stringify(bubbleIconLocalPosition)); - } else if (message.method === "destroy") { - console.log("destroying"); - Entities.deleteEntity(micBarEntity); - Entities.deleteEntity(bubbleIconEntity); } }; - function createEntities(){ + function createEntities() { + if (micBarEntity != null && bubbleIconEntity != null) { + return; + } // POSITIONS var micBarLocalPosition = {x: (-(MIC_BAR_DIMENSIONS.x / 2)) + LOCAL_POSITION_X_OFFSET, y: LOCAL_POSITION_Y_OFFSET, z: LOCAL_POSITION_Z_OFFSET}; var bubbleIconLocalPosition = {x: (MIC_BAR_DIMENSIONS.x * 1.2 / 2) + LOCAL_POSITION_X_OFFSET, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + LOCAL_POSITION_Y_OFFSET), z: LOCAL_POSITION_Z_OFFSET}; var props = { type: "Web", - name: "AvatarInputsMicBarEntity", + name: MIC_BAR_NAME, parentID: MyAvatar.SELF_ID, parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), localPosition: micBarLocalPosition, @@ -86,7 +89,7 @@ micBarEntity = Entities.addEntity(props, "local"); var props = { type: "Web", - name: "AvatarInputsBubbleIconEntity", + name: BUBBLE_ICON_NAME, parentID: MyAvatar.SELF_ID, parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), localPosition: bubbleIconLocalPosition, @@ -118,9 +121,9 @@ home: Script.resourcesPath() + "qml/hifi/EditAvatarInputsBar.qml", onMessage: fromQml, onOpened: createEntities, - onClosed: cleanup, - // normalButton: "icons/tablet-icons/avatar-i.svg", - // activeButton: "icons/tablet-icons/avatar-a.svg", + // onClosed: cleanup, + normalButton: "icons/tablet-icons/edit-i.svg", + activeButton: "icons/tablet-icons/edit-a.svg", }); }; From 7b5deb692c7aff78675cb9a4239a1446b8026ed7 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 21 Mar 2019 09:57:31 -0700 Subject: [PATCH 41/60] fixing x value change --- scripts/system/createAvatarInputsBarEntity.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/system/createAvatarInputsBarEntity.js index 500f8563fb..deb0cfdd89 100644 --- a/scripts/system/createAvatarInputsBarEntity.js +++ b/scripts/system/createAvatarInputsBarEntity.js @@ -11,9 +11,11 @@ var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var AVATAR_INPUTS_EDIT_QML_SOURCE = "hifi/EditAvatarInputsBar.qml"; + // DPI + var ENTITY_DPI = 60.0; // QML NATURAL DIMENSIONS - var MIC_BAR_DIMENSIONS = {x: 0.036, y: 0.048, z: 0.3}; - var BUBBLE_ICON_DIMENSIONS = {x: 0.036, y: 0.036, z: 0.3}; + var MIC_BAR_DIMENSIONS = Vec3.multiply(30.0 / ENTITY_DPI, {x: 0.036, y: 0.048, z: 0.3}); + var BUBBLE_ICON_DIMENSIONS = Vec3.multiply(30.0 / ENTITY_DPI, {x: 0.036, y: 0.036, z: 0.3}); // ENTITY NAMES var MIC_BAR_NAME = "AvatarInputsMicBarEntity"; var BUBBLE_ICON_NAME = "AvatarInputsBubbleIconEntity"; @@ -28,8 +30,8 @@ var bubbleIconLocalPosition = Entities.getEntityProperties(bubbleIconEntity).localPosition; var newMicBarLocalPosition, newBubbleIconLocalPosition; if (message.x !== undefined) { - newMicBarLocalPosition = { x: -((MIC_BAR_DIMENSIONS.x) / 2) - message.x, y: micBarLocalPosition.y, z: micBarLocalPosition.z }; - newBubbleIconLocalPosition = { x: ((MIC_BAR_DIMENSIONS.x) * 1.2 / 2) - message.x, y: bubbleIconLocalPosition.y, z: bubbleIconLocalPosition.z }; + newMicBarLocalPosition = { x: -((MIC_BAR_DIMENSIONS.x) / 2) + message.x, y: micBarLocalPosition.y, z: micBarLocalPosition.z }; + newBubbleIconLocalPosition = { x: ((MIC_BAR_DIMENSIONS.x) * 1.2 / 2) + message.x, y: bubbleIconLocalPosition.y, z: bubbleIconLocalPosition.z }; } else if (message.y !== undefined) { newMicBarLocalPosition = { x: micBarLocalPosition.x, y: message.y, z: micBarLocalPosition.z }; newBubbleIconLocalPosition = { x: bubbleIconLocalPosition.x, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + message.y), z: bubbleIconLocalPosition.z }; @@ -81,6 +83,7 @@ // cutoff alpha for detecting transparency alpha: 0.98, dimensions: MIC_BAR_DIMENSIONS, + dpi: ENTITY_DPI, drawInFront: true, userData: { grabbable: false @@ -98,6 +101,7 @@ // cutoff alpha for detecting transparency alpha: 0.98, dimensions: BUBBLE_ICON_DIMENSIONS, + dpi: ENTITY_DPI, drawInFront: true, userData: { grabbable: false From 0edbf12fa373dfb415aa8ed0f0d45a009fd8409d Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 22 Mar 2019 15:26:57 -0700 Subject: [PATCH 42/60] removing extra onLevelChanged --- .../qml/hifi/audio/MicBarApplication.qml | 10 -- interface/src/ui/PrivacyShield.cpp | 159 ------------------ 2 files changed, 169 deletions(-) delete mode 100644 interface/src/ui/PrivacyShield.cpp diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index f2839aee1a..bfac278ee4 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -53,16 +53,6 @@ Rectangle { micBar.opacity = rectOpacity; } - onLevelChanged: { - var rectOpacity = muted && (level >= userSpeakingLevel) ? 0.9 : 0.3; - if (pushToTalk && !pushingToTalk) { - rectOpacity = (level >= userSpeakingLevel) ? 0.9 : 0.7; - } else if (mouseArea.containsMouse && rectOpacity != 0.9) { - rectOpacity = 0.5; - } - micBar.opacity = rectOpacity; - } - color: "#00000000"; border { width: mouseArea.containsMouse || mouseArea.containsPress ? 2 : 0; diff --git a/interface/src/ui/PrivacyShield.cpp b/interface/src/ui/PrivacyShield.cpp deleted file mode 100644 index e8f61ff5bf..0000000000 --- a/interface/src/ui/PrivacyShield.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// -// PrivacyShield.cpp -// interface/src/ui -// -// Created by Wayne Chen on 2/27/19. -// Copyright 2019 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "PrivacyShield.h" - -#include -#include -#include -#include -#include -#include - -#include "Application.h" -#include "PathUtils.h" -#include "GLMHelpers.h" - -const int PRIVACY_SHIELD_VISIBLE_DURATION_MS = 3000; -const int PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS = 750; -const int PRIVACY_SHIELD_SOUND_RATE_LIMIT_MS = 15000; -const float PRIVACY_SHIELD_HEIGHT_SCALE = 0.15f; - -PrivacyShield::PrivacyShield() { - auto usersScriptingInterface = DependencyManager::get(); - //connect(usersScriptingInterface.data(), &UsersScriptingInterface::ignoreRadiusEnabledChanged, [this](bool enabled) { - // onPrivacyShieldToggled(enabled); - //}); - //connect(usersScriptingInterface.data(), &UsersScriptingInterface::enteredIgnoreRadius, this, &PrivacyShield::enteredIgnoreRadius); -} - -void PrivacyShield::createPrivacyShield() { - // Affects bubble height - auto myAvatar = DependencyManager::get()->getMyAvatar(); - auto avatarScale = myAvatar->getTargetScale(); - auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - auto avatarWorldPosition = myAvatar->getWorldPosition(); - auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - EntityItemProperties properties; - properties.setName("Privacy-Shield"); - properties.setModelURL(PathUtils::resourcesUrl("assets/models/Bubble-v14.fbx").toString()); - properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - properties.setPosition(glm::vec3(avatarWorldPosition.x, - -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); - properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - properties.setVisible(false); - - _localPrivacyShieldID = DependencyManager::get()->addEntityInternal(properties, entity::HostType::LOCAL); - //_bubbleActivateSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl() + "assets/sounds/bubble.wav"); - - //onPrivacyShieldToggled(DependencyManager::get()->getIgnoreRadiusEnabled(), true); -} - -void PrivacyShield::destroyPrivacyShield() { - DependencyManager::get()->deleteEntity(_localPrivacyShieldID); -} - -void PrivacyShield::update(float deltaTime) { - if (_updateConnected) { - auto now = usecTimestampNow(); - auto delay = (now - _privacyShieldTimestamp); - auto privacyShieldAlpha = 1.0 - (delay / PRIVACY_SHIELD_VISIBLE_DURATION_MS); - if (privacyShieldAlpha > 0) { - auto myAvatar = DependencyManager::get()->getMyAvatar(); - auto avatarScale = myAvatar->getTargetScale(); - auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - auto avatarWorldPosition = myAvatar->getWorldPosition(); - auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - EntityItemProperties properties; - properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); - if (delay < PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS) { - properties.setPosition(glm::vec3(avatarWorldPosition.x, - (-((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * avatarScale * 2.0 + - avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - properties.setModelScale(glm::vec3(2.0, - ((1 - ((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * - (0.5 * (avatarScale + 1.0))), 2.0)); - } else { - properties.setPosition(glm::vec3(avatarWorldPosition.x, avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - } - DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); - } - else { - hidePrivacyShield(); - if (_updateConnected) { - _updateConnected = false; - } - } - } -} - -void PrivacyShield::enteredIgnoreRadius() { - showPrivacyShield(); - DependencyManager::get()->privacyShieldActivated(); -} - -void PrivacyShield::onPrivacyShieldToggled(bool enabled, bool doNotLog) { - if (!doNotLog) { - DependencyManager::get()->privacyShieldToggled(enabled); - } - if (enabled) { - showPrivacyShield(); - } else { - hidePrivacyShield(); - if (_updateConnected) { - _updateConnected = false; - } - } -} - -void PrivacyShield::showPrivacyShield() { - auto now = usecTimestampNow(); - auto myAvatar = DependencyManager::get()->getMyAvatar(); - auto avatarScale = myAvatar->getTargetScale(); - auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - auto avatarWorldPosition = myAvatar->getWorldPosition(); - auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - if (now - _lastPrivacyShieldSoundTimestamp >= PRIVACY_SHIELD_SOUND_RATE_LIMIT_MS) { - AudioInjectorOptions options; - options.position = avatarWorldPosition; - options.localOnly = true; - options.volume = 0.2f; - AudioInjector::playSoundAndDelete(_bubbleActivateSound, options); - _lastPrivacyShieldSoundTimestamp = now; - } - hidePrivacyShield(); - if (_updateConnected) { - _updateConnected = false; - } - - EntityItemProperties properties; - properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - properties.setPosition(glm::vec3(avatarWorldPosition.x, - -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - properties.setVisible(true); - - DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); - - _privacyShieldTimestamp = now; - _updateConnected = true; -} - -void PrivacyShield::hidePrivacyShield() { - EntityTreePointer entityTree = qApp->getEntities()->getTree(); - EntityItemPointer privacyShieldEntity = entityTree->findEntityByEntityItemID(EntityItemID(_localPrivacyShieldID)); - if (privacyShieldEntity) { - privacyShieldEntity->setVisible(false); - } -} From 390ce9bb26951a825942e6589af8f0ef0e66d491 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 22 Mar 2019 15:34:06 -0700 Subject: [PATCH 43/60] wip for getting AvatarInputsBar to switch accordingly --- interface/resources/qml/AvatarInputsBar.qml | 21 ++++++++++++++----- interface/resources/qml/BubbleIcon.qml | 14 +++++++++++-- interface/resources/qml/hifi/audio/MicBar.qml | 15 ++++++------- .../qml/hifi/audio/MicBarApplication.qml | 15 ++++++------- .../resources/qml/hifi/tablet/TabletHome.qml | 2 +- interface/src/Application.cpp | 4 ++-- scripts/defaultScripts.js | 3 +-- .../createAvatarInputsBarEntity.js | 0 scripts/system/away.js | 4 ++-- 9 files changed, 50 insertions(+), 28 deletions(-) rename scripts/{system => developer}/createAvatarInputsBarEntity.js (100%) diff --git a/interface/resources/qml/AvatarInputsBar.qml b/interface/resources/qml/AvatarInputsBar.qml index dfff103aa0..adeb74242d 100644 --- a/interface/resources/qml/AvatarInputsBar.qml +++ b/interface/resources/qml/AvatarInputsBar.qml @@ -18,20 +18,31 @@ Item { id: root; objectName: "AvatarInputsBar" property int modality: Qt.NonModal - readonly property bool ignoreRadiusEnabled: AvatarInputs.ignoreRadiusEnabled - width: audio.width; - height: audio.height; + readonly property bool ignoreRadiusEnabled: AvatarInputs.ignoreRadiusEnabled; + width: HMD.active ? audio.width : audioApplication.width; + height: HMD.active ? audio.height : audioApplication.height; x: 10; y: 5; readonly property bool shouldReposition: true; - HifiAudio.MicBarApplication { + HifiAudio.MicBar { id: audio; - visible: AvatarInputs.showAudioTools; + visible: AvatarInputs.showAudioTools && HMD.active; + standalone: true; + dragTarget: parent; + } + + HifiAudio.MicBarApplication { + id: audioApplication; + visible: AvatarInputs.showAudioTools && !HMD.active; + onVisibleChanged: { + console.log("visible changed: " + visible); + } standalone: true; dragTarget: parent; } BubbleIcon { dragTarget: parent + visible: !HMD.active; } } diff --git a/interface/resources/qml/BubbleIcon.qml b/interface/resources/qml/BubbleIcon.qml index f9c57697f0..1ad73f6179 100644 --- a/interface/resources/qml/BubbleIcon.qml +++ b/interface/resources/qml/BubbleIcon.qml @@ -19,8 +19,16 @@ Rectangle { width: bubbleIcon.width + 10 height: bubbleIcon.height + 10 radius: 5; - opacity: AvatarInputs.ignoreRadiusEnabled ? 0.7 : 0.3; property var dragTarget: null; + property bool ignoreRadiusEnabled: AvatarInputs.ignoreRadiusEnabled; + + onIgnoreRadiusEnabledChanged: { + if (ignoreRadiusEnabled) { + bubbleRect.opacity = 0.7; + } else { + bubbleRect.opacity = 0.3; + } + } color: "#00000000"; border { @@ -58,15 +66,17 @@ Rectangle { } drag.target: dragTarget; onContainsMouseChanged: { + var rectOpacity = ignoreRadiusEnabled ? (containsMouse ? 0.9 : 0.7) : (containsMouse ? 0.5 : 0.3); if (containsMouse) { Tablet.playSound(TabletEnums.ButtonHover); } + bubbleRect.opacity = rectOpacity; } } Image { id: bubbleIcon source: "../icons/tablet-icons/bubble-i.svg"; - sourceSize: Qt.size(28, 28); + sourceSize: Qt.size(32, 32); smooth: true; anchors.top: parent.top anchors.topMargin: (parent.height - bubbleIcon.height) / 2 diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index fb52f8bc5e..71e3764826 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -16,6 +16,7 @@ import stylesUit 1.0 import TabletScriptingInterface 1.0 Rectangle { + id: micBar HifiConstants { id: hifi; } readonly property var level: AudioScriptingInterface.inputLevel; @@ -72,7 +73,7 @@ Rectangle { hoverEnabled: true; scrollGestureEnabled: false; onClicked: { - if (AudioScriptingInterface.pushToTalk) { + if (pushToTalk) { return; } muted = !muted; @@ -98,7 +99,7 @@ Rectangle { readonly property string red: colors.muted; readonly property string fill: "#55000000"; readonly property string border: standalone ? "#80FFFFFF" : "#55FFFFFF"; - readonly property string icon: muted ? muted : unmuted; + readonly property string icon: micBar.muted ? muted : unmuted; } Item { @@ -122,7 +123,7 @@ Rectangle { readonly property string gatedIcon: "../../../icons/tablet-icons/mic-gate-i.svg"; id: image; - source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : + source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; width: 30; @@ -146,9 +147,9 @@ Rectangle { Item { id: status; - readonly property string color: muted ? colors.muted : colors.unmuted; + readonly property string color: colors.icon; - visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); + visible: (pushToTalk && !pushingToTalk) || muted; anchors { left: parent.left; @@ -177,7 +178,7 @@ Rectangle { verticalCenter: parent.verticalCenter; } - width: AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk ? (HMD.active ? 27 : 25) : 50; + width: pushToTalk && !pushingToTalk ? (HMD.active ? 27 : 25) : 50; height: 4; color: parent.color; } @@ -188,7 +189,7 @@ Rectangle { verticalCenter: parent.verticalCenter; } - width: AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk ? (HMD.active ? 27 : 25) : 50; + width: pushToTalk && !pushingToTalk ? (HMD.active ? 27 : 25) : 50; height: 4; color: parent.color; } diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index bfac278ee4..f89ada6e49 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -126,7 +126,7 @@ Rectangle { Item { Image { id: image; - source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : + source: (pushToTalk) ? pushToTalkIcon : muted ? mutedIcon : clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; width: 29; height: 32; @@ -141,8 +141,7 @@ Rectangle { id: imageOverlay anchors { fill: image } source: image; - color: (pushToTalk && !pushingToTalk) ? ((level >= userSpeakingLevel) ? colors.mutedColor : - colors.unmutedColor) : colors.icon; + color: pushToTalk ? (pushingToTalk ? colors.unmutedColor : colors.mutedColor) : colors.icon; } } } @@ -150,12 +149,12 @@ Rectangle { Item { id: status; - visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); + visible: pushToTalk || (muted && (level >= userSpeakingLevel)); anchors { left: parent.left; top: icon.bottom; - topMargin: 5; + topMargin: 2; } width: parent.width; @@ -174,10 +173,10 @@ Rectangle { verticalCenter: parent.verticalCenter; } - color: (level >= userSpeakingLevel && muted) ? colors.mutedColor : colors.unmutedColor; + color: pushToTalk ? (pushingToTalk ? colors.unmutedColor : colors.mutedColor) : (level >= userSpeakingLevel && muted) ? colors.mutedColor : colors.unmutedColor; font.bold: true - text: (pushToTalk && !pushingToTalk) ? (HMD.active ? "PTT" : "PTT-(T)") : (muted ? "MUTED" : "MUTE"); + text: pushToTalk ? (HMD.active ? "PTT" : "PTT-(T)") : (muted ? "MUTED" : "MUTE"); size: 12; } } @@ -204,6 +203,7 @@ Rectangle { Rectangle { // mask id: mask; + visible: (!(pushToTalk && !pushingToTalk)) height: parent.height * level; width: parent.width; radius: 5; @@ -217,6 +217,7 @@ Rectangle { LinearGradient { anchors { fill: mask } + visible: (!(pushToTalk && !pushingToTalk)) source: mask start: Qt.point(0, 0); end: Qt.point(0, bar.height); diff --git a/interface/resources/qml/hifi/tablet/TabletHome.qml b/interface/resources/qml/hifi/tablet/TabletHome.qml index a1da69a44a..1a1e0a96ff 100644 --- a/interface/resources/qml/hifi/tablet/TabletHome.qml +++ b/interface/resources/qml/hifi/tablet/TabletHome.qml @@ -40,7 +40,7 @@ Item { } } - HifiAudio.MicBar { + HifiAudio.MicBarApplication { anchors { left: parent.left leftMargin: 30 diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5b0c379c64..734eb7221b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -339,7 +339,7 @@ Setting::Handle maxOctreePacketsPerSecond{"maxOctreePPS", DEFAULT_MAX_OCTRE Setting::Handle loginDialogPoppedUp{"loginDialogPoppedUp", false}; static const QUrl AVATAR_INPUTS_BAR_QML = PathUtils::qmlUrl("AvatarInputsBar.qml"); -static const QUrl MIC_BAR_ENTITY_QML = PathUtils::qmlUrl("hifi/audio/MicBarApplication.qml"); +static const QUrl MIC_BAR_APPLICATION_QML = PathUtils::qmlUrl("hifi/audio/MicBarApplication.qml"); static const QUrl BUBBLE_ICON_QML = PathUtils::qmlUrl("BubbleIcon.qml"); static const QString STANDARD_TO_ACTION_MAPPING_NAME = "Standard to Action"; @@ -2396,7 +2396,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo }); auto rootItemLoadedFunctor = [webSurface, url, isTablet] { Application::setupQmlSurface(webSurface->getSurfaceContext(), isTablet || url == LOGIN_DIALOG.toString() || url == AVATAR_INPUTS_BAR_QML.toString() || - url == BUBBLE_ICON_QML.toString() || url == MIC_BAR_ENTITY_QML.toString() ); + url == BUBBLE_ICON_QML.toString()); }; if (webSurface->getRootItem()) { rootItemLoadedFunctor(); diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 0d9799a035..bd7e79dffc 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -32,8 +32,7 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/firstPersonHMD.js", "system/tablet-ui/tabletUI.js", "system/emote.js", - "system/miniTablet.js", - "system/createAvatarInputsBarEntity.js" + "system/miniTablet.js" ]; var DEFAULT_SCRIPTS_SEPARATE = [ "system/controllers/controllerScripts.js", diff --git a/scripts/system/createAvatarInputsBarEntity.js b/scripts/developer/createAvatarInputsBarEntity.js similarity index 100% rename from scripts/system/createAvatarInputsBarEntity.js rename to scripts/developer/createAvatarInputsBarEntity.js diff --git a/scripts/system/away.js b/scripts/system/away.js index 2af43b2055..e45041139a 100644 --- a/scripts/system/away.js +++ b/scripts/system/away.js @@ -171,7 +171,7 @@ function goAway(fromStartup) { if (!previousBubbleState) { Users.toggleIgnoreRadius(); } - UserActivityLogger.bubbleToggled(Users.getIgnoreRadiusEnabled()); + UserActivityLogger.privacyShieldToggled(Users.getIgnoreRadiusEnabled()); UserActivityLogger.toggledAway(true); MyAvatar.isAway = true; } @@ -186,7 +186,7 @@ function goActive() { if (Users.getIgnoreRadiusEnabled() !== previousBubbleState) { Users.toggleIgnoreRadius(); - UserActivityLogger.bubbleToggled(Users.getIgnoreRadiusEnabled()); + UserActivityLogger.privacyShieldToggled(Users.getIgnoreRadiusEnabled()); } if (!Window.hasFocus()) { From 3ea45de7c73b87e34bea7707f9c36368a011cebc Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 22 Mar 2019 13:16:56 -0700 Subject: [PATCH 44/60] fixing qml bug in MicBar --- interface/resources/qml/AvatarInputsBar.qml | 35 ++++++++++++++----- interface/resources/qml/hifi/audio/MicBar.qml | 2 +- interface/src/scripting/Audio.cpp | 3 ++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/interface/resources/qml/AvatarInputsBar.qml b/interface/resources/qml/AvatarInputsBar.qml index adeb74242d..d975312aad 100644 --- a/interface/resources/qml/AvatarInputsBar.qml +++ b/interface/resources/qml/AvatarInputsBar.qml @@ -19,30 +19,49 @@ Item { objectName: "AvatarInputsBar" property int modality: Qt.NonModal readonly property bool ignoreRadiusEnabled: AvatarInputs.ignoreRadiusEnabled; - width: HMD.active ? audio.width : audioApplication.width; - height: HMD.active ? audio.height : audioApplication.height; x: 10; y: 5; readonly property bool shouldReposition: true; + property bool hmdActive: HMD.active; + width: hmdActive ? audio.width : audioApplication.width; + height: hmdActive ? audio.height : audioApplication.height; + + onHmdActiveChanged: { + console.log("hmd active = " + hmdActive); + } + + Timer { + id: hmdActiveCheckTimer; + interval: 500; + repeat: true; + onTriggered: { + root.hmdActive = HMD.active; + } + + } HifiAudio.MicBar { id: audio; - visible: AvatarInputs.showAudioTools && HMD.active; + visible: AvatarInputs.showAudioTools && root.hmdActive; standalone: true; dragTarget: parent; } HifiAudio.MicBarApplication { id: audioApplication; - visible: AvatarInputs.showAudioTools && !HMD.active; - onVisibleChanged: { - console.log("visible changed: " + visible); - } + visible: AvatarInputs.showAudioTools && !root.hmdActive; standalone: true; dragTarget: parent; } + + Component.onCompleted: { + HMD.displayModeChanged.connect(function(isHmdMode) { + root.hmdActive = isHmdMode; + }); + } + BubbleIcon { dragTarget: parent - visible: !HMD.active; + visible: !root.hmdActive; } } diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index 71e3764826..4b243e033a 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -19,9 +19,9 @@ Rectangle { id: micBar HifiConstants { id: hifi; } + property var muted: AudioScriptingInterface.muted; readonly property var level: AudioScriptingInterface.inputLevel; readonly property var clipping: AudioScriptingInterface.clipping; - readonly property var muted: AudioScriptingInterface.muted; readonly property var pushToTalk: AudioScriptingInterface.pushToTalk; readonly property var pushingToTalk: AudioScriptingInterface.pushingToTalk; diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index 434688e474..0e0d13ae45 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -228,6 +228,9 @@ void Audio::loadData() { setMutedHMD(_hmdMutedSetting.get()); setPTTDesktop(_pttDesktopSetting.get()); setPTTHMD(_pttHMDSetting.get()); + + auto client = DependencyManager::get().data(); + QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted()), Q_ARG(bool, false)); } bool Audio::getPTTHMD() const { From b98eda4674944f6d8eb210c1aad11aa743cf9716 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 22 Mar 2019 16:42:37 -0700 Subject: [PATCH 45/60] removing debug statemeng --- interface/resources/qml/AvatarInputsBar.qml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/interface/resources/qml/AvatarInputsBar.qml b/interface/resources/qml/AvatarInputsBar.qml index d975312aad..3f1f598991 100644 --- a/interface/resources/qml/AvatarInputsBar.qml +++ b/interface/resources/qml/AvatarInputsBar.qml @@ -26,10 +26,6 @@ Item { width: hmdActive ? audio.width : audioApplication.width; height: hmdActive ? audio.height : audioApplication.height; - onHmdActiveChanged: { - console.log("hmd active = " + hmdActive); - } - Timer { id: hmdActiveCheckTimer; interval: 500; From 49ce30d536443dc989aa98b71f78d2293531d2a0 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 25 Mar 2019 15:35:05 -0700 Subject: [PATCH 46/60] adding changes to design + truly separating muted/ptt --- .../qml/controlsUit/CheckBoxQQC2.qml | 3 +- .../resources/qml/controlsUit/Switch.qml | 5 +- interface/resources/qml/hifi/audio/Audio.qml | 57 ++++++++++++------- .../resources/qml/hifi/audio/InputPeak.qml | 20 +++---- .../qml/hifi/audio/LoopbackAudio.qml | 7 ++- .../qml/hifi/audio/PlaySampleSound.qml | 5 +- 6 files changed, 59 insertions(+), 38 deletions(-) diff --git a/interface/resources/qml/controlsUit/CheckBoxQQC2.qml b/interface/resources/qml/controlsUit/CheckBoxQQC2.qml index 91d35ecd58..bd71025aa9 100644 --- a/interface/resources/qml/controlsUit/CheckBoxQQC2.qml +++ b/interface/resources/qml/controlsUit/CheckBoxQQC2.qml @@ -24,6 +24,7 @@ CheckBox { leftPadding: 0 property int colorScheme: hifi.colorSchemes.light property string color: hifi.colors.lightGrayText + property int fontSize: hifi.fontSizes.inputLabel readonly property bool isLightColorScheme: colorScheme === hifi.colorSchemes.light property bool isRedCheck: false property bool isRound: false @@ -109,7 +110,7 @@ CheckBox { contentItem: Text { id: root - font.pixelSize: hifi.fontSizes.inputLabel + font.pixelSize: fontSize; font.family: "Raleway" font.weight: Font.DemiBold text: checkBox.text diff --git a/interface/resources/qml/controlsUit/Switch.qml b/interface/resources/qml/controlsUit/Switch.qml index 4e1c21c456..422b08b4eb 100644 --- a/interface/resources/qml/controlsUit/Switch.qml +++ b/interface/resources/qml/controlsUit/Switch.qml @@ -21,6 +21,7 @@ Item { property int switchWidth: 70; readonly property int switchRadius: height/2; property string labelTextOff: ""; + property int labelTextSize: hifi.fontSizes.inputLabel; property string labelGlyphOffText: ""; property int labelGlyphOffSize: 32; property string labelTextOn: ""; @@ -89,7 +90,7 @@ Item { RalewaySemiBold { id: labelOff; text: labelTextOff; - size: hifi.fontSizes.inputLabel; + size: labelTextSize; color: originalSwitch.checked ? hifi.colors.lightGrayText : "#FFFFFF"; anchors.top: parent.top; anchors.right: parent.right; @@ -130,7 +131,7 @@ Item { RalewaySemiBold { id: labelOn; text: labelTextOn; - size: hifi.fontSizes.inputLabel; + size: labelTextSize; color: originalSwitch.checked ? "#FFFFFF" : hifi.colors.lightGrayText; anchors.top: parent.top; anchors.left: parent.left; diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index cd0f290da4..79222ea792 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -31,6 +31,8 @@ Rectangle { property string title: "Audio Settings" property int switchHeight: 16 property int switchWidth: 40 + property bool pushToTalk: (bar.currentIndex === 0) ? AudioScriptingInterface.pushToTalkDesktop : AudioScriptingInterface.pushToTalkHMD; + property bool muted: (bar.currentIndex === 0) ? AudioScriptingInterface.desktopMuted : AudioScriptingInterface.hmdMuted; readonly property real verticalScrollWidth: 10 readonly property real verticalScrollShaft: 8 signal sendToScript(var message); @@ -44,7 +46,7 @@ Rectangle { property bool isVR: AudioScriptingInterface.context === "VR" - property real rightMostInputLevelPos: 440 + property real rightMostInputLevelPos: root.width //placeholder for control sizes and paddings //recalculates dynamically in case of UI size is changed QtObject { @@ -92,7 +94,9 @@ Rectangle { } } - Component.onCompleted: enablePeakValues(); + Component.onCompleted: { + enablePeakValues(); + } Flickable { id: flickView; @@ -167,15 +171,25 @@ Rectangle { height: root.switchHeight; switchWidth: root.switchWidth; labelTextOn: "Mute microphone"; + labelTextSize: 16; backgroundOnColor: "#E3E3E3"; - checked: AudioScriptingInterface.muted; + checked: muted; onClicked: { - if (AudioScriptingInterface.pushToTalk && !checked) { + if (pushToTalk && !checked) { // disable push to talk if unmuting - AudioScriptingInterface.pushToTalk = false; + if ((bar.currentIndex === 0)) { + AudioScriptingInterface.pushToTalkDesktop = false; + } + else { + AudioScriptingInterface.pushToTalkHMD = false; + } + } + if ((bar.currentIndex === 0)) { + AudioScriptingInterface.desktopMuted = checked; + } + else { + AudioScriptingInterface.hmdMuted = checked; } - AudioScriptingInterface.muted = checked; - checked = Qt.binding(function() { return AudioScriptingInterface.muted; }); // restore binding } } @@ -187,6 +201,7 @@ Rectangle { anchors.topMargin: 24 anchors.left: parent.left labelTextOn: "Noise Reduction"; + labelTextSize: 16; backgroundOnColor: "#E3E3E3"; checked: AudioScriptingInterface.noiseReduction; onCheckedChanged: { @@ -203,6 +218,7 @@ Rectangle { anchors.topMargin: 24 anchors.left: parent.left labelTextOn: qsTr("Push To Talk (T)"); + labelTextSize: 16; backgroundOnColor: "#E3E3E3"; checked: (bar.currentIndex === 0) ? AudioScriptingInterface.pushToTalkDesktop : AudioScriptingInterface.pushToTalkHMD; onCheckedChanged: { @@ -211,13 +227,6 @@ Rectangle { } else { AudioScriptingInterface.pushToTalkHMD = checked; } - checked = Qt.binding(function() { - if (bar.currentIndex === 0) { - return AudioScriptingInterface.pushToTalkDesktop; - } else { - return AudioScriptingInterface.pushToTalkHMD; - } - }); // restore binding } } } @@ -235,6 +244,7 @@ Rectangle { anchors.top: parent.top anchors.left: parent.left labelTextOn: qsTr("Warn when muted"); + labelTextSize: 16; backgroundOnColor: "#E3E3E3"; checked: AudioScriptingInterface.warnWhenMuted; onClicked: { @@ -252,6 +262,7 @@ Rectangle { anchors.topMargin: 24 anchors.left: parent.left labelTextOn: qsTr("Audio Level Meter"); + labelTextSize: 16; backgroundOnColor: "#E3E3E3"; checked: AvatarInputs.showAudioTools; onCheckedChanged: { @@ -268,6 +279,7 @@ Rectangle { anchors.topMargin: 24 anchors.left: parent.left labelTextOn: qsTr("Stereo input"); + labelTextSize: 16; backgroundOnColor: "#E3E3E3"; checked: AudioScriptingInterface.isStereoInput; onCheckedChanged: { @@ -281,6 +293,7 @@ Rectangle { Item { id: pttTextContainer + visible: pushToTalk; anchors.top: switchesContainer.bottom; anchors.topMargin: 10; anchors.left: parent.left; @@ -303,7 +316,7 @@ Rectangle { Separator { id: secondSeparator; - anchors.top: pttTextContainer.bottom; + anchors.top: pttTextContainer.visible ? pttTextContainer.bottom : switchesContainer.bottom; anchors.topMargin: 10; } @@ -330,7 +343,7 @@ Rectangle { width: margins.sizeText + margins.sizeLevel; anchors.left: parent.left; anchors.leftMargin: margins.sizeCheckBox; - size: 16; + size: 22; color: hifi.colors.white; text: qsTr("Choose input device"); } @@ -338,7 +351,7 @@ Rectangle { ListView { id: inputView; - width: parent.width - margins.paddings*2; + width: rightMostInputLevelPos; anchors.top: inputDeviceHeader.bottom; anchors.topMargin: 10; x: margins.paddings @@ -347,7 +360,7 @@ Rectangle { clip: true; model: AudioScriptingInterface.devices.input; delegate: Item { - width: rightMostInputLevelPos + width: rightMostInputLevelPos - margins.paddings*2 height: margins.sizeCheckBox > checkBoxInput.implicitHeight ? margins.sizeCheckBox : checkBoxInput.implicitHeight @@ -363,6 +376,7 @@ Rectangle { boxSize: margins.sizeCheckBox / 2 isRound: true text: devicename + fontSize: 16; onPressed: { if (!checked) { stereoInput.checked = false; @@ -395,7 +409,7 @@ Rectangle { Separator { id: thirdSeparator; - anchors.top: loopbackAudio.bottom; + anchors.top: loopbackAudio.visible ? loopbackAudio.bottom : inputView.bottom; anchors.topMargin: 10; } @@ -422,7 +436,7 @@ Rectangle { anchors.left: parent.left anchors.leftMargin: margins.sizeCheckBox anchors.verticalCenter: parent.verticalCenter; - size: 16; + size: 22; color: hifi.colors.white; text: qsTr("Choose output device"); } @@ -452,6 +466,7 @@ Rectangle { checked: bar.currentIndex === 0 ? selectedDesktop : selectedHMD; checkable: !checked text: devicename + fontSize: 16 onPressed: { if (!checked) { AudioScriptingInterface.setOutputDevice(info, bar.currentIndex === 1); @@ -514,7 +529,7 @@ Rectangle { RalewayRegular { // The slider for my card is special, it controls the master gain id: gainSliderText; - text: "Avatar volume"; + text: "People volume"; size: 16; anchors.left: parent.left; color: hifi.colors.white; diff --git a/interface/resources/qml/hifi/audio/InputPeak.qml b/interface/resources/qml/hifi/audio/InputPeak.qml index 00f7e63528..d8b166cee4 100644 --- a/interface/resources/qml/hifi/audio/InputPeak.qml +++ b/interface/resources/qml/hifi/audio/InputPeak.qml @@ -12,24 +12,26 @@ import QtQuick 2.5 import QtGraphicalEffects 1.0 -Rectangle { +Item { property var peak; width: 70; height: 8; - color: "transparent"; - - Item { + QtObject { id: colors; + readonly property string unmuted: "#FFF"; readonly property string muted: "#E2334D"; readonly property string gutter: "#575757"; readonly property string greenStart: "#39A38F"; readonly property string greenEnd: "#1FC6A6"; + readonly property string yellow: "#C0C000"; readonly property string red: colors.muted; + readonly property string fill: "#55000000"; } + Text { id: status; @@ -79,23 +81,19 @@ Rectangle { anchors { fill: mask } source: mask start: Qt.point(0, 0); - end: Qt.point(70, 0); + end: Qt.point(bar.width, 0); gradient: Gradient { GradientStop { position: 0; color: colors.greenStart; } GradientStop { - position: 0.8; + position: 0.5; color: colors.greenEnd; } - GradientStop { - position: 0.801; - color: colors.red; - } GradientStop { position: 1; - color: colors.red; + color: colors.yellow; } } } diff --git a/interface/resources/qml/hifi/audio/LoopbackAudio.qml b/interface/resources/qml/hifi/audio/LoopbackAudio.qml index 8ec0ffc496..b668568035 100644 --- a/interface/resources/qml/hifi/audio/LoopbackAudio.qml +++ b/interface/resources/qml/hifi/audio/LoopbackAudio.qml @@ -44,8 +44,11 @@ RowLayout { } HifiControlsUit.Button { - text: audioLoopedBack ? qsTr("STOP TESTING YOUR VOICE") : qsTr("TEST YOUR VOICE"); + text: audioLoopedBack ? qsTr("STOP TESTING VOICE") : qsTr("TEST YOUR VOICE"); color: audioLoopedBack ? hifi.buttons.red : hifi.buttons.blue; + fontSize: 15; + width: 200; + height: 32; onClicked: { if (audioLoopedBack) { loopbackTimer.stop(); @@ -59,7 +62,7 @@ RowLayout { RalewayRegular { Layout.leftMargin: 2; - size: 14; + size: 18; color: "white"; font.italic: true text: audioLoopedBack ? qsTr("Speak in your input") : ""; diff --git a/interface/resources/qml/hifi/audio/PlaySampleSound.qml b/interface/resources/qml/hifi/audio/PlaySampleSound.qml index b9d9727dab..8565512837 100644 --- a/interface/resources/qml/hifi/audio/PlaySampleSound.qml +++ b/interface/resources/qml/hifi/audio/PlaySampleSound.qml @@ -59,11 +59,14 @@ RowLayout { text: isPlaying ? qsTr("STOP TESTING YOUR SOUND") : qsTr("TEST YOUR SOUND"); color: isPlaying ? hifi.buttons.red : hifi.buttons.blue; onClicked: isPlaying ? stopSound() : playSound(); + fontSize: 15; + width: 200; + height: 32; } RalewayRegular { Layout.leftMargin: 2; - size: 14; + size: 18; color: "white"; font.italic: true text: isPlaying ? qsTr("Listen to your output") : ""; From 6aebd000d6be1a364d26725262d48ab121be7798 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 25 Mar 2019 15:41:03 -0700 Subject: [PATCH 47/60] changing api to match verbiage of overall code --- interface/resources/qml/hifi/audio/Audio.qml | 6 ++--- interface/src/scripting/Audio.cpp | 24 ++++++++++---------- interface/src/scripting/Audio.h | 21 +++++++++-------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index 79222ea792..3266f3ef46 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -32,7 +32,7 @@ Rectangle { property int switchHeight: 16 property int switchWidth: 40 property bool pushToTalk: (bar.currentIndex === 0) ? AudioScriptingInterface.pushToTalkDesktop : AudioScriptingInterface.pushToTalkHMD; - property bool muted: (bar.currentIndex === 0) ? AudioScriptingInterface.desktopMuted : AudioScriptingInterface.hmdMuted; + property bool muted: (bar.currentIndex === 0) ? AudioScriptingInterface.mutedDesktop : AudioScriptingInterface.mutedHMD; readonly property real verticalScrollWidth: 10 readonly property real verticalScrollShaft: 8 signal sendToScript(var message); @@ -185,10 +185,10 @@ Rectangle { } } if ((bar.currentIndex === 0)) { - AudioScriptingInterface.desktopMuted = checked; + AudioScriptingInterface.mutedDesktop = checked; } else { - AudioScriptingInterface.hmdMuted = checked; + AudioScriptingInterface.mutedHMD = checked; } } } diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index 0e0d13ae45..df88538724 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -88,44 +88,44 @@ void Audio::setMuted(bool isMuted) { void Audio::setMutedDesktop(bool isMuted) { bool changed = false; withWriteLock([&] { - if (_desktopMuted != isMuted) { + if (_mutedDesktop != isMuted) { changed = true; - _desktopMuted = isMuted; + _mutedDesktop = isMuted; auto client = DependencyManager::get().data(); QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted), Q_ARG(bool, false)); } }); if (changed) { emit mutedChanged(isMuted); - emit desktopMutedChanged(isMuted); + emit mutedDesktopChanged(isMuted); } } bool Audio::getMutedDesktop() const { return resultWithReadLock([&] { - return _desktopMuted; + return _mutedDesktop; }); } void Audio::setMutedHMD(bool isMuted) { bool changed = false; withWriteLock([&] { - if (_hmdMuted != isMuted) { + if (_mutedHMD != isMuted) { changed = true; - _hmdMuted = isMuted; + _mutedHMD = isMuted; auto client = DependencyManager::get().data(); QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted), Q_ARG(bool, false)); } }); if (changed) { emit mutedChanged(isMuted); - emit hmdMutedChanged(isMuted); + emit mutedHMDChanged(isMuted); } } bool Audio::getMutedHMD() const { return resultWithReadLock([&] { - return _hmdMuted; + return _mutedHMD; }); } @@ -217,15 +217,15 @@ void Audio::setPTTHMD(bool enabled) { } void Audio::saveData() { - _desktopMutedSetting.set(getMutedDesktop()); - _hmdMutedSetting.set(getMutedHMD()); + _mutedDesktopSetting.set(getMutedDesktop()); + _mutedHMDSetting.set(getMutedHMD()); _pttDesktopSetting.set(getPTTDesktop()); _pttHMDSetting.set(getPTTHMD()); } void Audio::loadData() { - setMutedDesktop(_desktopMutedSetting.get()); - setMutedHMD(_hmdMutedSetting.get()); + setMutedDesktop(_mutedDesktopSetting.get()); + setMutedHMD(_mutedHMDSetting.get()); setPTTDesktop(_pttDesktopSetting.get()); setPTTHMD(_pttHMDSetting.get()); diff --git a/interface/src/scripting/Audio.h b/interface/src/scripting/Audio.h index 9ee230fc29..dba3af0730 100644 --- a/interface/src/scripting/Audio.h +++ b/interface/src/scripting/Audio.h @@ -41,6 +41,7 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable { * @hifi-assignment-client * * @property {boolean} muted - true if the audio input is muted, otherwise false. + * @property {boolean} mutedDesktop - true if the audio input is muted, otherwise false. * @property {boolean} noiseReduction - true if noise reduction is enabled, otherwise false. When * enabled, the input audio signal is blocked (fully attenuated) when it falls below an adaptive threshold set just * above the noise floor. @@ -68,8 +69,8 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable { Q_PROPERTY(bool clipping READ isClipping NOTIFY clippingChanged) Q_PROPERTY(QString context READ getContext NOTIFY contextChanged) Q_PROPERTY(AudioDevices* devices READ getDevices NOTIFY nop) - Q_PROPERTY(bool desktopMuted READ getMutedDesktop WRITE setMutedDesktop NOTIFY desktopMutedChanged) - Q_PROPERTY(bool hmdMuted READ getMutedHMD WRITE setMutedHMD NOTIFY hmdMutedChanged) + Q_PROPERTY(bool mutedDesktop READ getMutedDesktop WRITE setMutedDesktop NOTIFY mutedDesktopChanged) + Q_PROPERTY(bool mutedHMD READ getMutedHMD WRITE setMutedHMD NOTIFY mutedHMDChanged) Q_PROPERTY(bool pushToTalk READ getPTT WRITE setPTT NOTIFY pushToTalkChanged); Q_PROPERTY(bool pushToTalkDesktop READ getPTTDesktop WRITE setPTTDesktop NOTIFY pushToTalkDesktopChanged) Q_PROPERTY(bool pushToTalkHMD READ getPTTHMD WRITE setPTTHMD NOTIFY pushToTalkHMDChanged) @@ -227,19 +228,19 @@ signals: /**jsdoc * Triggered when desktop audio input is muted or unmuted. - * @function Audio.desktopMutedChanged + * @function Audio.mutedDesktopChanged * @param {boolean} isMuted - true if the audio input is muted for desktop mode, otherwise false. * @returns {Signal} */ - void desktopMutedChanged(bool isMuted); + void mutedDesktopChanged(bool isMuted); /**jsdoc * Triggered when HMD audio input is muted or unmuted. - * @function Audio.hmdMutedChanged + * @function Audio.mutedHMDChanged * @param {boolean} isMuted - true if the audio input is muted for HMD mode, otherwise false. * @returns {Signal} */ - void hmdMutedChanged(bool isMuted); + void mutedHMDChanged(bool isMuted); /** * Triggered when Push-to-Talk has been enabled or disabled. @@ -356,12 +357,12 @@ private: bool _contextIsHMD { false }; AudioDevices* getDevices() { return &_devices; } AudioDevices _devices; - Setting::Handle _desktopMutedSetting{ QStringList { Audio::AUDIO, "desktopMuted" }, true }; - Setting::Handle _hmdMutedSetting{ QStringList { Audio::AUDIO, "hmdMuted" }, true }; + Setting::Handle _mutedDesktopSetting{ QStringList { Audio::AUDIO, "mutedDesktop" }, true }; + Setting::Handle _mutedHMD{ QStringList { Audio::AUDIO, "mutedHMD" }, true }; Setting::Handle _pttDesktopSetting{ QStringList { Audio::AUDIO, "pushToTalkDesktop" }, false }; Setting::Handle _pttHMDSetting{ QStringList { Audio::AUDIO, "pushToTalkHMD" }, false }; - bool _desktopMuted{ true }; - bool _hmdMuted{ false }; + bool _mutedDesktop{ true }; + bool _mutedHMD{ false }; bool _pttDesktop{ false }; bool _pttHMD{ false }; bool _pushingToTalk{ false }; From c54e8f55693be7175839700c6e00d04b368bbc77 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 25 Mar 2019 17:32:03 -0700 Subject: [PATCH 48/60] showing ptt text always + hmd mode switch fix --- interface/resources/qml/BubbleIcon.qml | 10 +++++++++- interface/resources/qml/hifi/audio/Audio.qml | 5 ++--- interface/resources/qml/hifi/audio/MicBar.qml | 15 +++++++++------ .../qml/hifi/audio/MicBarApplication.qml | 13 +++++++++---- scripts/system/audio.js | 2 ++ 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/interface/resources/qml/BubbleIcon.qml b/interface/resources/qml/BubbleIcon.qml index 1ad73f6179..430eb19860 100644 --- a/interface/resources/qml/BubbleIcon.qml +++ b/interface/resources/qml/BubbleIcon.qml @@ -22,7 +22,7 @@ Rectangle { property var dragTarget: null; property bool ignoreRadiusEnabled: AvatarInputs.ignoreRadiusEnabled; - onIgnoreRadiusEnabledChanged: { + function updateOpacity() { if (ignoreRadiusEnabled) { bubbleRect.opacity = 0.7; } else { @@ -30,6 +30,14 @@ Rectangle { } } + Component.onCompleted: { + updateOpacity(); + } + + onIgnoreRadiusEnabledChanged: { + updateOpacity(); + } + color: "#00000000"; border { width: mouseArea.containsMouse || mouseArea.containsPress ? 2 : 0; diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index 3266f3ef46..015a9542e9 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -177,14 +177,14 @@ Rectangle { onClicked: { if (pushToTalk && !checked) { // disable push to talk if unmuting - if ((bar.currentIndex === 0)) { + if (bar.currentIndex === 0) { AudioScriptingInterface.pushToTalkDesktop = false; } else { AudioScriptingInterface.pushToTalkHMD = false; } } - if ((bar.currentIndex === 0)) { + if (bar.currentIndex === 0) { AudioScriptingInterface.mutedDesktop = checked; } else { @@ -293,7 +293,6 @@ Rectangle { Item { id: pttTextContainer - visible: pushToTalk; anchors.top: switchesContainer.bottom; anchors.topMargin: 10; anchors.left: parent.left; diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index 4b243e033a..b6254b168c 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -22,14 +22,18 @@ Rectangle { property var muted: AudioScriptingInterface.muted; readonly property var level: AudioScriptingInterface.inputLevel; readonly property var clipping: AudioScriptingInterface.clipping; - readonly property var pushToTalk: AudioScriptingInterface.pushToTalk; - readonly property var pushingToTalk: AudioScriptingInterface.pushingToTalk; + property var pushToTalk: AudioScriptingInterface.pushToTalk; + property var pushingToTalk: AudioScriptingInterface.pushingToTalk; readonly property var userSpeakingLevel: 0.4; property bool gated: false; Component.onCompleted: { AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; }); AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; }); + HMD.displayModeChanged.connect(function() { + muted = AudioScriptingInterface.muted; + pushToTalk = AudioScriptingInterface.pushToTalk; + }); } property bool standalone: false; @@ -147,7 +151,6 @@ Rectangle { Item { id: status; - readonly property string color: colors.icon; visible: (pushToTalk && !pushingToTalk) || muted; @@ -166,7 +169,7 @@ Rectangle { verticalCenter: parent.verticalCenter; } - color: parent.color; + color: colors.icon; text: (pushToTalk && !pushingToTalk) ? (HMD.active ? "MUTED PTT" : "MUTED PTT-(T)") : (muted ? "MUTED" : "MUTE"); font.pointSize: 12; @@ -180,7 +183,7 @@ Rectangle { width: pushToTalk && !pushingToTalk ? (HMD.active ? 27 : 25) : 50; height: 4; - color: parent.color; + color: colors.icon; } Rectangle { @@ -191,7 +194,7 @@ Rectangle { width: pushToTalk && !pushingToTalk ? (HMD.active ? 27 : 25) : 50; height: 4; - color: parent.color; + color: colors.icon; } } diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index f89ada6e49..509517063d 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -19,14 +19,18 @@ Rectangle { id: micBar; readonly property var level: AudioScriptingInterface.inputLevel; readonly property var clipping: AudioScriptingInterface.clipping; - readonly property var muted: AudioScriptingInterface.muted; - readonly property var pushToTalk: AudioScriptingInterface.pushToTalk; - readonly property var pushingToTalk: AudioScriptingInterface.pushingToTalk; + property var muted: AudioScriptingInterface.muted; + property var pushToTalk: AudioScriptingInterface.pushToTalk; + property var pushingToTalk: AudioScriptingInterface.pushingToTalk; readonly property var userSpeakingLevel: 0.4; property bool gated: false; Component.onCompleted: { AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; }); AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; }); + HMD.displayModeChanged.connect(function() { + muted = AudioScriptingInterface.muted; + pushToTalk = AudioScriptingInterface.pushToTalk; + }); } readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; @@ -86,8 +90,9 @@ Rectangle { hoverEnabled: true; scrollGestureEnabled: false; onClicked: { - AudioScriptingInterface.muted = !AudioScriptingInterface.muted; + AudioScriptingInterface.muted = !muted; Tablet.playSound(TabletEnums.ButtonClick); + muted = Qt.binding(function() { return AudioScriptingInterface.muted; }); // restore binding } drag.target: dragTarget; onContainsMouseChanged: { diff --git a/scripts/system/audio.js b/scripts/system/audio.js index 19ed3faef2..a161b40ffd 100644 --- a/scripts/system/audio.js +++ b/scripts/system/audio.js @@ -75,6 +75,7 @@ button.clicked.connect(onClicked); tablet.screenChanged.connect(onScreenChanged); Audio.mutedChanged.connect(onMuteToggled); Audio.pushToTalkChanged.connect(onMuteToggled); +HMD.displayModeChanged.connect(onMuteToggled); Script.scriptEnding.connect(function () { if (onAudioScreen) { @@ -84,6 +85,7 @@ Script.scriptEnding.connect(function () { tablet.screenChanged.disconnect(onScreenChanged); Audio.mutedChanged.disconnect(onMuteToggled); Audio.pushToTalkChanged.disconnect(onMuteToggled); + HMD.displayModeChanged.disconnect(onMuteToggled); tablet.removeButton(button); }); From 060932ad4bcd609e4c434fcc18ee77d056b06bd7 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 26 Mar 2019 09:13:10 -0700 Subject: [PATCH 49/60] fixing typo --- interface/src/scripting/Audio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/scripting/Audio.h b/interface/src/scripting/Audio.h index dba3af0730..90687e220e 100644 --- a/interface/src/scripting/Audio.h +++ b/interface/src/scripting/Audio.h @@ -358,7 +358,7 @@ private: AudioDevices* getDevices() { return &_devices; } AudioDevices _devices; Setting::Handle _mutedDesktopSetting{ QStringList { Audio::AUDIO, "mutedDesktop" }, true }; - Setting::Handle _mutedHMD{ QStringList { Audio::AUDIO, "mutedHMD" }, true }; + Setting::Handle _mutedHMDSetting{ QStringList { Audio::AUDIO, "mutedHMD" }, true }; Setting::Handle _pttDesktopSetting{ QStringList { Audio::AUDIO, "pushToTalkDesktop" }, false }; Setting::Handle _pttHMDSetting{ QStringList { Audio::AUDIO, "pushToTalkHMD" }, false }; bool _mutedDesktop{ true }; From 9349514ff723d0696b36e89f1fae28279e2719bd Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Mar 2019 10:35:28 -0700 Subject: [PATCH 50/60] make audio screen inputs/outputs unflickable --- interface/resources/qml/hifi/audio/Audio.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index 27c7048053..8bec821f34 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -365,6 +365,7 @@ Rectangle { anchors.top: inputDeviceHeader.bottom; anchors.topMargin: 10; x: margins.paddings + interactive: false; height: contentHeight; spacing: 4; clip: true; @@ -456,7 +457,8 @@ Rectangle { ListView { id: outputView width: parent.width - margins.paddings*2 - x: margins.paddings + x: margins.paddings; + interactive: false; height: contentHeight; anchors.top: outputDeviceHeader.bottom; anchors.topMargin: 10; From c3e5c49f693d33c09b7f9d9889f9683e71242373 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Mar 2019 10:40:39 -0700 Subject: [PATCH 51/60] update muted in AudioScriptingInterface --- interface/resources/qml/hifi/audio/MicBar.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index b6254b168c..9f970faaa9 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -80,7 +80,7 @@ Rectangle { if (pushToTalk) { return; } - muted = !muted; + AudioScriptingInterface.muted = !muted; Tablet.playSound(TabletEnums.ButtonClick); } drag.target: dragTarget; From 8627a92f299778de6aa389595ef59e05ae427f0f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Mar 2019 11:29:34 -0700 Subject: [PATCH 52/60] adding functions to update variables --- interface/resources/qml/hifi/audio/MicBar.qml | 6 ++++++ interface/resources/qml/hifi/audio/MicBarApplication.qml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index 9f970faaa9..89a30b4b91 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -34,6 +34,12 @@ Rectangle { muted = AudioScriptingInterface.muted; pushToTalk = AudioScriptingInterface.pushToTalk; }); + AudioScriptingInterface.mutedChanged.connect(function() { + muted = AudioScriptingInterface.muted; + }); + AudioScriptingInterface.pushToTalkChanged.connect(function() { + pushToTalk = AudioScriptingInterface.pushToTalk; + }); } property bool standalone: false; diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 509517063d..a39707e052 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -31,6 +31,12 @@ Rectangle { muted = AudioScriptingInterface.muted; pushToTalk = AudioScriptingInterface.pushToTalk; }); + AudioScriptingInterface.mutedChanged.connect(function() { + muted = AudioScriptingInterface.muted; + }); + AudioScriptingInterface.pushToTalkChanged.connect(function() { + pushToTalk = AudioScriptingInterface.pushToTalk; + }); } readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; From f2b0e47c39aa56d7277dc237a60a6b497939b50e Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Mar 2019 16:19:35 -0700 Subject: [PATCH 53/60] changing opacity --- interface/resources/qml/BubbleIcon.qml | 6 +++--- .../resources/qml/hifi/audio/MicBarApplication.qml | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/interface/resources/qml/BubbleIcon.qml b/interface/resources/qml/BubbleIcon.qml index 430eb19860..f4e99f136c 100644 --- a/interface/resources/qml/BubbleIcon.qml +++ b/interface/resources/qml/BubbleIcon.qml @@ -24,9 +24,9 @@ Rectangle { function updateOpacity() { if (ignoreRadiusEnabled) { - bubbleRect.opacity = 0.7; + bubbleRect.opacity = 1.0; } else { - bubbleRect.opacity = 0.3; + bubbleRect.opacity = 0.7; } } @@ -74,7 +74,7 @@ Rectangle { } drag.target: dragTarget; onContainsMouseChanged: { - var rectOpacity = ignoreRadiusEnabled ? (containsMouse ? 0.9 : 0.7) : (containsMouse ? 0.5 : 0.3); + var rectOpacity = (ignoreRadiusEnabled && containsMouse) ? 1.0 : (containsMouse ? 1.0 : 0.7); if (containsMouse) { Tablet.playSound(TabletEnums.ButtonHover); } diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index a39707e052..6bb418688e 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -51,14 +51,14 @@ Rectangle { height: 44; radius: 5; - opacity: 0.7 + opacity: 0.7; onLevelChanged: { - var rectOpacity = muted && (level >= userSpeakingLevel) ? 0.9 : 0.3; + var rectOpacity = muted && (level >= userSpeakingLevel) ? 1.0 : 0.7; if (pushToTalk && !pushingToTalk) { - rectOpacity = (level >= userSpeakingLevel) ? 0.9 : 0.7; - } else if (mouseArea.containsMouse && rectOpacity != 0.9) { - rectOpacity = 0.5; + rectOpacity = (level >= userSpeakingLevel) ? 1.0 : 0.7; + } else if (mouseArea.containsMouse && rectOpacity != 1.0) { + rectOpacity = 1.0; } micBar.opacity = rectOpacity; } From 3241d2f9602c9ef0d86643323b99cc311dbd897e Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 28 Mar 2019 16:24:37 -0700 Subject: [PATCH 54/60] don't allow clicking on push to talk in MicBarApplication --- interface/resources/qml/hifi/audio/MicBarApplication.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 6bb418688e..c19cc54f4a 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -96,6 +96,9 @@ Rectangle { hoverEnabled: true; scrollGestureEnabled: false; onClicked: { + if (pushToTalk) { + return; + } AudioScriptingInterface.muted = !muted; Tablet.playSound(TabletEnums.ButtonClick); muted = Qt.binding(function() { return AudioScriptingInterface.muted; }); // restore binding From 248f9ba375e07faac10a09dfd9cdbdd675a2b393 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Mar 2019 10:32:13 -0700 Subject: [PATCH 55/60] adding mute overlay back into HMD and have warn when muted disable in desktop --- .../qml/hifi/audio/MicBarApplication.qml | 7 ++++--- scripts/defaultScripts.js | 3 ++- scripts/system/audioMuteOverlay.js | 16 +--------------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index c19cc54f4a..4e0adfd95c 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -18,6 +18,7 @@ import TabletScriptingInterface 1.0 Rectangle { id: micBar; readonly property var level: AudioScriptingInterface.inputLevel; + readonly property var warnWhenMuted: AudioScriptingInterface.warnWhenMuted; readonly property var clipping: AudioScriptingInterface.clipping; property var muted: AudioScriptingInterface.muted; property var pushToTalk: AudioScriptingInterface.pushToTalk; @@ -54,7 +55,7 @@ Rectangle { opacity: 0.7; onLevelChanged: { - var rectOpacity = muted && (level >= userSpeakingLevel) ? 1.0 : 0.7; + var rectOpacity = (muted && (level >= userSpeakingLevel)) && warnWhenMuted ? 1.0 : 0.7; if (pushToTalk && !pushingToTalk) { rectOpacity = (level >= userSpeakingLevel) ? 1.0 : 0.7; } else if (mouseArea.containsMouse && rectOpacity != 1.0) { @@ -163,7 +164,7 @@ Rectangle { Item { id: status; - visible: pushToTalk || (muted && (level >= userSpeakingLevel)); + visible: pushToTalk || (muted && (level >= userSpeakingLevel) && warnWhenMuted); anchors { left: parent.left; @@ -187,7 +188,7 @@ Rectangle { verticalCenter: parent.verticalCenter; } - color: pushToTalk ? (pushingToTalk ? colors.unmutedColor : colors.mutedColor) : (level >= userSpeakingLevel && muted) ? colors.mutedColor : colors.unmutedColor; + color: pushToTalk ? (pushingToTalk ? colors.unmutedColor : colors.mutedColor) : (level >= userSpeakingLevel && muted && warnWhenMuted) ? colors.mutedColor : colors.unmutedColor; font.bold: true text: pushToTalk ? (HMD.active ? "PTT" : "PTT-(T)") : (muted ? "MUTED" : "MUTE"); diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index bd7e79dffc..e392680df9 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -32,7 +32,8 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/firstPersonHMD.js", "system/tablet-ui/tabletUI.js", "system/emote.js", - "system/miniTablet.js" + "system/miniTablet.js", + "system/audioMuteOverlay.js" ]; var DEFAULT_SCRIPTS_SEPARATE = [ "system/controllers/controllerScripts.js", diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index e715e97575..feea604a92 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -58,20 +58,6 @@ parentID: MyAvatar.SELF_ID, parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX") }); - } else { - var textDimensions = { x: 100, y: 50 }; - warningOverlayID = Overlays.addOverlay("text", { - name: "Muted-Warning", - font: { size: 36 }, - text: warningText, - x: (Window.innerWidth - textDimensions.x) / 2, - y: (Window.innerHeight - textDimensions.y), - width: textDimensions.x, - height: textDimensions.y, - textColor: { red: 226, green: 51, blue: 77 }, - backgroundAlpha: 0, - visible: true - }); } } @@ -141,4 +127,4 @@ Audio.mutedChanged.connect(startOrStopPoll); Audio.warnWhenMutedChanged.connect(startOrStopPoll); -}()); // END LOCAL_SCOPE \ No newline at end of file +}()); // END LOCAL_SCOPE From 3c65b92ff50127672c271e8e05a84b17c8e1aaa2 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Mar 2019 10:41:16 -0700 Subject: [PATCH 56/60] moving text position higher --- scripts/system/audioMuteOverlay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index feea604a92..9acc5ab123 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -43,7 +43,7 @@ if (HMD.active) { warningOverlayID = Overlays.addOverlay("text3d", { name: "Muted-Warning", - localPosition: { x: 0.0, y: -0.5, z: -1.0 }, + localPosition: { x: 0.0, y: -0.45, z: -1.0 }, localOrientation: Quat.fromVec3Degrees({ x: 0.0, y: 0.0, z: 0.0, w: 1.0 }), text: warningText, textAlpha: 1, From 26224087924d765da046035b8f4ed4df6de5595f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Mar 2019 10:45:40 -0700 Subject: [PATCH 57/60] warn when muted only affects hmd --- interface/resources/qml/hifi/audio/Audio.qml | 4 ++-- interface/resources/qml/hifi/audio/MicBarApplication.qml | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index 8bec821f34..f7e2494813 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -228,7 +228,7 @@ Rectangle { anchors.top: noiseReductionSwitch.bottom anchors.topMargin: 24 anchors.left: parent.left - labelTextOn: qsTr("Push To Talk (T)"); + labelTextOn: (bar.currentIndex === 0) ? qsTr("Push To Talk (T)") : qsTr("Push To Talk"); labelTextSize: 16; backgroundOnColor: "#E3E3E3"; checked: (bar.currentIndex === 0) ? AudioScriptingInterface.pushToTalkDesktop : AudioScriptingInterface.pushToTalkHMD; @@ -254,7 +254,7 @@ Rectangle { switchWidth: root.switchWidth; anchors.top: parent.top anchors.left: parent.left - labelTextOn: qsTr("Warn when muted"); + labelTextOn: qsTr("Warn when muted in HMD"); labelTextSize: 16; backgroundOnColor: "#E3E3E3"; checked: AudioScriptingInterface.warnWhenMuted; diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 4e0adfd95c..70bded0fc6 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -18,7 +18,6 @@ import TabletScriptingInterface 1.0 Rectangle { id: micBar; readonly property var level: AudioScriptingInterface.inputLevel; - readonly property var warnWhenMuted: AudioScriptingInterface.warnWhenMuted; readonly property var clipping: AudioScriptingInterface.clipping; property var muted: AudioScriptingInterface.muted; property var pushToTalk: AudioScriptingInterface.pushToTalk; @@ -55,7 +54,7 @@ Rectangle { opacity: 0.7; onLevelChanged: { - var rectOpacity = (muted && (level >= userSpeakingLevel)) && warnWhenMuted ? 1.0 : 0.7; + var rectOpacity = (muted && (level >= userSpeakingLevel)) ? 1.0 : 0.7; if (pushToTalk && !pushingToTalk) { rectOpacity = (level >= userSpeakingLevel) ? 1.0 : 0.7; } else if (mouseArea.containsMouse && rectOpacity != 1.0) { @@ -164,7 +163,7 @@ Rectangle { Item { id: status; - visible: pushToTalk || (muted && (level >= userSpeakingLevel) && warnWhenMuted); + visible: pushToTalk || (muted && (level >= userSpeakingLevel); anchors { left: parent.left; @@ -188,7 +187,7 @@ Rectangle { verticalCenter: parent.verticalCenter; } - color: pushToTalk ? (pushingToTalk ? colors.unmutedColor : colors.mutedColor) : (level >= userSpeakingLevel && muted && warnWhenMuted) ? colors.mutedColor : colors.unmutedColor; + color: pushToTalk ? (pushingToTalk ? colors.unmutedColor : colors.mutedColor) : (level >= userSpeakingLevel && muted) ? colors.mutedColor : colors.unmutedColor; font.bold: true text: pushToTalk ? (HMD.active ? "PTT" : "PTT-(T)") : (muted ? "MUTED" : "MUTE"); From 426ffe5a142ffeae8d4e28954b12119e70fcb30f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Mar 2019 15:38:42 -0700 Subject: [PATCH 58/60] Fixing typo --- interface/resources/qml/hifi/audio/MicBarApplication.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 70bded0fc6..5a98d03094 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -163,7 +163,7 @@ Rectangle { Item { id: status; - visible: pushToTalk || (muted && (level >= userSpeakingLevel); + visible: pushToTalk || (muted && (level >= userSpeakingLevel)); anchors { left: parent.left; From c4cccc6ef75763ffa1b42df2e382de847de0f8a2 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Mar 2019 17:04:44 -0700 Subject: [PATCH 59/60] fix opacity for containing mouse only --- interface/resources/qml/hifi/audio/MicBarApplication.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 5a98d03094..bc3f4dff89 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -56,7 +56,7 @@ Rectangle { onLevelChanged: { var rectOpacity = (muted && (level >= userSpeakingLevel)) ? 1.0 : 0.7; if (pushToTalk && !pushingToTalk) { - rectOpacity = (level >= userSpeakingLevel) ? 1.0 : 0.7; + rectOpacity = (mouseArea.containsMouse) ? 1.0 : 0.7; } else if (mouseArea.containsMouse && rectOpacity != 1.0) { rectOpacity = 1.0; } From afdf95c894de5302d2213288dff9c134b35042ce Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 1 Apr 2019 12:20:55 -0700 Subject: [PATCH 60/60] remove unused slotted function --- interface/src/Application.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 734eb7221b..ecafbfdb2c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1295,21 +1295,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo setCrashAnnotation("display_plugin", displayPlugin->getName().toStdString()); setCrashAnnotation("hmd", displayPlugin->isHmd() ? "1" : "0"); }); - connect(this, &Application::activeDisplayPluginChanged, this, [&](){ -#if !defined(Q_OS_ANDROID) - if (!getLoginDialogPoppedUp() && _desktopRootItemCreated) { -/* if (isHMDMode()) {*/ - //createAvatarInputsBar(); - //auto offscreenUi = getOffscreenUI(); - //offscreenUi->hide(AVATAR_INPUTS_BAR_QML.toString()); - //} else { - //destroyAvatarInputsBar(); - //auto offscreenUi = getOffscreenUI(); - //offscreenUi->show(AVATAR_INPUTS_BAR_QML.toString(), "AvatarInputsBar"); - /*}*/ - } -#endif - }); connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode); connect(this, &Application::activeDisplayPluginChanged, this, [&](){ if (getLoginDialogPoppedUp()) {