diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4d4d76172a..138d415515 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4314,7 +4314,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { buttons, event->modifiers()); if (compositor.getReticleVisible() || !isHMDMode() || !compositor.getReticleOverDesktop() || - !getOverlays().getOverlayAtPoint(glm::vec2(transformedPos.x(), transformedPos.y())).isNull()) { + getOverlays().getOverlayAtPoint(glm::vec2(transformedPos.x(), transformedPos.y())) != UNKNOWN_ENTITY_ID) { getEntities()->mouseMoveEvent(&mappedEvent); getOverlays().mouseMoveEvent(&mappedEvent); } @@ -5756,8 +5756,11 @@ void Application::setKeyboardFocusEntity(const QUuid& id) { return; } + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_VISIBLE; + desiredProperties += PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT; auto properties = entityScriptingInterface->getEntityProperties(id); - if (!properties.getLocked() && properties.getVisible()) { + if (properties.getVisible() && properties.getShowKeyboardFocusHighlight()) { auto entities = getEntities(); auto entityId = _keyboardFocusedEntity.get(); if (entities->wantsKeyboardFocus(entityId)) { diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index e55ebcc159..c677c3dbb5 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -740,7 +740,8 @@ bool Overlays::editOverlay(const QUuid& id, const QVariant& properties) { } auto entityScriptingInterface = DependencyManager::get(); - EntityItemProperties entityProperties = convertOverlayToEntityProperties(properties.toMap(), entityScriptingInterface->getEntityType(id), false, id); + auto propertyMap = properties.toMap(); + EntityItemProperties entityProperties = convertOverlayToEntityProperties(propertyMap, entityScriptingInterface->getEntityType(id), false, id); return !entityScriptingInterface->editEntity(id, entityProperties).isNull(); } @@ -766,7 +767,8 @@ bool Overlays::editOverlays(const QVariant& propertiesById) { } overlay->setProperties(properties.toMap()); } else { - entityScriptingInterface->editEntity(id, convertOverlayToEntityProperties(properties.toMap(), entityScriptingInterface->getEntityType(id), false, id)); + auto propertyMap = properties.toMap(); + entityScriptingInterface->editEntity(id, convertOverlayToEntityProperties(propertyMap, entityScriptingInterface->getEntityType(id), false, id)); } } diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 8d4ba3ea4e..4403237fb7 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -115,35 +115,39 @@ bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointe } } - if (_color != entity->getColor()) { - return true; - } + if(resultWithReadLock([&] { + if (_color != entity->getColor()) { + return true; + } - if (_alpha != entity->getAlpha()) { - return true; - } + if (_alpha != entity->getAlpha()) { + return true; + } - if (_sourceURL != entity->getSourceUrl()) { - return true; - } + if (_sourceURL != entity->getSourceUrl()) { + return true; + } - if (_dpi != entity->getDPI()) { - return true; - } + if (_dpi != entity->getDPI()) { + return true; + } - if (_scriptURL != entity->getScriptURL()) { - return true; - } + if (_scriptURL != entity->getScriptURL()) { + return true; + } - if (_maxFPS != entity->getMaxFPS()) { - return true; - } + if (_maxFPS != entity->getMaxFPS()) { + return true; + } - if (_inputMode != entity->getInputMode()) { - return true; - } + if (_inputMode != entity->getInputMode()) { + return true; + } - if (_pulseProperties != entity->getPulseProperties()) { + if (_pulseProperties != entity->getPulseProperties()) { + return true; + } + })) { return true; } @@ -185,17 +189,14 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene ContentType currentContentType; withReadLock([&] { urlChanged = _sourceURL != newSourceURL; - currentContentType = _contentType; }); + currentContentType = _contentType; if (urlChanged) { - if (!_loading && (newContentType != ContentType::HtmlContent || currentContentType != ContentType::HtmlContent)) { + if (newContentType != ContentType::HtmlContent || currentContentType != ContentType::HtmlContent) { destroyWebSurface(); } - - withWriteLock([&] { - _contentType = newContentType; - }); + _contentType = newContentType; } } @@ -214,16 +215,14 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene // This work must be done on the main thread if (!_webSurface) { buildWebSurface(entity, newSourceURL); - _loading = true; } if (_webSurface) { if (_webSurface->getRootItem()) { - _loading = false; if (_contentType == ContentType::HtmlContent && urlChanged) { _webSurface->getRootItem()->setProperty(URL_PROPERTY, newSourceURL); - _sourceURL = newSourceURL; } + _sourceURL = newSourceURL; { auto scriptURL = entity->getScriptURL(); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.h b/libraries/entities-renderer/src/RenderableWebEntityItem.h index b97ad98502..e5eff5818b 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.h +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.h @@ -77,7 +77,6 @@ private: }; static ContentType getContentType(const QString& urlString); ContentType _contentType { ContentType::NoContent }; - bool _loading { false }; QSharedPointer _webSurface { nullptr }; bool _cachedWebSurface { false }; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 0c8396f405..fbc897d8ae 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -642,6 +642,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_SCRIPT_URL, scriptURL); CHECK_PROPERTY_CHANGE(PROP_MAX_FPS, maxFPS); CHECK_PROPERTY_CHANGE(PROP_INPUT_MODE, inputMode); + CHECK_PROPERTY_CHANGE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight); // Polyline CHECK_PROPERTY_CHANGE(PROP_LINE_POINTS, linePoints); @@ -1345,6 +1346,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { * @property {number} maxFPS=10 - The maximum update rate for the Web content, in frames/second. * @property {WebInputMode} inputMode="touch" - The user input mode to use. * @property {Entities.Pulse} pulse - The pulse-related properties. Deprecated. + * @property {boolean} showKeyboardFocusHighlight - Whether or not to show the keyboard focus highlight when this entity has focus. * @example Create a Web entity displaying at 1920 x 1080 resolution. * var METERS_TO_INCHES = 39.3701; * var entity = Entities.addEntity({ @@ -1764,6 +1766,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SCRIPT_URL, scriptURL); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_MAX_FPS, maxFPS); COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_INPUT_MODE, inputMode, getInputModeAsString()); + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight); } // PolyVoxel only @@ -2131,6 +2134,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(scriptURL, QString, setScriptURL); COPY_PROPERTY_FROM_QSCRIPTVALUE(maxFPS, uint8_t, setMaxFPS); COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(inputMode, InputMode); + COPY_PROPERTY_FROM_QSCRIPTVALUE(showKeyboardFocusHighlight, bool, setShowKeyboardFocusHighlight); // Polyline COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints); @@ -2409,6 +2413,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) { COPY_PROPERTY_IF_CHANGED(scriptURL); COPY_PROPERTY_IF_CHANGED(maxFPS); COPY_PROPERTY_IF_CHANGED(inputMode); + COPY_PROPERTY_IF_CHANGED(showKeyboardFocusHighlight); // Polyline COPY_PROPERTY_IF_CHANGED(linePoints); @@ -2793,6 +2798,7 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr ADD_PROPERTY_TO_MAP(PROP_SCRIPT_URL, ScriptURL, scriptURL, QString); ADD_PROPERTY_TO_MAP(PROP_MAX_FPS, MaxFPS, maxFPS, uint8_t); ADD_PROPERTY_TO_MAP(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode); + ADD_PROPERTY_TO_MAP(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, ShowKeyboardFocusHighlight, showKeyboardFocusHighlight, bool); // Polyline ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector); @@ -3201,6 +3207,7 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy APPEND_ENTITY_PROPERTY(PROP_SCRIPT_URL, properties.getScriptURL()); APPEND_ENTITY_PROPERTY(PROP_MAX_FPS, properties.getMaxFPS()); APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)properties.getInputMode()); + APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, properties.getShowKeyboardFocusHighlight()); } if (properties.getType() == EntityTypes::Line) { @@ -3661,6 +3668,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SCRIPT_URL, QString, setScriptURL); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MAX_FPS, uint8_t, setMaxFPS); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_INPUT_MODE, WebInputMode, setInputMode); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight); } if (properties.getType() == EntityTypes::Line) { @@ -4035,6 +4043,7 @@ void EntityItemProperties::markAllChanged() { _scriptURLChanged = true; _maxFPSChanged = true; _inputModeChanged = true; + _showKeyboardFocusHighlightChanged = true; // Polyline _linePointsChanged = true; @@ -4686,6 +4695,9 @@ QList EntityItemProperties::listChangedProperties() { if (faceCameraChanged()) { out += "faceCamera"; } + if (showKeyboardFocusHighlightChanged()) { + out += "showKeyboardFocusHighlight"; + } // Shape if (shapeChanged()) { diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index dcba60b004..58fe63cf40 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -341,6 +341,7 @@ public: DEFINE_PROPERTY_REF(PROP_SCRIPT_URL, ScriptURL, scriptURL, QString, ""); DEFINE_PROPERTY_REF(PROP_MAX_FPS, MaxFPS, maxFPS, uint8_t, WebEntityItem::DEFAULT_MAX_FPS); DEFINE_PROPERTY_REF_ENUM(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode, WebInputMode::TOUCH); + DEFINE_PROPERTY_REF(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, ShowKeyboardFocusHighlight, showKeyboardFocusHighlight, bool, true); // Polyline DEFINE_PROPERTY_REF(PROP_LINE_POINTS, LinePoints, linePoints, QVector, ENTITY_ITEM_DEFAULT_EMPTY_VEC3_QVEC); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index b11ecff5bb..5cf809e38e 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -296,6 +296,7 @@ enum EntityPropertyList { PROP_SCRIPT_URL = PROP_DERIVED_2, PROP_MAX_FPS = PROP_DERIVED_3, PROP_INPUT_MODE = PROP_DERIVED_4, + PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT = PROP_DERIVED_5, // Polyline PROP_LINE_POINTS = PROP_DERIVED_0, diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index 6157d3663a..1853d0fa73 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -270,12 +270,12 @@ public slots: */ Q_INVOKABLE QUuid addEntity(const EntityItemProperties& properties, const QString& entityHostTypeString) { entity::HostType entityHostType; - if (entityHostTypeString == "domain") { - entityHostType = entity::HostType::DOMAIN; + if (entityHostTypeString == "local") { + entityHostType = entity::HostType::LOCAL; } else if (entityHostTypeString == "avatar") { entityHostType = entity::HostType::AVATAR; - } else if (entityHostTypeString == "local") { - entityHostType = entity::HostType::LOCAL; + } else { + entityHostType = entity::HostType::DOMAIN; } return addEntityInternal(properties, entityHostType); } diff --git a/libraries/entities/src/WebEntityItem.cpp b/libraries/entities/src/WebEntityItem.cpp index 21d8b876f0..51b78aaec7 100644 --- a/libraries/entities/src/WebEntityItem.cpp +++ b/libraries/entities/src/WebEntityItem.cpp @@ -54,6 +54,7 @@ EntityItemProperties WebEntityItem::getProperties(const EntityPropertyFlags& des COPY_ENTITY_PROPERTY_TO_PROPERTIES(scriptURL, getScriptURL); COPY_ENTITY_PROPERTY_TO_PROPERTIES(maxFPS, getMaxFPS); COPY_ENTITY_PROPERTY_TO_PROPERTIES(inputMode, getInputMode); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(showKeyboardFocusHighlight, getShowKeyboardFocusHighlight); return properties; } @@ -73,6 +74,7 @@ bool WebEntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(scriptURL, setScriptURL); SET_ENTITY_PROPERTY_FROM_PROPERTIES(maxFPS, setMaxFPS); SET_ENTITY_PROPERTY_FROM_PROPERTIES(inputMode, setInputMode); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(showKeyboardFocusHighlight, setShowKeyboardFocusHighlight); if (somethingChanged) { bool wantDebug = false; @@ -111,6 +113,7 @@ int WebEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, i READ_ENTITY_PROPERTY(PROP_SCRIPT_URL, QString, setScriptURL); READ_ENTITY_PROPERTY(PROP_MAX_FPS, uint8_t, setMaxFPS); READ_ENTITY_PROPERTY(PROP_INPUT_MODE, WebInputMode, setInputMode); + READ_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight); return bytesRead; } @@ -126,6 +129,7 @@ EntityPropertyFlags WebEntityItem::getEntityProperties(EncodeBitstreamParams& pa requestedProperties += PROP_SCRIPT_URL; requestedProperties += PROP_MAX_FPS; requestedProperties += PROP_INPUT_MODE; + requestedProperties += PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT; return requestedProperties; } @@ -150,6 +154,7 @@ void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst APPEND_ENTITY_PROPERTY(PROP_SCRIPT_URL, getScriptURL()); APPEND_ENTITY_PROPERTY(PROP_MAX_FPS, getMaxFPS()); APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)getInputMode()); + APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, getShowKeyboardFocusHighlight()); } bool WebEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, @@ -298,6 +303,18 @@ WebInputMode WebEntityItem::getInputMode() const { }); } +void WebEntityItem::setShowKeyboardFocusHighlight(bool value) { + withWriteLock([&] { + _showKeyboardFocusHighlight = value; + }); +} + +bool WebEntityItem::getShowKeyboardFocusHighlight() const { + return resultWithReadLock([&] { + return _showKeyboardFocusHighlight; + }); +} + PulsePropertyGroup WebEntityItem::getPulseProperties() const { return resultWithReadLock([&] { return _pulseProperties; diff --git a/libraries/entities/src/WebEntityItem.h b/libraries/entities/src/WebEntityItem.h index a0a2d65253..86b2377c90 100644 --- a/libraries/entities/src/WebEntityItem.h +++ b/libraries/entities/src/WebEntityItem.h @@ -77,6 +77,9 @@ public: void setInputMode(const WebInputMode& value); WebInputMode getInputMode() const; + bool getShowKeyboardFocusHighlight() const; + void setShowKeyboardFocusHighlight(bool value); + PulsePropertyGroup getPulseProperties() const; protected: @@ -89,6 +92,7 @@ protected: QString _scriptURL; uint8_t _maxFPS; WebInputMode _inputMode; + bool _showKeyboardFocusHighlight; }; #endif // hifi_WebEntityItem_h diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index d898c03597..0697fe8885 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -260,6 +260,7 @@ enum class EntityVersion : PacketVersion { MissingWebEntityProperties, PulseProperties, RingGizmoEntities, + ShowKeyboardFocusHighlight, // Add new versions above here NUM_PACKET_TYPE, diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index c0b28cbf9c..4cbc44bc2b 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -1154,7 +1154,6 @@ SelectionDisplay = (function() { var result = testRayIntersect(pickRay, allOverlays); var pickedColor; var highlightNeeded = false; - print(JSON.stringify(result)); if (result.intersects) { switch (result.overlayID) {