From 358aa547b17a6d6b578743d79c6cf571b5f389c3 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Mon, 5 Nov 2018 16:30:30 -0800 Subject: [PATCH] feedback changes --- interface/resources/config/keyboard.json | 4 +- .../resources/qml/controls/TabletWebView.qml | 4 + .../qml/dialogs/TabletLoginDialog.qml | 16 +++ .../qml/hifi/commerce/wallet/Wallet.qml | 2 +- interface/src/Application.cpp | 2 + .../src/raypick/PointerScriptingInterface.cpp | 4 +- interface/src/ui/Keyboard.cpp | 97 +++++++++++++++++-- interface/src/ui/Keyboard.h | 3 + interface/src/ui/PreferencesDialog.cpp | 1 - libraries/shared/src/RegisteredMetaTypes.h | 4 +- 10 files changed, 121 insertions(+), 16 deletions(-) diff --git a/interface/resources/config/keyboard.json b/interface/resources/config/keyboard.json index ba113da1f5..186a9c1084 100644 --- a/interface/resources/config/keyboard.json +++ b/interface/resources/config/keyboard.json @@ -31,8 +31,8 @@ "localOrientation": { "w": 0.000, "x": 0.000, - "y": 0.976, - "z": 0.216 + "y": 0.906, + "z": 0.423 }, "leftMargin": 0.0, "rightMargin": 0.0, diff --git a/interface/resources/qml/controls/TabletWebView.qml b/interface/resources/qml/controls/TabletWebView.qml index 0c5ca37e00..94f4c7978c 100644 --- a/interface/resources/qml/controls/TabletWebView.qml +++ b/interface/resources/qml/controls/TabletWebView.qml @@ -195,6 +195,10 @@ Item { keyboardEnabled = HMD.active; } + Component.onDestruction: { + keyboardRaised = false; + } + Keys.onPressed: { switch(event.key) { case Qt.Key_L: diff --git a/interface/resources/qml/dialogs/TabletLoginDialog.qml b/interface/resources/qml/dialogs/TabletLoginDialog.qml index 08aa903ae9..dad2bb91aa 100644 --- a/interface/resources/qml/dialogs/TabletLoginDialog.qml +++ b/interface/resources/qml/dialogs/TabletLoginDialog.qml @@ -95,6 +95,18 @@ TabletModalWindow { } } + Timer { + id: keyboardTimer + repeat: false + interval: 200 + + onTriggered: { + if (MenuInterface.isOptionChecked("Use 3D Keyboard")) { + KeyboardScriptingInterface.raised = true; + } + } + } + TabletModalFrame { id: mfRoot @@ -131,6 +143,10 @@ TabletModalWindow { loginKeyboard.raised = false; } + Component.onCompleted: { + keyboardTimer.start(); + } + Keyboard { id: loginKeyboard raised: root.keyboardEnabled && root.keyboardRaised diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index 874c1c53b7..81fec4ace3 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -41,7 +41,7 @@ Rectangle { } Component.onDestruction: { - keyboard.raised = false; + KeyboardScriptingInterface.raised = false; } Connections { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ccefb3c772..afb2bde7f3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2644,6 +2644,7 @@ void Application::cleanupBeforeQuit() { // it accesses the PickManager to delete its associated Pick DependencyManager::destroy(); DependencyManager::destroy(); + DependencyManager::destroy(); DependencyManager::destroy(); qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete"; @@ -2929,6 +2930,7 @@ void Application::initializeRenderEngine() { // Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success. DependencyManager::get()->initializeShapePipelines(); + DependencyManager::get()->registerKeyboardHighlighting(); }); } diff --git a/interface/src/raypick/PointerScriptingInterface.cpp b/interface/src/raypick/PointerScriptingInterface.cpp index 1893132917..0009536479 100644 --- a/interface/src/raypick/PointerScriptingInterface.cpp +++ b/interface/src/raypick/PointerScriptingInterface.cpp @@ -56,14 +56,14 @@ unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType& * @property {boolean} [hover=false] If this pointer should generate hover events. * @property {boolean} [enabled=false] * @property {Vec3} [tipOffset] The specified offset of the from the joint index. - * @property {Pointers.StylusPointerProperties.model} [model] Data to replace the default model url, positionOffset and rotationOffset. {@link Pointers.StylusPointerProperties.model} + * @property {Pointers.StylusPointerProperties.model} [model] Data to replace the default model url, positionOffset and rotationOffset. */ /**jsdoc * properties defining stylus pick model that can be included to {@link Pointers.StylusPointerProperties} * @typedef {object} Pointers.StylusPointerProperties.model * @property {string} [url] url to the model * @property {Vec3} [dimensions] the dimensions of the model - * @property {Vec3} [positionOffset] the position offset of the model from the parent joint index + * @property {Vec3} [positionOffset] the position offset of the model from the stylus tip. * @property {Vec3} [rotationOffset] the rotation offset of the model from the parent joint index */ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties) const { diff --git a/interface/src/ui/Keyboard.cpp b/interface/src/ui/Keyboard.cpp index c00ea007f0..773253f85c 100644 --- a/interface/src/ui/Keyboard.cpp +++ b/interface/src/ui/Keyboard.cpp @@ -44,6 +44,7 @@ #include "raypick/PickScriptingInterface.h" #include "scripting/HMDScriptingInterface.h" #include "scripting/WindowScriptingInterface.h" +#include "scripting/SelectionScriptingInterface.h" #include "DependencyManager.h" #include "raypick/StylusPointer.h" @@ -53,12 +54,12 @@ static const int LEFT_HAND_CONTROLLER_INDEX = 0; static const int RIGHT_HAND_CONTROLLER_INDEX = 1; -static const float MALLET_LENGTH = 0.4f; -static const float MALLET_TOUCH_Y_OFFSET = 0.105f; -static const float MALLET_Y_OFFSET = 0.35f; +static const float MALLET_LENGTH = 0.2f; +static const float MALLET_TOUCH_Y_OFFSET = 0.052f; +static const float MALLET_Y_OFFSET = 0.180f; static const glm::quat MALLET_ROTATION_OFFSET{0.70710678f, 0.0f, -0.70710678f, 0.0f}; -static const glm::vec3 MALLET_MODEL_DIMENSIONS{0.05f, MALLET_LENGTH, 0.05f}; +static const glm::vec3 MALLET_MODEL_DIMENSIONS{0.03f, MALLET_LENGTH, 0.03f}; static const glm::vec3 MALLET_POSITION_OFFSET{0.0f, -MALLET_Y_OFFSET / 2.0f, 0.0f}; static const glm::vec3 MALLET_TIP_OFFSET{0.0f, MALLET_LENGTH - MALLET_TOUCH_Y_OFFSET, 0.0f}; @@ -88,6 +89,28 @@ static const QString BACKSPACE_STRING = "backspace"; static const QString SPACE_STRING = "space"; static const QString ENTER_STRING = "enter"; +static const QString KEY_HOVER_HIGHLIGHT = "keyHoverHiglight"; +static const QString KEY_PRESSED_HIGHLIGHT = "keyPressesHighlight"; +static const QVariantMap KEY_HOVERING_STYLE { + { "isOutlineSmooth", true }, + { "outlineWidth", 3 }, + { "outlineUnoccludedColor", QVariantMap {{"red", 13}, {"green", 152}, {"blue", 186}}}, + { "outlineUnoccludedAlpha", 1.0 }, + { "outlineOccludedAlpha", 0.0 }, + { "fillUnoccludedAlpha", 0.0 }, + { "fillOccludedAlpha", 0.0 } +}; + +static const QVariantMap KEY_PRESSING_STYLE { + { "isOutlineSmooth", true }, + { "outlineWidth", 3 }, + { "fillUnoccludedColor", QVariantMap {{"red", 50}, {"green", 50}, {"blue", 50}}}, + { "outlineUnoccludedAlpha", 0.0 }, + { "outlineOccludedAlpha", 0.0 }, + { "fillUnoccludedAlpha", 0.6 }, + { "fillOccludedAlpha", 0.0 } +}; + std::pair calculateKeyboardPositionAndOrientation() { auto myAvatar = DependencyManager::get()->getMyAvatar(); auto hmd = DependencyManager::get(); @@ -201,10 +224,20 @@ Keyboard::Keyboard() { connect(pointerManager.data(), &PointerManager::triggerBeginOverlay, this, &Keyboard::handleTriggerBegin, Qt::QueuedConnection); connect(pointerManager.data(), &PointerManager::triggerContinueOverlay, this, &Keyboard::handleTriggerContinue, Qt::QueuedConnection); connect(pointerManager.data(), &PointerManager::triggerEndOverlay, this, &Keyboard::handleTriggerEnd, Qt::QueuedConnection); + connect(pointerManager.data(), &PointerManager::hoverBeginOverlay, this, &Keyboard::handleHoverBegin, Qt::QueuedConnection); + connect(pointerManager.data(), &PointerManager::hoverEndOverlay, this, &Keyboard::handleHoverEnd, Qt::QueuedConnection); connect(myAvatar.get(), &MyAvatar::sensorToWorldScaleChanged, this, &Keyboard::scaleKeyboard, Qt::QueuedConnection); connect(windowScriptingInterface.data(), &WindowScriptingInterface::domainChanged, [&]() { setRaised(false); }); } +void Keyboard::registerKeyboardHighlighting() { + auto selection = DependencyManager::get(); + selection->enableListHighlight(KEY_HOVER_HIGHLIGHT, KEY_HOVERING_STYLE); + selection->enableListToScene(KEY_HOVER_HIGHLIGHT); + selection->enableListHighlight(KEY_PRESSED_HIGHLIGHT, KEY_PRESSING_STYLE); + selection->enableListToScene(KEY_PRESSED_HIGHLIGHT); +} + void Keyboard::createKeyboard() { auto pointerManager = DependencyManager::get(); @@ -450,7 +483,7 @@ void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent AudioInjectorOptions audioOptions; audioOptions.localOnly = true; audioOptions.position = keyWorldPosition; - audioOptions.volume = 0.4f; + audioOptions.volume = 0.1f; AudioInjector::playSound(_keySound->getByteArray(), audioOptions); @@ -504,6 +537,8 @@ void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent QCoreApplication::postEvent(QCoreApplication::instance(), releaseEvent); key.startTimer(KEY_PRESS_TIMEOUT_MS); + auto selection = DependencyManager::get(); + selection->addToSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "overlay", overlayID); } } @@ -536,6 +571,9 @@ void Keyboard::handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& if (key.timerFinished()) { key.startTimer(KEY_PRESS_TIMEOUT_MS); } + + auto selection = DependencyManager::get(); + selection->removeFromSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "overlay", overlayID); } void Keyboard::handleTriggerContinue(const OverlayID& overlayID, const PointerEvent& event) { @@ -565,9 +603,8 @@ void Keyboard::handleTriggerContinue(const OverlayID& overlayID, const PointerEv if (base3DOverlay) { auto pointerManager = DependencyManager::get(); auto pickResult = pointerManager->getPrevPickResult(pointerID); - auto pickResultVariant = pickResult->toVariantMap(); - - float distance = pickResultVariant["distance"].toFloat(); + auto stylusPickResult = std::dynamic_pointer_cast(pickResult); + float distance = stylusPickResult->distance; static const float PENATRATION_THRESHOLD = 0.025f; if (distance < PENATRATION_THRESHOLD) { @@ -583,6 +620,50 @@ void Keyboard::handleTriggerContinue(const OverlayID& overlayID, const PointerEv } } +void Keyboard::handleHoverBegin(const OverlayID& overlayID, const PointerEvent& event) { + if (_keyboardLayers.empty() || !isLayerSwitchTimerFinished()) { + return; + } + + auto pointerID = event.getID(); + + if (pointerID != _leftHandStylus && pointerID != _rightHandStylus) { + return; + } + + auto& keyboardLayer = _keyboardLayers[_layerIndex]; + auto search = keyboardLayer.find(overlayID); + + if (search == keyboardLayer.end()) { + return; + } + + auto selection = DependencyManager::get(); + selection->addToSelectedItemsList(KEY_HOVER_HIGHLIGHT, "overlay", overlayID); +} + +void Keyboard::handleHoverEnd(const OverlayID& overlayID, const PointerEvent& event) { + if (_keyboardLayers.empty() || !isLayerSwitchTimerFinished()) { + return; + } + + auto pointerID = event.getID(); + + if (pointerID != _leftHandStylus && pointerID != _rightHandStylus) { + return; + } + + auto& keyboardLayer = _keyboardLayers[_layerIndex]; + auto search = keyboardLayer.find(overlayID); + + if (search == keyboardLayer.end()) { + return; + } + + auto selection = DependencyManager::get(); + selection->removeFromSelectedItemsList(KEY_HOVER_HIGHLIGHT, "overlay", overlayID); +} + void Keyboard::disableStylus() { auto pointerManager = DependencyManager::get(); pointerManager->setRenderState(_leftHandStylus, "events off"); diff --git a/interface/src/ui/Keyboard.h b/interface/src/ui/Keyboard.h index 2a29a12961..18db38b2ae 100644 --- a/interface/src/ui/Keyboard.h +++ b/interface/src/ui/Keyboard.h @@ -90,6 +90,7 @@ class Keyboard : public Dependency, public QObject, public ReadWriteLockable { public: Keyboard(); void createKeyboard(); + void registerKeyboardHighlighting(); bool isRaised() const; void setRaised(bool raised); @@ -103,6 +104,8 @@ public slots: void handleTriggerBegin(const OverlayID& overlayID, const PointerEvent& event); void handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& event); void handleTriggerContinue(const OverlayID& overlayID, const PointerEvent& event); + void handleHoverBegin(const OverlayID& overlayID, const PointerEvent& event); + void handleHoverEnd(const OverlayID& overlayID, const PointerEvent& event); void scaleKeyboard(float sensorToWorldScale); private: diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 34d80f50cf..d71ad9dc82 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -147,7 +147,6 @@ void setupPreferences() { preferences->addPreference(new CheckPreference(UI_CATEGORY, "Prefer Avatar Finger Over Stylus", getter, setter)); } */ - // Snapshots static const QString SNAPSHOTS { "Snapshots" }; { diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index 18c1339223..ed637fe771 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -280,8 +280,8 @@ public: StylusTip(const bilateral::Side& side, const glm::vec3& tipOffset = Vectors::ZERO ,const glm::vec3& position = Vectors::ZERO, const glm::quat& orientation = Quaternions::IDENTITY, const glm::vec3& velocity = Vectors::ZERO) : side(side), tipOffset(tipOffset), position(position), orientation(orientation), velocity(velocity) {} - StylusTip(const QVariantMap& pickVariant) : side(bilateral::Side(pickVariant["side"].toInt())), position(vec3FromVariant(pickVariant["position"])), - orientation(quatFromVariant(pickVariant["orientation"])), velocity(vec3FromVariant(pickVariant["velocity"])) {} + StylusTip(const QVariantMap& pickVariant) : side(bilateral::Side(pickVariant["side"].toInt())), tipOffset(vec3FromVariant(pickVariant["tipOffset"])), + position(vec3FromVariant(pickVariant["position"])), orientation(quatFromVariant(pickVariant["orientation"])), velocity(vec3FromVariant(pickVariant["velocity"])) {} bilateral::Side side { bilateral::Side::Invalid }; glm::vec3 tipOffset;