diff --git a/interface/resources/qml/+webengine/BrowserWebView.qml b/interface/resources/qml/+webengine/BrowserWebView.qml index fcf4b39a2e..0b93cf5af4 100644 --- a/interface/resources/qml/+webengine/BrowserWebView.qml +++ b/interface/resources/qml/+webengine/BrowserWebView.qml @@ -8,7 +8,6 @@ WebView { id: webview url: "https://vircadia.com/" profile: FileTypeProfile; - property var parentRoot: null // Create a global EventBridge object for raiseAndLowerKeyboard. diff --git a/interface/resources/qml/Web3DSurface.qml b/interface/resources/qml/Web3DSurface.qml index d58bcd2eba..e9c8d119d6 100644 --- a/interface/resources/qml/Web3DSurface.qml +++ b/interface/resources/qml/Web3DSurface.qml @@ -3,6 +3,7 @@ // // Created by David Rowe on 16 Dec 2016. // Copyright 2016 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -17,22 +18,31 @@ Item { anchors.fill: parent property string url: "" property string scriptUrl: null + property bool useBackground: true onUrlChanged: { - load(root.url, root.scriptUrl); + load(root.url, root.scriptUrl, root.useBackground); } onScriptUrlChanged: { if (root.item) { root.item.scriptUrl = root.scriptUrl; } else { - load(root.url, root.scriptUrl); + load(root.url, root.scriptUrl, root.useBackground); + } + } + + onUseBackgroundChanged: { + if (root.item) { + root.item.useBackground = root.useBackground; + } else { + load(root.url, root.scriptUrl, root.useBackground); } } property var item: null - function load(url, scriptUrl) { + function load(url, scriptUrl, useBackground) { // Ensure we reset any existing item to "about:blank" to ensure web audio stops: DEV-2375 if (root.item != null) { root.item.url = "about:blank" @@ -43,11 +53,12 @@ Item { root.item = newItem root.item.url = url root.item.scriptUrl = scriptUrl + root.item.useBackground = useBackground }) } Component.onCompleted: { - load(root.url, root.scriptUrl); + load(root.url, root.scriptUrl, root.useBackground); } signal sendToScript(var message); diff --git a/interface/resources/qml/controls/+webengine/FlickableWebViewCore.qml b/interface/resources/qml/controls/+webengine/FlickableWebViewCore.qml index e9546748c0..a0585ae053 100644 --- a/interface/resources/qml/controls/+webengine/FlickableWebViewCore.qml +++ b/interface/resources/qml/controls/+webengine/FlickableWebViewCore.qml @@ -16,6 +16,7 @@ Item { property alias webViewCoreProfile: webViewCore.profile property string webViewCoreUserAgent + property bool useBackground: webViewCore.useBackground property string userScriptUrl: "" property string urlTag: "noDownload=false"; @@ -98,6 +99,7 @@ Item { width: parent.width height: parent.height + backgroundColor: (flick.useBackground) ? "white" : "transparent" profile: HFWebEngineProfile; settings.pluginsEnabled: true diff --git a/interface/resources/qml/controls/FlickableWebViewCore.qml b/interface/resources/qml/controls/FlickableWebViewCore.qml index a844c8b624..35f3182f98 100644 --- a/interface/resources/qml/controls/FlickableWebViewCore.qml +++ b/interface/resources/qml/controls/FlickableWebViewCore.qml @@ -14,6 +14,7 @@ Item { property alias webViewCoreProfile: webViewCore.profile property string webViewCoreUserAgent + property bool useBackground: webViewCore.useBackground property string userScriptUrl: "" property string urlTag: "noDownload=false"; diff --git a/interface/resources/qml/controls/WebView.qml b/interface/resources/qml/controls/WebView.qml index 24ea11a906..b46c8c904d 100644 --- a/interface/resources/qml/controls/WebView.qml +++ b/interface/resources/qml/controls/WebView.qml @@ -23,6 +23,7 @@ Item { property bool passwordField: false property alias flickable: webroot.interactive property alias blurOnCtrlShift: webroot.blurOnCtrlShift + property alias useBackground: webroot.useBackground function stop() { webroot.stop(); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index a30d7adb18..b3231b906d 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -4,6 +4,7 @@ // // Created by Mark Peng on 8/16/13. // Copyright 2012 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -51,6 +52,7 @@ #include #include #include +#include #include "MyHead.h" #include "MySkeletonModel.h" diff --git a/interface/src/ui/ModelsBrowser.cpp b/interface/src/ui/ModelsBrowser.cpp index 6ee589f098..191fc1a09c 100644 --- a/interface/src/ui/ModelsBrowser.cpp +++ b/interface/src/ui/ModelsBrowser.cpp @@ -4,6 +4,7 @@ // // Created by Clement on 3/17/14. // Copyright 2014 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -33,7 +34,7 @@ const char* MODEL_TYPE_NAMES[] = { "entities", "heads", "skeletons", "skeletons", "attachments" }; static const QString S3_URL = NetworkingConstants::HF_PUBLIC_CDN_URL; -static const QString PUBLIC_URL = "http://public.highfidelity.io"; // Needs to change to Vircadia...? +static const QString PUBLIC_URL = "http://public.vircadia.com"; // Changed to Vircadia but not entirely sure what to do with this yet. static const QString MODELS_LOCATION = "models/"; static const QString PREFIX_PARAMETER_NAME = "prefix"; diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index c818eaf237..e88ebcf19a 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -1,6 +1,7 @@ // // Created by Bradley Austin Davis on 2015/05/12 // Copyright 2013 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -35,6 +36,9 @@ using namespace render::entities; const QString WebEntityRenderer::QML = "Web3DSurface.qml"; const char* WebEntityRenderer::URL_PROPERTY = "url"; +const char* WebEntityRenderer::SCRIPT_URL_PROPERTY = "scriptURL"; +const char* WebEntityRenderer::GLOBAL_POSITION_PROPERTY = "globalPosition"; +const char* WebEntityRenderer::USE_BACKGROUND_PROPERTY = "useBackground"; std::function&, bool&)> WebEntityRenderer::_acquireWebSurfaceOperator = nullptr; std::function&, bool&, std::vector&)> WebEntityRenderer::_releaseWebSurfaceOperator = nullptr; @@ -100,7 +104,7 @@ WebEntityRenderer::~WebEntityRenderer() { bool WebEntityRenderer::isTransparent() const { float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f; - return fadeRatio < OPAQUE_ALPHA_THRESHOLD || _alpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE; + return fadeRatio < OPAQUE_ALPHA_THRESHOLD || _alpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE || !_useBackground; } bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const { @@ -193,11 +197,15 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene if (_webSurface) { if (_webSurface->getRootItem()) { - if (_contentType == ContentType::HtmlContent && _sourceURL != newSourceURL) { + if (_contentType == ContentType::HtmlContent && _sourceURL != newSourceURL) { if (localSafeContext) { ::hifi::scripting::setLocalAccessSafeThread(true); } _webSurface->getRootItem()->setProperty(URL_PROPERTY, newSourceURL); + _webSurface->getRootItem()->setProperty(SCRIPT_URL_PROPERTY, _scriptURL); + _webSurface->getRootItem()->setProperty(USE_BACKGROUND_PROPERTY, _useBackground); + _webSurface->getSurfaceContext()->setContextProperty(GLOBAL_POSITION_PROPERTY, vec3toVariant(_contextPosition)); + _webSurface->setMaxFps((QUrl(newSourceURL).host().endsWith("youtube.com", Qt::CaseInsensitive)) ? YOUTUBE_MAX_FPS : _maxFPS); ::hifi::scripting::setLocalAccessSafeThread(false); _sourceURL = newSourceURL; } else if (_contentType != ContentType::HtmlContent) { @@ -207,7 +215,7 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene { auto scriptURL = entity->getScriptURL(); if (_scriptURL != scriptURL) { - _webSurface->getRootItem()->setProperty("scriptURL", _scriptURL); + _webSurface->getRootItem()->setProperty(SCRIPT_URL_PROPERTY, scriptURL); _scriptURL = scriptURL; } } @@ -226,10 +234,18 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene } } + { + auto useBackground = entity->getUseBackground(); + if (_useBackground != useBackground) { + _webSurface->getRootItem()->setProperty(USE_BACKGROUND_PROPERTY, useBackground); + _useBackground = useBackground; + } + } + { auto contextPosition = entity->getWorldPosition(); if (_contextPosition != contextPosition) { - _webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(contextPosition)); + _webSurface->getSurfaceContext()->setContextProperty(GLOBAL_POSITION_PROPERTY, vec3toVariant(contextPosition)); _contextPosition = contextPosition; } } @@ -290,12 +306,14 @@ void WebEntityRenderer::doRender(RenderArgs* args) { glm::vec4 color; Transform transform; bool forward; + bool transparent; withReadLock([&] { float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f; color = glm::vec4(toGlm(_color), _alpha * fadeRatio); color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created); transform = _renderTransform; forward = _renderLayer != RenderLayer::WORLD || args->_renderMethod == render::Args::FORWARD; + transparent = isTransparent(); }); if (color.a == 0.0f) { @@ -309,7 +327,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) { // Turn off jitter for these entities batch.pushProjectionJitter(); - DependencyManager::get()->bindWebBrowserProgram(batch, color.a < OPAQUE_ALPHA_THRESHOLD, forward); + DependencyManager::get()->bindWebBrowserProgram(batch, transparent, forward); DependencyManager::get()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, color, _geometryId); batch.popProjectionJitter(); batch.setResourceTexture(0, nullptr); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.h b/libraries/entities-renderer/src/RenderableWebEntityItem.h index 7118774d30..ffd5880c1e 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.h +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.h @@ -1,6 +1,7 @@ // // Created by Bradley Austin Davis on 2015/05/12 // Copyright 2013 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -32,6 +33,9 @@ public: static const QString QML; static const char* URL_PROPERTY; + static const char* SCRIPT_URL_PROPERTY; + static const char* GLOBAL_POSITION_PROPERTY; + static const char* USE_BACKGROUND_PROPERTY; static void setAcquireWebSurfaceOperator(std::function&, bool&)> acquireWebSurfaceOperator) { _acquireWebSurfaceOperator = acquireWebSurfaceOperator; } static void acquireWebSurface(const QString& url, bool htmlContent, QSharedPointer& webSurface, bool& cachedWebSurface) { @@ -93,6 +97,7 @@ private: uint16_t _dpi; QString _scriptURL; uint8_t _maxFPS; + bool _useBackground; WebInputMode _inputMode; glm::vec3 _contextPosition; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 08c7421842..ac4886db8f 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -602,6 +602,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_MAX_FPS, maxFPS); CHECK_PROPERTY_CHANGE(PROP_INPUT_MODE, inputMode); CHECK_PROPERTY_CHANGE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight); + CHECK_PROPERTY_CHANGE(PROP_WEB_USE_BACKGROUND, useBackground); // Polyline CHECK_PROPERTY_CHANGE(PROP_LINE_POINTS, linePoints); @@ -1383,6 +1384,9 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { * @property {WebInputMode} inputMode="touch" - The user input mode to use. * @property {boolean} showKeyboardFocusHighlight=true - true if the entity is highlighted when it has keyboard * focus, false if it isn't. + * @property {boolean} useBackground=true - true if the web entity should have a background, + * false if the web entity's background should be transparent. The webpage must have CSS properties for transparency set + * on the background-color for this property to have an effect. * @example Create a Web entity displaying at 1920 x 1080 resolution. * var METERS_TO_INCHES = 39.3701; * var entity = Entities.addEntity({ @@ -1820,6 +1824,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool 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); + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_WEB_USE_BACKGROUND, useBackground); } // PolyVoxel only @@ -2201,6 +2206,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(maxFPS, uint8_t, setMaxFPS); COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(inputMode, InputMode); COPY_PROPERTY_FROM_QSCRIPTVALUE(showKeyboardFocusHighlight, bool, setShowKeyboardFocusHighlight); + COPY_PROPERTY_FROM_QSCRIPTVALUE(useBackground, bool, setUseBackground); // Polyline COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints); @@ -2492,6 +2498,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) { COPY_PROPERTY_IF_CHANGED(maxFPS); COPY_PROPERTY_IF_CHANGED(inputMode); COPY_PROPERTY_IF_CHANGED(showKeyboardFocusHighlight); + COPY_PROPERTY_IF_CHANGED(useBackground); // Polyline COPY_PROPERTY_IF_CHANGED(linePoints); @@ -2891,6 +2898,7 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr 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); + ADD_PROPERTY_TO_MAP(PROP_WEB_USE_BACKGROUND, useBackground, useBackground, bool); // Polyline ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector); @@ -3321,6 +3329,7 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy 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()); + APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, properties.getUseBackground()); } if (properties.getType() == EntityTypes::Line) { @@ -3796,6 +3805,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int 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); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_WEB_USE_BACKGROUND, bool, setUseBackground); } if (properties.getType() == EntityTypes::Line) { @@ -4183,6 +4193,7 @@ void EntityItemProperties::markAllChanged() { _maxFPSChanged = true; _inputModeChanged = true; _showKeyboardFocusHighlightChanged = true; + _useBackgroundChanged = true; // Polyline _linePointsChanged = true; @@ -4873,6 +4884,9 @@ QList EntityItemProperties::listChangedProperties() { if (showKeyboardFocusHighlightChanged()) { out += "showKeyboardFocusHighlight"; } + if (useBackgroundChanged()) { + out += "useBackground"; + } // Shape if (shapeChanged()) { diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index efc8b5dc33..f7fde73430 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -4,6 +4,7 @@ // // Created by Brad Hefta-Gaub on 12/4/13. // Copyright 2013 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -365,6 +366,7 @@ public: 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); + DEFINE_PROPERTY_REF(PROP_WEB_USE_BACKGROUND, UseBackground, useBackground, 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 a7359c0bca..93bb8a89a7 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -4,6 +4,7 @@ // // Created by Brad Hefta-Gaub on 12/4/13. // Copyright 2013 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -317,6 +318,7 @@ enum EntityPropertyList { PROP_MAX_FPS = PROP_DERIVED_3, PROP_INPUT_MODE = PROP_DERIVED_4, PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT = PROP_DERIVED_5, + PROP_WEB_USE_BACKGROUND = PROP_DERIVED_6, // Polyline PROP_LINE_POINTS = PROP_DERIVED_0, diff --git a/libraries/entities/src/WebEntityItem.cpp b/libraries/entities/src/WebEntityItem.cpp index 73e0096e76..61a1ed18c5 100644 --- a/libraries/entities/src/WebEntityItem.cpp +++ b/libraries/entities/src/WebEntityItem.cpp @@ -1,6 +1,7 @@ // // Created by Bradley Austin Davis on 2015/05/12 // Copyright 2013 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -16,13 +17,14 @@ #include #include #include +#include #include "EntitiesLogging.h" #include "EntityItemProperties.h" #include "EntityTree.h" #include "EntityTreeElement.h" -const QString WebEntityItem::DEFAULT_SOURCE_URL = "http://www.google.com"; +const QString WebEntityItem::DEFAULT_SOURCE_URL = NetworkingConstants::WEB_ENTITY_DEFAULT_SOURCE_URL; const uint8_t WebEntityItem::DEFAULT_MAX_FPS = 10; EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { @@ -60,6 +62,7 @@ EntityItemProperties WebEntityItem::getProperties(const EntityPropertyFlags& des COPY_ENTITY_PROPERTY_TO_PROPERTIES(maxFPS, getMaxFPS); COPY_ENTITY_PROPERTY_TO_PROPERTIES(inputMode, getInputMode); COPY_ENTITY_PROPERTY_TO_PROPERTIES(showKeyboardFocusHighlight, getShowKeyboardFocusHighlight); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(useBackground, getUseBackground); return properties; } @@ -81,6 +84,7 @@ bool WebEntityItem::setSubClassProperties(const EntityItemProperties& properties SET_ENTITY_PROPERTY_FROM_PROPERTIES(maxFPS, setMaxFPS); SET_ENTITY_PROPERTY_FROM_PROPERTIES(inputMode, setInputMode); SET_ENTITY_PROPERTY_FROM_PROPERTIES(showKeyboardFocusHighlight, setShowKeyboardFocusHighlight); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(useBackground, setUseBackground); return somethingChanged; } @@ -110,6 +114,7 @@ int WebEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, i 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); + READ_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, bool, setUseBackground); return bytesRead; } @@ -127,6 +132,7 @@ EntityPropertyFlags WebEntityItem::getEntityProperties(EncodeBitstreamParams& pa requestedProperties += PROP_MAX_FPS; requestedProperties += PROP_INPUT_MODE; requestedProperties += PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT; + requestedProperties += PROP_WEB_USE_BACKGROUND; return requestedProperties; } @@ -153,6 +159,7 @@ void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst 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()); + APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, getUseBackground()); } glm::vec3 WebEntityItem::getRaycastDimensions() const { @@ -295,7 +302,7 @@ void WebEntityItem::setScriptURL(const QString& value) { auto newURL = QUrl::fromUserInput(value); if (!newURL.isValid()) { - qCDebug(entities) << "Not setting web entity script URL since" << value << "cannot be parsed to a valid URL."; + qCDebug(entities) << "Not setting web entity script URL since" << value << "cannot be parsed to a valid URL."; return; } @@ -347,6 +354,17 @@ bool WebEntityItem::getShowKeyboardFocusHighlight() const { return _showKeyboardFocusHighlight; } +void WebEntityItem::setUseBackground(bool value) { + withWriteLock([&] { + _needsRenderUpdate |= _useBackground != value; + _useBackground = value; + }); +} + +bool WebEntityItem::getUseBackground() const { + return resultWithReadLock([&] { return _useBackground; }); +} + PulsePropertyGroup WebEntityItem::getPulseProperties() const { return resultWithReadLock([&] { return _pulseProperties; diff --git a/libraries/entities/src/WebEntityItem.h b/libraries/entities/src/WebEntityItem.h index 5ab53d6ef8..4b39261bfb 100644 --- a/libraries/entities/src/WebEntityItem.h +++ b/libraries/entities/src/WebEntityItem.h @@ -1,6 +1,7 @@ // // Created by Bradley Austin Davis on 2015/05/12 // Copyright 2013 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -85,6 +86,9 @@ public: bool getShowKeyboardFocusHighlight() const; void setShowKeyboardFocusHighlight(bool value); + + bool getUseBackground() const; + void setUseBackground(bool value); PulsePropertyGroup getPulseProperties() const; @@ -100,6 +104,7 @@ protected: uint8_t _maxFPS; WebInputMode _inputMode; bool _showKeyboardFocusHighlight; + bool _useBackground; bool _localSafeContext { false }; }; diff --git a/libraries/networking/src/NetworkingConstants.h b/libraries/networking/src/NetworkingConstants.h index 0766965a44..58cefb35ad 100644 --- a/libraries/networking/src/NetworkingConstants.h +++ b/libraries/networking/src/NetworkingConstants.h @@ -43,6 +43,11 @@ namespace NetworkingConstants { const QUrl BUILDS_XML_URL("https://highfidelity.com/builds.xml"); const QUrl MASTER_BUILDS_XML_URL("https://highfidelity.com/dev-builds.xml"); + + // WebEntity Defaults + const QString WEB_ENTITY_DEFAULT_SOURCE_URL = "https://vircadia.com/"; + + const QString DEFAULT_AVATAR_COLLISION_SOUND_URL = "https://hifi-public.s3.amazonaws.com/sounds/Collisions-otherorganic/Body_Hits_Impact.wav"; // CDN URLs const QString HF_CONTENT_CDN_URL = "https://cdn-1.vircadia.com/eu-c-1/vircadia-content/"; diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index a34be09db7..fc74f4459c 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -4,6 +4,7 @@ // // Created by Stephen Birarda on 4/8/13. // Copyright 2013 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -281,6 +282,7 @@ enum class EntityVersion : PacketVersion { ScreenshareZone, ZoneOcclusion, ModelBlendshapes, + TransparentWeb, // Add new versions above here NUM_PACKET_TYPE, diff --git a/scripts/system/create/assets/data/createAppTooltips.json b/scripts/system/create/assets/data/createAppTooltips.json index 8e53823cd8..478793ab78 100644 --- a/scripts/system/create/assets/data/createAppTooltips.json +++ b/scripts/system/create/assets/data/createAppTooltips.json @@ -607,6 +607,9 @@ "webAlpha": { "tooltip": "The opacity of the web entity between 0.0 fully transparent and 1.0 completely opaque." }, + "useBackground": { + "tooltip": "If disabled, this web entity will support a transparent background for the webpage and its elements if the CSS property of 'background-color' on the 'body' is set with transparency." + }, "maxFPS": { "tooltip": "The FPS at which to render the web entity. Higher values will have a performance impact." }, diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index f6dcf10bc8..8364d5b155 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -762,6 +762,11 @@ const GROUPS = [ min: 0, max: 1, }, + { + label: "Use Background", + type: "bool", + propertyID: "useBackground", + }, { label: "Max FPS", type: "number-draggable",