mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
useBackground property added.
This commit is contained in:
parent
7e5e513dc1
commit
b05cb8b6ac
11 changed files with 48 additions and 52 deletions
|
@ -18,31 +18,31 @@ Item {
|
|||
anchors.fill: parent
|
||||
property string url: ""
|
||||
property string scriptUrl: null
|
||||
property string webBackgroundColor: "#FFFFFFFF"
|
||||
property bool useBackground: true
|
||||
|
||||
onUrlChanged: {
|
||||
load(root.url, root.scriptUrl, root.webBackgroundColor);
|
||||
load(root.url, root.scriptUrl, root.useBackground);
|
||||
}
|
||||
|
||||
onScriptUrlChanged: {
|
||||
if (root.item) {
|
||||
root.item.scriptUrl = root.scriptUrl;
|
||||
} else {
|
||||
load(root.url, root.scriptUrl, root.webBackgroundColor);
|
||||
load(root.url, root.scriptUrl, root.useBackground);
|
||||
}
|
||||
}
|
||||
|
||||
onWebBackgroundColorChanged: {
|
||||
onUseBackgroundChanged: {
|
||||
if (root.item) {
|
||||
root.item.webBackgroundColor = root.webBackgroundColor;
|
||||
root.item.useBackground = root.useBackground;
|
||||
} else {
|
||||
load(root.url, root.scriptUrl, root.webBackgroundColor);
|
||||
load(root.url, root.scriptUrl, root.useBackground);
|
||||
}
|
||||
}
|
||||
|
||||
property var item: null
|
||||
|
||||
function load(url, scriptUrl, webBackgroundColor) {
|
||||
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"
|
||||
|
@ -53,12 +53,12 @@ Item {
|
|||
root.item = newItem
|
||||
root.item.url = url
|
||||
root.item.scriptUrl = scriptUrl
|
||||
root.item.transparentBackground = webBackgroundColor.startsWith("#FF") ? false : true
|
||||
root.item.useBackground = useBackground
|
||||
})
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
load(root.url, root.scriptUrl, root.webBackgroundColor);
|
||||
load(root.url, root.scriptUrl, root.useBackground);
|
||||
}
|
||||
|
||||
signal sendToScript(var message);
|
||||
|
|
|
@ -15,8 +15,8 @@ Item {
|
|||
property alias webViewCore: webViewCore
|
||||
property alias webViewCoreProfile: webViewCore.profile
|
||||
property string webViewCoreUserAgent
|
||||
property string webBackgroundColor: "#FFFFFFFF" // Fully opaque white.
|
||||
|
||||
property bool useBackground: true
|
||||
property string userScriptUrl: ""
|
||||
property string urlTag: "noDownload=false";
|
||||
|
||||
|
@ -99,10 +99,7 @@ Item {
|
|||
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
//backgroundColor: "transparent"
|
||||
//backgroundColor: "#FFFF00CC"
|
||||
backgroundColor: flick.webBackgroundColor
|
||||
//backgroundColor: Qt.rgba(0.502, 0.502, 0.502, 0.502)
|
||||
backgroundColor: (flick.useBackground) ? "white" : "transparent"
|
||||
|
||||
profile: HFWebEngineProfile;
|
||||
settings.pluginsEnabled: true
|
||||
|
|
|
@ -14,8 +14,7 @@ Item {
|
|||
property alias webViewCoreProfile: webViewCore.profile
|
||||
property string webViewCoreUserAgent
|
||||
|
||||
property string webBackgroundColor: "#FFFFFFFF"
|
||||
|
||||
property bool useBackground: true
|
||||
property string userScriptUrl: ""
|
||||
property string urlTag: "noDownload=false";
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ Item {
|
|||
property bool passwordField: false
|
||||
property alias flickable: webroot.interactive
|
||||
property alias blurOnCtrlShift: webroot.blurOnCtrlShift
|
||||
property alias webBackgroundColor: webroot.webBackgroundColor
|
||||
property alias useBackground: webroot.useBackground
|
||||
|
||||
function stop() {
|
||||
webroot.stop();
|
||||
|
|
|
@ -101,7 +101,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 {
|
||||
|
@ -228,10 +228,10 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
|
|||
}
|
||||
|
||||
{
|
||||
auto webBackgroundColor = entity->getWebBackgroundColor();
|
||||
if (_webBackgroundColor != webBackgroundColor) {
|
||||
_webSurface->getRootItem()->setProperty("webBackgroundColor", webBackgroundColor);
|
||||
_webBackgroundColor = webBackgroundColor;
|
||||
auto useBackground = entity->getUseBackground();
|
||||
if (_useBackground != useBackground) {
|
||||
_webSurface->getRootItem()->setProperty("useBackground", useBackground);
|
||||
_useBackground = useBackground;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,12 +300,14 @@ void WebEntityRenderer::doRender(RenderArgs* args) {
|
|||
glm::vec4 color;
|
||||
Transform transform;
|
||||
bool forward;
|
||||
bool isTransparent;
|
||||
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;
|
||||
isTransparent = isTransparent();
|
||||
});
|
||||
|
||||
if (color.a == 0.0f) {
|
||||
|
@ -319,7 +321,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) {
|
|||
|
||||
// Turn off jitter for these entities
|
||||
batch.pushProjectionJitter();
|
||||
DependencyManager::get<GeometryCache>()->bindWebBrowserProgram(batch, color.a < OPAQUE_ALPHA_THRESHOLD, forward);
|
||||
DependencyManager::get<GeometryCache>()->bindWebBrowserProgram(batch, isTransparent, forward);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, color, _geometryId);
|
||||
batch.popProjectionJitter();
|
||||
batch.setResourceTexture(0, nullptr);
|
||||
|
|
|
@ -94,7 +94,7 @@ private:
|
|||
uint16_t _dpi;
|
||||
QString _scriptURL;
|
||||
uint8_t _maxFPS;
|
||||
QString _webBackgroundColor;
|
||||
bool _useBackground;
|
||||
WebInputMode _inputMode;
|
||||
|
||||
glm::vec3 _contextPosition;
|
||||
|
|
|
@ -602,7 +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_BACKGROUND_COLOR, webBackgroundColor);
|
||||
CHECK_PROPERTY_CHANGE(PROP_WEB_USE_BACKGROUND, useBackground);
|
||||
|
||||
// Polyline
|
||||
CHECK_PROPERTY_CHANGE(PROP_LINE_POINTS, linePoints);
|
||||
|
@ -1821,7 +1821,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_BACKGROUND_COLOR, webBackgroundColor);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_WEB_USE_BACKGROUND, useBackground);
|
||||
}
|
||||
|
||||
// PolyVoxel only
|
||||
|
@ -2203,7 +2203,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(webBackgroundColor, QString, setWebBackgroundColor);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(useBackground, bool, setUseBackground);
|
||||
|
||||
// Polyline
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints);
|
||||
|
@ -2495,7 +2495,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(webBackgroundColor);
|
||||
COPY_PROPERTY_IF_CHANGED(useBackground);
|
||||
|
||||
// Polyline
|
||||
COPY_PROPERTY_IF_CHANGED(linePoints);
|
||||
|
@ -2895,7 +2895,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_BACKGROUND_COLOR, WebBackgroundColor, webBackgroundColor, QString);
|
||||
ADD_PROPERTY_TO_MAP(PROP_WEB_USE_BACKGROUND, useBackground, useBackground, bool);
|
||||
|
||||
// Polyline
|
||||
ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector<vec3>);
|
||||
|
@ -3326,7 +3326,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_BACKGROUND_COLOR, properties.getWebBackgroundColor());
|
||||
APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, properties.getUseBackground());
|
||||
}
|
||||
|
||||
if (properties.getType() == EntityTypes::Line) {
|
||||
|
@ -3802,7 +3802,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_BACKGROUND_COLOR, QString, setWebBackgroundColor);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_WEB_USE_BACKGROUND, bool, setUseBackground);
|
||||
}
|
||||
|
||||
if (properties.getType() == EntityTypes::Line) {
|
||||
|
@ -4190,7 +4190,7 @@ void EntityItemProperties::markAllChanged() {
|
|||
_maxFPSChanged = true;
|
||||
_inputModeChanged = true;
|
||||
_showKeyboardFocusHighlightChanged = true;
|
||||
_webBackgroundColor = true;
|
||||
_useBackgroundChanged = true;
|
||||
|
||||
// Polyline
|
||||
_linePointsChanged = true;
|
||||
|
@ -4881,8 +4881,8 @@ QList<QString> EntityItemProperties::listChangedProperties() {
|
|||
if (showKeyboardFocusHighlightChanged()) {
|
||||
out += "showKeyboardFocusHighlight";
|
||||
}
|
||||
if (webBackgroundColorChanged()) {
|
||||
out += "webBackgroundColor";
|
||||
if (useBackgroundChanged()) {
|
||||
out += "useBackground";
|
||||
}
|
||||
|
||||
// Shape
|
||||
|
|
|
@ -366,7 +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_BACKGROUND_COLOR, WebBackgroundColor, webBackgroundColor, QString, WebEntityItem::DEFAULT_WEB_BACKGROUND_COLOR);
|
||||
DEFINE_PROPERTY_REF(PROP_WEB_USE_BACKGROUND, UseBackground, useBackground, bool, true);
|
||||
|
||||
// Polyline
|
||||
DEFINE_PROPERTY_REF(PROP_LINE_POINTS, LinePoints, linePoints, QVector<glm::vec3>, ENTITY_ITEM_DEFAULT_EMPTY_VEC3_QVEC);
|
||||
|
|
|
@ -318,7 +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_BACKGROUND_COLOR = PROP_DERIVED_6,
|
||||
PROP_WEB_USE_BACKGROUND = PROP_DERIVED_6,
|
||||
|
||||
// Polyline
|
||||
PROP_LINE_POINTS = PROP_DERIVED_0,
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
const QString WebEntityItem::DEFAULT_SOURCE_URL = NetworkingConstants::WEB_ENTITY_DEFAULT_SOURCE_URL;
|
||||
const uint8_t WebEntityItem::DEFAULT_MAX_FPS = 10;
|
||||
const QString WebEntityItem::DEFAULT_WEB_BACKGROUND_COLOR = "#FFFFFFFF";
|
||||
|
||||
EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity(new WebEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
|
@ -63,7 +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(webBackgroundColor, getWebBackgroundColor);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(useBackground, getUseBackground);
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
@ -86,7 +85,7 @@ bool WebEntityItem::setProperties(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(webBackgroundColor, setWebBackgroundColor);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(useBackground, setUseBackground);
|
||||
|
||||
if (somethingChanged) {
|
||||
bool wantDebug = false;
|
||||
|
@ -127,7 +126,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_BACKGROUND_COLOR, QString, setWebBackgroundColor);
|
||||
READ_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, bool, setUseBackground);
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
@ -145,7 +144,7 @@ EntityPropertyFlags WebEntityItem::getEntityProperties(EncodeBitstreamParams& pa
|
|||
requestedProperties += PROP_MAX_FPS;
|
||||
requestedProperties += PROP_INPUT_MODE;
|
||||
requestedProperties += PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT;
|
||||
requestedProperties += PROP_WEB_BACKGROUND_COLOR;
|
||||
requestedProperties += PROP_WEB_USE_BACKGROUND;
|
||||
return requestedProperties;
|
||||
}
|
||||
|
||||
|
@ -172,7 +171,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_BACKGROUND_COLOR, getWebBackgroundColor());
|
||||
APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, getUseBackground());
|
||||
}
|
||||
|
||||
glm::vec3 WebEntityItem::getRaycastDimensions() const {
|
||||
|
@ -367,15 +366,15 @@ bool WebEntityItem::getShowKeyboardFocusHighlight() const {
|
|||
return _showKeyboardFocusHighlight;
|
||||
}
|
||||
|
||||
void WebEntityItem::setWebBackgroundColor(const QString& value) {
|
||||
void WebEntityItem::setUseBackground(bool value) {
|
||||
withWriteLock([&] {
|
||||
_needsRenderUpdate |= _webBackgroundColor != value;
|
||||
_webBackgroundColor = value;
|
||||
_needsRenderUpdate |= _useBackground != value;
|
||||
_useBackground = value;
|
||||
});
|
||||
}
|
||||
|
||||
QString WebEntityItem::getWebBackgroundColor() const {
|
||||
return resultWithReadLock<QString>([&] { return _webBackgroundColor; });
|
||||
bool WebEntityItem::getUseBackground() const {
|
||||
return resultWithReadLock<bool>([&] { return _useBackground; });
|
||||
}
|
||||
|
||||
PulsePropertyGroup WebEntityItem::getPulseProperties() const {
|
||||
|
|
|
@ -81,15 +81,14 @@ public:
|
|||
void setMaxFPS(uint8_t value);
|
||||
uint8_t getMaxFPS() const;
|
||||
|
||||
static const QString DEFAULT_WEB_BACKGROUND_COLOR;
|
||||
void setWebBackgroundColor(const QString& value);
|
||||
QString getWebBackgroundColor() const;
|
||||
|
||||
void setInputMode(const WebInputMode& value);
|
||||
WebInputMode getInputMode() const;
|
||||
|
||||
bool getShowKeyboardFocusHighlight() const;
|
||||
void setShowKeyboardFocusHighlight(bool value);
|
||||
|
||||
bool getUseBackground() const;
|
||||
void setUseBackground(bool value);
|
||||
|
||||
PulsePropertyGroup getPulseProperties() const;
|
||||
|
||||
|
@ -103,9 +102,9 @@ protected:
|
|||
uint16_t _dpi;
|
||||
QString _scriptURL;
|
||||
uint8_t _maxFPS;
|
||||
QString _webBackgroundColor;
|
||||
WebInputMode _inputMode;
|
||||
bool _showKeyboardFocusHighlight;
|
||||
bool _useBackground;
|
||||
bool _localSafeContext { false };
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue