3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-26 22:56:02 +02:00

showKeyboardFocusHighlight + fixes

This commit is contained in:
SamGondelman 2019-01-28 20:43:47 -08:00
parent 7b88efa42c
commit 6ad0b3412a
12 changed files with 79 additions and 41 deletions

View file

@ -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)) {

View file

@ -740,7 +740,8 @@ bool Overlays::editOverlay(const QUuid& id, const QVariant& properties) {
}
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
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));
}
}

View file

@ -115,35 +115,39 @@ bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointe
}
}
if (_color != entity->getColor()) {
return true;
}
if(resultWithReadLock<bool>([&] {
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();

View file

@ -77,7 +77,6 @@ private:
};
static ContentType getContentType(const QString& urlString);
ContentType _contentType { ContentType::NoContent };
bool _loading { false };
QSharedPointer<OffscreenQmlSurface> _webSurface { nullptr };
bool _cachedWebSurface { false };

View file

@ -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 <caption>Create a Web entity displaying at 1920 x 1080 resolution.</caption>
* 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<vec3>);
@ -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<QString> EntityItemProperties::listChangedProperties() {
if (faceCameraChanged()) {
out += "faceCamera";
}
if (showKeyboardFocusHighlightChanged()) {
out += "showKeyboardFocusHighlight";
}
// Shape
if (shapeChanged()) {

View file

@ -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<glm::vec3>, ENTITY_ITEM_DEFAULT_EMPTY_VEC3_QVEC);

View file

@ -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,

View file

@ -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);
}

View file

@ -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<bool>([&] {
return _showKeyboardFocusHighlight;
});
}
PulsePropertyGroup WebEntityItem::getPulseProperties() const {
return resultWithReadLock<PulsePropertyGroup>([&] {
return _pulseProperties;

View file

@ -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

View file

@ -260,6 +260,7 @@ enum class EntityVersion : PacketVersion {
MissingWebEntityProperties,
PulseProperties,
RingGizmoEntities,
ShowKeyboardFocusHighlight,
// Add new versions above here
NUM_PACKET_TYPE,

View file

@ -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) {