diff --git a/cmake/macros/GenerateEntityProperties.cmake b/cmake/macros/GenerateEntityProperties.cmake index fd267f289e..ad5671b496 100644 --- a/cmake/macros/GenerateEntityProperties.cmake +++ b/cmake/macros/GenerateEntityProperties.cmake @@ -291,7 +291,7 @@ macro(GENERATE_ENTITY_PROPERTIES) endif() if(NOT COMMON_PROPS) if(LINE MATCHES ".*enum( |,).*") - string(CONCAT ENTITY_ITEM_PROPERTY_APPEND "${ENTITY_ITEM_PROPERTY_APPEND}" "\t\t\tAPPEND_ENTITY_PROPERTY(${ENTITY_PROPERTY_ENUM}, (uint32_t)properties.get${ENTITY_PROPERTY_NAME_CAPS}());\n") + string(CONCAT ENTITY_ITEM_PROPERTY_APPEND "${ENTITY_ITEM_PROPERTY_APPEND}" "\t\t\tAPPEND_ENTITY_PROPERTY(${ENTITY_PROPERTY_ENUM}, (uint8_t)properties.get${ENTITY_PROPERTY_NAME_CAPS}());\n") elseif(ENTITY_PROPERTY_NETWORK_GETTER) string(CONCAT ENTITY_ITEM_PROPERTY_APPEND "${ENTITY_ITEM_PROPERTY_APPEND}" "\t\t\tAPPEND_ENTITY_PROPERTY(${ENTITY_PROPERTY_ENUM}, ${ENTITY_PROPERTY_NETWORK_GETTER});\n") else() @@ -300,7 +300,7 @@ macro(GENERATE_ENTITY_PROPERTIES) string(CONCAT ENTITY_ITEM_PROPERTY_READ "${ENTITY_ITEM_PROPERTY_READ}" "\tREAD_ENTITY_PROPERTY_TO_PROPERTIES(${ENTITY_PROPERTY_ENUM}, ${ENTITY_PROPERTY_READ_TYPE}, set${ENTITY_PROPERTY_NAME_CAPS});\n") string(CONCAT ${CURRENT_TYPE}_REQUESTED_PROPS "${${CURRENT_TYPE}_REQUESTED_PROPS}" "\trequestedProperties += ${ENTITY_PROPERTY_ENUM};\n") if(LINE MATCHES ".*enum( |,).*") - string(CONCAT ${CURRENT_TYPE}_ENTITY_APPEND "${${CURRENT_TYPE}_ENTITY_APPEND}" "\tAPPEND_ENTITY_PROPERTY(${ENTITY_PROPERTY_ENUM}, (uint32_t)get${ENTITY_PROPERTY_NAME_CAPS}());\n") + string(CONCAT ${CURRENT_TYPE}_ENTITY_APPEND "${${CURRENT_TYPE}_ENTITY_APPEND}" "\tAPPEND_ENTITY_PROPERTY(${ENTITY_PROPERTY_ENUM}, (uint8_t)get${ENTITY_PROPERTY_NAME_CAPS}());\n") elseif(ENTITY_VARIABLE_NETWORK_GETTER) string(CONCAT ${CURRENT_TYPE}_ENTITY_APPEND "${${CURRENT_TYPE}_ENTITY_APPEND}" "\tAPPEND_ENTITY_PROPERTY(${ENTITY_PROPERTY_ENUM}, ${ENTITY_VARIABLE_NETWORK_GETTER});\n") else() @@ -515,7 +515,7 @@ macro(GENERATE_ENTITY_PROPERTIES) string(CONCAT ${CURRENT_TYPE_CAPS}_GROUP_LIST_CHANGED "${${CURRENT_TYPE_CAPS}_GROUP_LIST_CHANGED}" "\tif (${GROUP_PROPERTY_NAME}Changed()) {\n\t\tout += \"${GROUP_PROPERTY_NAME}\";\n\t}\n") string(CONCAT ${CURRENT_TYPE_CAPS}_REQUESTED_PROPS "${${CURRENT_TYPE_CAPS}_REQUESTED_PROPS}" "\trequestedProperties += ${GROUP_PROPERTY_ENUM};\n") if(LINE MATCHES ".*enum( |,).*") - string(CONCAT ${CURRENT_TYPE_CAPS}_GROUP_APPEND "${${CURRENT_TYPE_CAPS}_GROUP_APPEND}" "\tAPPEND_ENTITY_PROPERTY(${GROUP_PROPERTY_ENUM}, (uint32_t)get${GROUP_PROPERTY_NAME_CAPS}());\n") + string(CONCAT ${CURRENT_TYPE_CAPS}_GROUP_APPEND "${${CURRENT_TYPE_CAPS}_GROUP_APPEND}" "\tAPPEND_ENTITY_PROPERTY(${GROUP_PROPERTY_ENUM}, (uint8_t)get${GROUP_PROPERTY_NAME_CAPS}());\n") elseif(GROUP_VARIABLE_NETWORK_GETTER) string(CONCAT ${CURRENT_TYPE_CAPS}_GROUP_APPEND "${${CURRENT_TYPE_CAPS}_GROUP_APPEND}" "\tAPPEND_ENTITY_PROPERTY(${GROUP_PROPERTY_ENUM}, ${GROUP_VARIABLE_NETWORK_GETTER});\n") else() diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 6b27a31f8e..4b63dcb932 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -1040,7 +1040,7 @@ void Avatar::renderDisplayName(gpu::Batch& batch, const ViewFrustum& view, const QByteArray nameUTF8 = renderedDisplayName.toLocal8Bit(); // Render text slightly in front to avoid z-fighting - textTransform.postTranslate(glm::vec3(0.0f, 0.0f, SLIGHTLY_IN_FRONT * displayNameRenderer->getFontSize())); + textTransform.postTranslate(glm::vec3(0.0f, 0.0f, SLIGHTLY_IN_FRONT)); batch.setModelTransform(textTransform); { PROFILE_RANGE_BATCH(batch, __FUNCTION__":renderText"); diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index 1cfab07986..9aec4c47f1 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -25,10 +25,6 @@ using namespace render; using namespace render::entities; -static const int FIXED_FONT_POINT_SIZE = 40; -const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 92.0f; // Determined through experimentation to fit font to line height. -const float LINE_SCALE_RATIO = 1.2f; - TextEntityRenderer::TextEntityRenderer(const EntityItemPointer& entity) : Parent(entity), _textRenderer(TextRenderer3D::getInstance(ROBOTO_FONT_FAMILY)) { @@ -77,6 +73,7 @@ void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointe _effectColor = toGlm(entity->getTextEffectColor()); _effectThickness = entity->getTextEffectThickness(); _alignment = entity->getAlignment(); + _verticalAlignment = entity->getVerticalAlignment(); bool materialChanged = false; glm::vec3 color = toGlm(entity->getBackgroundColor()); @@ -192,12 +189,8 @@ void TextEntityRenderer::doRender(RenderArgs* args) { QSizeF TextEntityRenderer::textSize(const QString& text) const { auto extents = _textRenderer->computeExtent(text); - extents.y *= 2.0f; - - float maxHeight = (float)_textRenderer->computeExtent("Xy").y * LINE_SCALE_RATIO; - float pointToWorldScale = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight; - - return QSizeF(extents.x, extents.y) * pointToWorldScale; + float scale = _lineHeight / _textRenderer->getFontHeight(); + return scale * QSizeF(extents.x, extents.y); } void TextEntityRenderer::onAddToSceneTyped(const TypedEntityPointer& entity) { @@ -374,14 +367,18 @@ void entities::TextPayload::render(RenderArgs* args) { transform.setRotation(BillboardModeHelpers::getBillboardRotation(transform.getTranslation(), transform.getRotation(), textRenderable->_billboardMode, usePrimaryFrustum ? BillboardModeHelpers::getPrimaryViewFrustumPosition() : args->getViewFrustum().getPosition())); - float scale = textRenderable->_lineHeight / textRenderer->getFontSize(); + float scale = 1.0f; + float fontHeight = textRenderer->getFontHeight(); + if (fontHeight > 0.0f) { + scale = textRenderable->_lineHeight / fontHeight; + } transform.postTranslate(glm::vec3(-0.5, 0.5, 1.0f + EPSILON / dimensions.z)); transform.setScale(scale); batch.setModelTransform(transform); glm::vec2 bounds = glm::vec2(dimensions.x - (textRenderable->_leftMargin + textRenderable->_rightMargin), dimensions.y - (textRenderable->_topMargin + textRenderable->_bottomMargin)); textRenderer->draw(batch, textRenderable->_font, { textRenderable->_text, textColor, effectColor, { textRenderable->_leftMargin / scale, -textRenderable->_topMargin / scale }, - bounds / scale, scale, textRenderable->_effectThickness, textRenderable->_effect, textRenderable->_alignment, textRenderable->_unlit, forward, mirror }); + bounds / scale, scale, textRenderable->_effectThickness, textRenderable->_effect, textRenderable->_alignment, textRenderable->_verticalAlignment, textRenderable->_unlit, forward, mirror }); } namespace render { diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.h b/libraries/entities-renderer/src/RenderableTextEntityItem.h index f48bb8085f..782b4d4f34 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.h +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.h @@ -74,6 +74,7 @@ private: QString _font { "" }; TextAlignment _alignment { TextAlignment::LEFT }; + TextVerticalAlignment _verticalAlignment { TextVerticalAlignment::TOP }; TextEffect _effect { TextEffect::NO_EFFECT }; glm::vec3 _effectColor { 0 }; float _effectThickness { 0.0f }; diff --git a/libraries/entities/src/EntityItem.h.in b/libraries/entities/src/EntityItem.h.in index d1d4c49352..837c84714c 100644 --- a/libraries/entities/src/EntityItem.h.in +++ b/libraries/entities/src/EntityItem.h.in @@ -69,7 +69,7 @@ class MeshProxyList; #endif namespace entity { -enum class HostType { +enum class HostType : uint8_t { DOMAIN = 0, AVATAR, LOCAL diff --git a/libraries/entities/src/EntityItemProperties.cpp.in b/libraries/entities/src/EntityItemProperties.cpp.in index bc8804c396..e5d16aaf94 100644 --- a/libraries/entities/src/EntityItemProperties.cpp.in +++ b/libraries/entities/src/EntityItemProperties.cpp.in @@ -257,7 +257,7 @@ const QHash stringToComponentMode = [] { addComponentMode(toReturn, ComponentMode::COMPONENT_MODE_ENABLED); return toReturn; }(); -QString EntityItemProperties::getComponentModeAsString(uint32_t mode) { return ComponentModeHelpers::getNameForComponentMode((ComponentMode)mode); } +QString EntityItemProperties::getComponentModeAsString(uint8_t mode) { return ComponentModeHelpers::getNameForComponentMode((ComponentMode)mode); } QString EntityItemProperties::getSkyboxModeAsString() const { return getComponentModeAsString(_skyboxMode); } QString EntityItemProperties::getKeyLightModeAsString() const { return getComponentModeAsString(_keyLightMode); } QString EntityItemProperties::getAmbientLightModeAsString() const { return getComponentModeAsString(_ambientLightMode); } @@ -376,6 +376,23 @@ void EntityItemProperties::setAlignmentFromString(const QString& alignment) { } } +inline void addTextVerticalAlignment(QHash& lookup, TextVerticalAlignment verticalAlignment) { lookup[TextVerticalAlignmentHelpers::getNameForTextVerticalAlignment(verticalAlignment)] = verticalAlignment; } +const QHash stringToTextVerticalAlignmentLookup = [] { + QHash toReturn; + addTextVerticalAlignment(toReturn, TextVerticalAlignment::TOP); + addTextVerticalAlignment(toReturn, TextVerticalAlignment::BOTTOM); + addTextVerticalAlignment(toReturn, TextVerticalAlignment::CENTER); + return toReturn; +}(); +QString EntityItemProperties::getVerticalAlignmentAsString() const { return TextVerticalAlignmentHelpers::getNameForTextVerticalAlignment(_verticalAlignment); } +void EntityItemProperties::setVerticalAlignmentFromString(const QString& verticalAlignment) { + auto textVerticalAlignmentItr = stringToTextVerticalAlignmentLookup.find(verticalAlignment.toLower()); + if (textVerticalAlignmentItr != stringToTextVerticalAlignmentLookup.end()) { + _verticalAlignment = textVerticalAlignmentItr.value(); + _verticalAlignmentChanged = true; + } +} + QString getCollisionGroupAsString(uint16_t group) { switch (group) { case USER_COLLISION_GROUP_DYNAMIC: diff --git a/libraries/entities/src/EntityItemProperties.h.in b/libraries/entities/src/EntityItemProperties.h.in index 9c904837df..c838e1d0d7 100644 --- a/libraries/entities/src/EntityItemProperties.h.in +++ b/libraries/entities/src/EntityItemProperties.h.in @@ -55,6 +55,7 @@ #include "GizmoType.h" #include "TextEffect.h" #include "TextAlignment.h" +#include "TextVerticalAlignment.h" #include "MirrorMode.h" #include "EntityShape.h" @@ -116,7 +117,7 @@ public: @ENTITY_ITEM_PROPERTY_DEFINES@ - static QString getComponentModeAsString(uint32_t mode); + static QString getComponentModeAsString(uint8_t mode); public: float getMaxDimension() const { return glm::compMax(_dimensions); } diff --git a/libraries/entities/src/EntityItemProperties.txt b/libraries/entities/src/EntityItemProperties.txt index c4c9d5f0a3..251c9766d1 100644 --- a/libraries/entities/src/EntityItemProperties.txt +++ b/libraries/entities/src/EntityItemProperties.txt @@ -161,6 +161,7 @@ enum:TEXT_EFFECT prop:textEffect type:TextEffect default:TextEffect::NO_EFFECT e enum:TEXT_EFFECT_COLOR prop:textEffectColor type:u8vec3Color default:TextEntityItem::DEFAULT_TEXT_COLOR renderProp, enum:TEXT_EFFECT_THICKNESS prop:textEffectThickness type:float default:TextEntityItem::DEFAULT_TEXT_EFFECT_THICKNESS min:0.0f max:0.5f renderProp, enum:TEXT_ALIGNMENT prop:alignment type:TextAlignment default:TextAlignment::LEFT enum renderProp, +enum:TEXT_VERTICAL_ALIGNMENT prop:verticalAlignment type:TextVerticalAlignment default:TextVerticalAlignment::TOP enum renderProp, Zone enum:SHAPE_TYPE prop:shapeType type:ShapeType enum default:SHAPE_TYPE_NONE common noGetterSetterProp, enum:COMPOUND_SHAPE_URL prop:compoundShapeURL type:QString default:"" urlPermission common, @@ -175,15 +176,15 @@ group:ambientOcclusion recordChange, enum:FLYING_ALLOWED prop:flyingAllowed type:bool default:ZoneEntityItem::DEFAULT_FLYING_ALLOWED basicProp, enum:GHOSTING_ALLOWED prop:ghostingAllowed type:bool default:ZoneEntityItem::DEFAULT_GHOSTING_ALLOWED basicProp, enum:FILTER_URL prop:filterURL type:QString default:ZoneEntityItem::DEFAULT_FILTER_URL urlPermission, -enum:KEY_LIGHT_MODE prop:keyLightMode type:uint32_t default:(uint32_t)COMPONENT_MODE_INHERIT enum, -enum:AMBIENT_LIGHT_MODE prop:ambientLightMode type:uint32_t default:(uint32_t)COMPONENT_MODE_INHERIT enum, -enum:SKYBOX_MODE prop:skyboxMode type:uint32_t default:(uint32_t)COMPONENT_MODE_INHERIT enum, -enum:HAZE_MODE prop:hazeMode type:uint32_t default:(uint32_t)COMPONENT_MODE_INHERIT enum, -enum:BLOOM_MODE prop:bloomMode type:uint32_t default:(uint32_t)COMPONENT_MODE_INHERIT enum, -enum:AVATAR_PRIORITY prop:avatarPriority type:uint32_t default:(uint32_t)COMPONENT_MODE_INHERIT enum basicProp, -enum:SCREENSHARE prop:screenshare type:uint32_t default:(uint32_t)COMPONENT_MODE_INHERIT enum basicProp, -enum:TONEMAPPING_MODE prop:tonemappingMode type:uint32_t default:(uint32_t)COMPONENT_MODE_INHERIT enum, -enum:AMBIENT_OCCLUSION_MODE prop:ambientOcclusionMode type:uint32_t default:(uint32_t)COMPONENT_MODE_INHERIT enum, +enum:KEY_LIGHT_MODE prop:keyLightMode type:uint8_t default:(uint8_t)COMPONENT_MODE_INHERIT enum, +enum:AMBIENT_LIGHT_MODE prop:ambientLightMode type:uint8_t default:(uint8_t)COMPONENT_MODE_INHERIT enum, +enum:SKYBOX_MODE prop:skyboxMode type:uint8_t default:(uint8_t)COMPONENT_MODE_INHERIT enum, +enum:HAZE_MODE prop:hazeMode type:uint8_t default:(uint8_t)COMPONENT_MODE_INHERIT enum, +enum:BLOOM_MODE prop:bloomMode type:uint8_t default:(uint8_t)COMPONENT_MODE_INHERIT enum, +enum:AVATAR_PRIORITY prop:avatarPriority type:uint8_t default:(uint8_t)COMPONENT_MODE_INHERIT enum basicProp, +enum:SCREENSHARE prop:screenshare type:uint8_t default:(uint8_t)COMPONENT_MODE_INHERIT enum basicProp, +enum:TONEMAPPING_MODE prop:tonemappingMode type:uint8_t default:(uint8_t)COMPONENT_MODE_INHERIT enum, +enum:AMBIENT_OCCLUSION_MODE prop:ambientOcclusionMode type:uint8_t default:(uint8_t)COMPONENT_MODE_INHERIT enum, PolyVox enum:VOXEL_VOLUME_SIZE prop:voxelVolumeSize type:vec3 default:PolyVoxEntityItem::DEFAULT_VOXEL_VOLUME_SIZE noGetterSetterProp, enum:VOXEL_DATA prop:voxelData type:QByteArray default:PolyVoxEntityItem::DEFAULT_VOXEL_DATA noGetterSetterProp, diff --git a/libraries/entities/src/EntityItemPropertiesDocs.cpp b/libraries/entities/src/EntityItemPropertiesDocs.cpp index a321327aec..2e1c0013e3 100644 --- a/libraries/entities/src/EntityItemPropertiesDocs.cpp +++ b/libraries/entities/src/EntityItemPropertiesDocs.cpp @@ -779,7 +779,8 @@ * @property {Entities.TextEffect} textEffect="none" - The effect that is applied to the text. * @property {Color} textEffectColor=255,255,255 - The color of the effect. * @property {number} textEffectThickness=0.2 - The magnitude of the text effect, range 0.00.5. - * @property {Entities.TextAlignment} alignment="left" - How the text is aligned against its background. + * @property {Entities.TextAlignment} alignment="left" - How the text is horizontally aligned against its background. + * @property {Entities.TextVerticalAlignment} verticalAlignment="top" - How the text is vertically aligned against its background. * @property {boolean} faceCamera - true if billboardMode is "yaw", false * if it isn't. Setting this property to false sets the billboardMode to "none". *

Deprecated: This property is deprecated and will be removed.

diff --git a/libraries/entities/src/EntityPropertyFlags.h.in b/libraries/entities/src/EntityPropertyFlags.h.in index f689845478..c087ae5c57 100644 --- a/libraries/entities/src/EntityPropertyFlags.h.in +++ b/libraries/entities/src/EntityPropertyFlags.h.in @@ -16,7 +16,7 @@ #include -enum EntityPropertyList { +enum EntityPropertyList : uint16_t { PROP_PAGED_PROPERTY, PROP_CUSTOM_PROPERTIES_INCLUDED, diff --git a/libraries/entities/src/ZoneEntityItem.cpp.in b/libraries/entities/src/ZoneEntityItem.cpp.in index 4b3689be02..e926f678ce 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp.in +++ b/libraries/entities/src/ZoneEntityItem.cpp.in @@ -239,80 +239,80 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() { }); } -void ZoneEntityItem::setSkyboxMode(const uint32_t value) { +void ZoneEntityItem::setSkyboxMode(const uint8_t value) { if (value < COMPONENT_MODE_ITEM_COUNT && value != _skyboxMode) { _skyboxMode = value; _skyboxPropertiesChanged = true; } } -uint32_t ZoneEntityItem::getSkyboxMode() const { +uint8_t ZoneEntityItem::getSkyboxMode() const { return _skyboxMode; } -void ZoneEntityItem::setKeyLightMode(const uint32_t value) { +void ZoneEntityItem::setKeyLightMode(const uint8_t value) { if (value < COMPONENT_MODE_ITEM_COUNT && value != _keyLightMode) { _keyLightMode = value; _keyLightPropertiesChanged = true; } } -uint32_t ZoneEntityItem::getKeyLightMode() const { +uint8_t ZoneEntityItem::getKeyLightMode() const { return _keyLightMode; } -void ZoneEntityItem::setAmbientLightMode(const uint32_t value) { +void ZoneEntityItem::setAmbientLightMode(const uint8_t value) { if (value < COMPONENT_MODE_ITEM_COUNT && value != _ambientLightMode) { _ambientLightMode = value; _ambientLightPropertiesChanged = true; } } -uint32_t ZoneEntityItem::getAmbientLightMode() const { +uint8_t ZoneEntityItem::getAmbientLightMode() const { return _ambientLightMode; } -void ZoneEntityItem::setHazeMode(const uint32_t value) { +void ZoneEntityItem::setHazeMode(const uint8_t value) { if (value < COMPONENT_MODE_ITEM_COUNT && value != _hazeMode) { _hazeMode = value; _hazePropertiesChanged = true; } } -uint32_t ZoneEntityItem::getHazeMode() const { +uint8_t ZoneEntityItem::getHazeMode() const { return _hazeMode; } -void ZoneEntityItem::setBloomMode(const uint32_t value) { +void ZoneEntityItem::setBloomMode(const uint8_t value) { if (value < COMPONENT_MODE_ITEM_COUNT && value != _bloomMode) { _bloomMode = value; _bloomPropertiesChanged = true; } } -uint32_t ZoneEntityItem::getBloomMode() const { +uint8_t ZoneEntityItem::getBloomMode() const { return _bloomMode; } -void ZoneEntityItem::setTonemappingMode(const uint32_t value) { +void ZoneEntityItem::setTonemappingMode(const uint8_t value) { if (value < COMPONENT_MODE_ITEM_COUNT && value != _tonemappingMode) { _tonemappingMode = value; _tonemappingPropertiesChanged = true; } } -uint32_t ZoneEntityItem::getTonemappingMode() const { +uint8_t ZoneEntityItem::getTonemappingMode() const { return _tonemappingMode; } -void ZoneEntityItem::setAmbientOcclusionMode(const uint32_t value) { +void ZoneEntityItem::setAmbientOcclusionMode(const uint8_t value) { if (value < COMPONENT_MODE_ITEM_COUNT && value != _ambientOcclusionMode) { _ambientOcclusionMode = value; _ambientOcclusionPropertiesChanged = true; } } -uint32_t ZoneEntityItem::getAmbientOcclusionMode() const { +uint8_t ZoneEntityItem::getAmbientOcclusionMode() const { return _ambientOcclusionMode; } diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index ff3bfaaa9b..923913e896 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -361,6 +361,7 @@ enum class EntityVersion : PacketVersion { TonemappingAndAmbientOcclusion, ModelLoadPriority, PropertyCleanup, + TextVerticalAlignment, // Add new versions above here NUM_PACKET_TYPE, diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index eaffc4bdb4..cf4d259a4c 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -43,6 +43,7 @@ #include "GizmoType.h" #include "TextEffect.h" #include "TextAlignment.h" +#include "TextVerticalAlignment.h" #include "MirrorMode.h" #include "TonemappingCurve.h" #include "AmbientOcclusionTechnique.h" @@ -288,6 +289,7 @@ public: static int unpackDataFromBytes(const unsigned char* dataBytes, GizmoType& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, TextEffect& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, TextAlignment& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } + static int unpackDataFromBytes(const unsigned char* dataBytes, TextVerticalAlignment& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, MirrorMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, TonemappingCurve& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, AmbientOcclusionTechnique& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } diff --git a/libraries/render-utils/src/TextRenderer3D.cpp b/libraries/render-utils/src/TextRenderer3D.cpp index 8ab1b8e0e9..a4680805e6 100644 --- a/libraries/render-utils/src/TextRenderer3D.cpp +++ b/libraries/render-utils/src/TextRenderer3D.cpp @@ -33,9 +33,9 @@ glm::vec2 TextRenderer3D::computeExtent(const QString& str) const { return glm::vec2(0.0f, 0.0f); } -float TextRenderer3D::getFontSize() const { +float TextRenderer3D::getFontHeight() const { if (_font) { - return _font->getFontSize(); + return _font->getFontHeight(); } return 0.0f; } diff --git a/libraries/render-utils/src/TextRenderer3D.h b/libraries/render-utils/src/TextRenderer3D.h index 9db93e9dcc..1a0a1343f8 100644 --- a/libraries/render-utils/src/TextRenderer3D.h +++ b/libraries/render-utils/src/TextRenderer3D.h @@ -25,7 +25,7 @@ public: static TextRenderer3D* getInstance(const char* family); glm::vec2 computeExtent(const QString& str) const; - float getFontSize() const; // Pixel size + float getFontHeight() const; void draw(gpu::Batch& batch, const Font::DrawProps& props); void draw(gpu::Batch& batch, const QString& font, const Font::DrawProps& props); diff --git a/libraries/render-utils/src/text/Font.cpp b/libraries/render-utils/src/text/Font.cpp index 3019b8f1c3..81badb8440 100644 --- a/libraries/render-utils/src/text/Font.cpp +++ b/libraries/render-utils/src/text/Font.cpp @@ -129,7 +129,7 @@ void Font::read(QIODevice& in) { } _distanceRange = glm::vec2(arteryFont.variants[0].metrics.distanceRange); - _fontSize = arteryFont.variants[0].metrics.ascender + fabs(arteryFont.variants[0].metrics.descender); + _fontHeight = arteryFont.variants[0].metrics.ascender + fabs(arteryFont.variants[0].metrics.descender); _leading = arteryFont.variants[0].metrics.lineHeight; _spaceWidth = 0.5f * arteryFont.variants[0].metrics.emSize; // We use half the emSize as a first guess for _spaceWidth @@ -303,11 +303,11 @@ QStringList Font::tokenizeForWrapping(const QString& str) const { return tokens; } -glm::vec2 Font::computeTokenExtent(const QString& token) const { - glm::vec2 advance(0, _fontSize); +float Font::computeTokenWidth(const QString& token) const { + float advance = 0.0f; foreach(QChar c, token) { Q_ASSERT(c != '\n'); - advance.x += (c == ' ') ? _spaceWidth : getGlyph(c).d; + advance += (c == ' ') ? _spaceWidth : getGlyph(c).d; } return advance; } @@ -318,10 +318,10 @@ glm::vec2 Font::computeExtent(const QString& str) const { QStringList lines = splitLines(str); if (!lines.empty()) { for(const auto& line : lines) { - glm::vec2 tokenExtent = computeTokenExtent(line); - extent.x = std::max(tokenExtent.x, extent.x); + float tokenWidth = computeTokenWidth(line); + extent.x = std::max(tokenWidth, extent.x); } - extent.y = lines.count() * _fontSize; + extent.y = lines.count() * _fontHeight; } return extent; } @@ -373,17 +373,22 @@ void Font::setupGPU() { } inline QuadBuilder adjustedQuadBuilderForAlignmentMode(const Glyph& glyph, glm::vec2 advance, float scale, float enlargeForShadows, - TextAlignment alignment, float rightSpacing) { + TextAlignment alignment, float rightSpacing, TextVerticalAlignment verticalAlignment, float bottomSpacing) { if (alignment == TextAlignment::RIGHT) { advance.x += rightSpacing; } else if (alignment == TextAlignment::CENTER) { advance.x += 0.5f * rightSpacing; } + if (verticalAlignment == TextVerticalAlignment::BOTTOM) { + advance.y += bottomSpacing; + } else if (verticalAlignment == TextVerticalAlignment::CENTER) { + advance.y += 0.5f * bottomSpacing; + } return QuadBuilder(glyph, advance, scale, enlargeForShadows); } void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm::vec2& origin, const glm::vec2& bounds, float scale, bool enlargeForShadows, - TextAlignment alignment) { + TextAlignment alignment, TextVerticalAlignment verticalAlignment) { drawInfo.verticesBuffer = std::make_shared(); drawInfo.indicesBuffer = std::make_shared(); drawInfo.indexCount = 0; @@ -394,6 +399,7 @@ void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm drawInfo.origin = origin; float rightEdge = origin.x + bounds.x; + float bottomEdge = origin.y - bounds.y; // Top left of text bool firstTokenOfLine = true; @@ -403,7 +409,7 @@ void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm for (int i = 0; i < tokens.length(); i++) { const QString& token = tokens[i]; - if ((bounds.y != -1) && (advance.y < origin.y - bounds.y)) { + if ((bounds.y != -1) && (advance.y < bottomEdge)) { // We are out of the y bound, stop drawing break; } @@ -459,25 +465,47 @@ void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm std::vector quadBuilders; quadBuilders.reserve(glyphsAndCorners.size()); { + float bottomSpacing = -FLT_MAX; + bool foundBottomSpacing = false; + if (verticalAlignment != TextVerticalAlignment::TOP) { + int i = (int)glyphsAndCorners.size() - 1; + while (!foundBottomSpacing && i >= 0) { + auto* nextGlyphAndCorner = &glyphsAndCorners[i]; + bottomSpacing = std::max(bottomSpacing, bottomEdge - (nextGlyphAndCorner->second.y + (nextGlyphAndCorner->first.offset.y - nextGlyphAndCorner->first.size.y))); + i--; + while (i >= 0) { + auto& prevGlyphAndCorner = glyphsAndCorners[i]; + // We're to the right of the last character we checked, which means we're on a previous line, so we can stop + if (prevGlyphAndCorner.second.x >= nextGlyphAndCorner->second.x) { + foundBottomSpacing = true; + break; + } + nextGlyphAndCorner = &prevGlyphAndCorner; + bottomSpacing = std::max(bottomSpacing, bottomEdge - (nextGlyphAndCorner->second.y + (nextGlyphAndCorner->first.offset.y - nextGlyphAndCorner->first.size.y))); + i--; + } + } + } + int i = (int)glyphsAndCorners.size() - 1; while (i >= 0) { - auto nextGlyphAndCorner = glyphsAndCorners[i]; - float rightSpacing = rightEdge - (nextGlyphAndCorner.second.x + nextGlyphAndCorner.first.d); - quadBuilders.push_back(adjustedQuadBuilderForAlignmentMode(nextGlyphAndCorner.first, nextGlyphAndCorner.second, scale, enlargeForShadows, - alignment, rightSpacing)); + auto* nextGlyphAndCorner = &glyphsAndCorners[i]; + float rightSpacing = rightEdge - (nextGlyphAndCorner->second.x + nextGlyphAndCorner->first.d); + quadBuilders.push_back(adjustedQuadBuilderForAlignmentMode(nextGlyphAndCorner->first, nextGlyphAndCorner->second, scale, enlargeForShadows, + alignment, rightSpacing, verticalAlignment, bottomSpacing)); i--; while (i >= 0) { - const auto& prevGlyphAndCorner = glyphsAndCorners[i]; + auto& prevGlyphAndCorner = glyphsAndCorners[i]; // We're to the right of the last character we checked, which means we're on a previous line, so we need to // recalculate the spacing, so we exit this loop - if (prevGlyphAndCorner.second.x >= nextGlyphAndCorner.second.x) { + if (prevGlyphAndCorner.second.x >= nextGlyphAndCorner->second.x) { break; } quadBuilders.push_back(adjustedQuadBuilderForAlignmentMode(prevGlyphAndCorner.first, prevGlyphAndCorner.second, scale, enlargeForShadows, - alignment, rightSpacing)); + alignment, rightSpacing, verticalAlignment, bottomSpacing)); - nextGlyphAndCorner = prevGlyphAndCorner; + nextGlyphAndCorner = &prevGlyphAndCorner; i--; } } @@ -529,12 +557,13 @@ void Font::drawString(gpu::Batch& batch, Font::DrawInfo& drawInfo, const DrawPro const bool boundsChanged = props.bounds != drawInfo.bounds || props.origin != drawInfo.origin; // If we're switching to or from shadow effect mode, we need to rebuild the vertices - if (props.str != drawInfo.string || boundsChanged || props.alignment != _alignment || + if (props.str != drawInfo.string || boundsChanged || props.alignment != drawInfo.alignment || props.verticalAlignment != drawInfo.verticalAlignment || (drawInfo.params.effect != textEffect && (textEffect == SHADOW_EFFECT || drawInfo.params.effect == SHADOW_EFFECT)) || - (textEffect == SHADOW_EFFECT && props.scale != _scale)) { - _scale = props.scale; - _alignment = props.alignment; - buildVertices(drawInfo, props.str, props.origin, props.bounds, props.scale, textEffect == SHADOW_EFFECT, props.alignment); + (textEffect == SHADOW_EFFECT && props.scale != drawInfo.scale)) { + drawInfo.scale = props.scale; + drawInfo.alignment = props.alignment; + drawInfo.verticalAlignment = props.verticalAlignment; + buildVertices(drawInfo, props.str, props.origin, props.bounds, props.scale, textEffect == SHADOW_EFFECT, drawInfo.alignment, drawInfo.verticalAlignment); } setupGPU(); diff --git a/libraries/render-utils/src/text/Font.h b/libraries/render-utils/src/text/Font.h index c9d96bc6f6..8112e279e5 100644 --- a/libraries/render-utils/src/text/Font.h +++ b/libraries/render-utils/src/text/Font.h @@ -15,6 +15,7 @@ #include "Glyph.h" #include "TextEffect.h" #include "TextAlignment.h" +#include "TextVerticalAlignment.h" #include #include @@ -55,16 +56,21 @@ public: glm::vec2 origin; glm::vec2 bounds; DrawParams params; + + float scale { 0.0f }; + TextAlignment alignment { TextAlignment::LEFT }; + TextVerticalAlignment verticalAlignment { TextVerticalAlignment::TOP }; }; glm::vec2 computeExtent(const QString& str) const; - float getFontSize() const { return _fontSize; } + float getFontHeight() const { return _fontHeight; } struct DrawProps { DrawProps(const QString& str, const glm::vec4& color, const glm::vec3& effectColor, const glm::vec2& origin, const glm::vec2& bounds, - float scale, float effectThickness, TextEffect effect, TextAlignment alignment, bool unlit, bool forward, bool mirror) : + float scale, float effectThickness, TextEffect effect, TextAlignment alignment, TextVerticalAlignment verticalAlignment, bool unlit, + bool forward, bool mirror) : str(str), color(color), effectColor(effectColor), origin(origin), bounds(bounds), scale(scale), effectThickness(effectThickness), - effect(effect), alignment(alignment), unlit(unlit), forward(forward), mirror(mirror) {} + effect(effect), alignment(alignment), verticalAlignment(verticalAlignment), unlit(unlit), forward(forward), mirror(mirror) {} DrawProps(const QString& str, const glm::vec4& color, const glm::vec2& origin, const glm::vec2& bounds, bool forward) : str(str), color(color), origin(origin), bounds(bounds), forward(forward) {} @@ -77,6 +83,7 @@ public: float effectThickness { 0.0f }; TextEffect effect { TextEffect::NO_EFFECT }; TextAlignment alignment { TextAlignment::LEFT }; + TextVerticalAlignment verticalAlignment { TextVerticalAlignment::TOP }; bool unlit = true; bool forward; bool mirror = false; @@ -96,11 +103,11 @@ private: static Pointer load(const QString& family, QIODevice& fontFile); QStringList tokenizeForWrapping(const QString& str) const; QStringList splitLines(const QString& str) const; - glm::vec2 computeTokenExtent(const QString& str) const; + float computeTokenWidth(const QString& str) const; const Glyph& getGlyph(const QChar& c) const; void buildVertices(DrawInfo& drawInfo, const QString& str, const glm::vec2& origin, const glm::vec2& bounds, float scale, bool enlargeForShadows, - TextAlignment alignment); + TextAlignment alignment, TextVerticalAlignment verticalAlignment); void setupGPU(); @@ -114,13 +121,10 @@ private: // Font characteristics QString _family; glm::vec2 _distanceRange { 1.0f }; - float _fontSize { 0.0f }; + float _fontHeight { 0.0f }; float _leading { 0.0f }; float _spaceWidth { 0.0f }; - float _scale { 0.0f }; - TextAlignment _alignment { TextAlignment::LEFT }; - bool _loaded { false }; bool _needsParamsUpdate { false }; diff --git a/libraries/shared/src/AmbientOcclusionTechnique.h b/libraries/shared/src/AmbientOcclusionTechnique.h index 15ce034606..3295149e4d 100644 --- a/libraries/shared/src/AmbientOcclusionTechnique.h +++ b/libraries/shared/src/AmbientOcclusionTechnique.h @@ -25,7 +25,7 @@ * @typedef {string} AmbientOcclusionTechnique */ -enum class AmbientOcclusionTechnique { +enum class AmbientOcclusionTechnique : uint8_t { SSAO = 0, HBAO, }; diff --git a/libraries/shared/src/BillboardMode.h b/libraries/shared/src/BillboardMode.h index dd377cab31..7c7ab981fb 100644 --- a/libraries/shared/src/BillboardMode.h +++ b/libraries/shared/src/BillboardMode.h @@ -33,7 +33,7 @@ * @typedef {string} BillboardMode */ -enum class BillboardMode { +enum class BillboardMode : uint8_t { NONE = 0, YAW, FULL diff --git a/libraries/shared/src/ComponentMode.h b/libraries/shared/src/ComponentMode.h index f1d030cefd..9cf773e997 100644 --- a/libraries/shared/src/ComponentMode.h +++ b/libraries/shared/src/ComponentMode.h @@ -14,7 +14,7 @@ #include -enum ComponentMode { +enum ComponentMode : uint8_t { COMPONENT_MODE_INHERIT, COMPONENT_MODE_DISABLED, COMPONENT_MODE_ENABLED, @@ -22,7 +22,7 @@ enum ComponentMode { COMPONENT_MODE_ITEM_COUNT }; -enum AvatarPriorityMode { +enum AvatarPriorityMode : uint8_t { AVATAR_PRIORITY_INHERIT, AVATAR_PRIORITY_CROWD, AVATAR_PRIORITY_HERO, diff --git a/libraries/shared/src/EntityShape.h b/libraries/shared/src/EntityShape.h index 8c1500d4cb..baa3eb7738 100644 --- a/libraries/shared/src/EntityShape.h +++ b/libraries/shared/src/EntityShape.h @@ -37,7 +37,7 @@ * * @typedef {string} Entities.Shape */ -enum class EntityShape { +enum class EntityShape : uint8_t { Triangle, Quad, Hexagon, diff --git a/libraries/shared/src/GizmoType.h b/libraries/shared/src/GizmoType.h index ca091e63fe..edee96698a 100644 --- a/libraries/shared/src/GizmoType.h +++ b/libraries/shared/src/GizmoType.h @@ -24,7 +24,7 @@ * @typedef {string} Entities.GizmoType */ -enum GizmoType { +enum GizmoType : uint8_t { RING = 0, // put new gizmo-types before this line. UNSET_GIZMO_TYPE diff --git a/libraries/shared/src/MaterialMappingMode.h b/libraries/shared/src/MaterialMappingMode.h index d95fbb339e..d48739562a 100644 --- a/libraries/shared/src/MaterialMappingMode.h +++ b/libraries/shared/src/MaterialMappingMode.h @@ -11,7 +11,7 @@ #include "QString" -enum MaterialMappingMode { +enum MaterialMappingMode : uint8_t { UV = 0, PROJECTED, // put new mapping-modes before this line. diff --git a/libraries/shared/src/MirrorMode.h b/libraries/shared/src/MirrorMode.h index e48e564df0..cfcef790f2 100644 --- a/libraries/shared/src/MirrorMode.h +++ b/libraries/shared/src/MirrorMode.h @@ -30,7 +30,7 @@ * @typedef {string} MirrorMode */ -enum class MirrorMode { +enum class MirrorMode : uint8_t { NONE = 0, MIRROR, PORTAL diff --git a/libraries/shared/src/PrimitiveMode.h b/libraries/shared/src/PrimitiveMode.h index 6dd65ec0c7..f52d21ca59 100644 --- a/libraries/shared/src/PrimitiveMode.h +++ b/libraries/shared/src/PrimitiveMode.h @@ -25,7 +25,7 @@ * @typedef {string} Entities.PrimitiveMode */ -enum class PrimitiveMode { +enum class PrimitiveMode : uint8_t { SOLID = 0, LINES }; diff --git a/libraries/shared/src/PulseMode.h b/libraries/shared/src/PulseMode.h index 8d4c24b4be..fb6bfc434f 100644 --- a/libraries/shared/src/PulseMode.h +++ b/libraries/shared/src/PulseMode.h @@ -26,7 +26,7 @@ * @typedef {string} Entities.PulseMode */ -enum class PulseMode { +enum class PulseMode : uint8_t { NONE = 0, IN_PHASE, OUT_PHASE diff --git a/libraries/shared/src/RenderLayer.h b/libraries/shared/src/RenderLayer.h index e0c249a001..d3fb97a256 100644 --- a/libraries/shared/src/RenderLayer.h +++ b/libraries/shared/src/RenderLayer.h @@ -26,7 +26,7 @@ * @typedef {string} Entities.RenderLayer */ -enum class RenderLayer { +enum class RenderLayer : uint8_t { WORLD = 0, FRONT, HUD diff --git a/libraries/shared/src/ShapeInfo.h b/libraries/shared/src/ShapeInfo.h index 6b0f981b24..7af28e8684 100644 --- a/libraries/shared/src/ShapeInfo.h +++ b/libraries/shared/src/ShapeInfo.h @@ -28,7 +28,7 @@ const int MAX_HULL_POINTS = 42; const int32_t END_OF_MESH_PART = -1; // bogus vertex index at end of mesh part const int32_t END_OF_MESH = -2; // bogus vertex index at end of mesh -enum ShapeType { +enum ShapeType : uint8_t { SHAPE_TYPE_NONE, SHAPE_TYPE_BOX, SHAPE_TYPE_SPHERE, diff --git a/libraries/shared/src/TextAlignment.h b/libraries/shared/src/TextAlignment.h index b82d8e8c57..643b501b31 100644 --- a/libraries/shared/src/TextAlignment.h +++ b/libraries/shared/src/TextAlignment.h @@ -12,21 +12,21 @@ #include "QString" /*@jsdoc - *

A {@link Entities.EntityProperties-Text|Text} entity may use one of the following alignments:

+ *

A {@link Entities.EntityProperties-Text|Text} entity may use one of the following horizontal alignments:

* * * * * * - * + * * * *
ValueDescription
"left"Text is aligned to the left side.
"center"Text is centered.
"center"Text is centered horizontally.
"right"Text is aligned to the right side.
* @typedef {string} Entities.TextAlignment */ -enum class TextAlignment { +enum class TextAlignment : uint8_t { LEFT = 0, CENTER, RIGHT diff --git a/libraries/shared/src/TextEffect.h b/libraries/shared/src/TextEffect.h index 09affc1f4e..f0bbf22209 100644 --- a/libraries/shared/src/TextEffect.h +++ b/libraries/shared/src/TextEffect.h @@ -27,7 +27,7 @@ * @typedef {string} Entities.TextEffect */ -enum class TextEffect { +enum class TextEffect : uint8_t { NO_EFFECT = 0, OUTLINE_EFFECT, OUTLINE_WITH_FILL_EFFECT, diff --git a/libraries/shared/src/TextVerticalAlignment.cpp b/libraries/shared/src/TextVerticalAlignment.cpp new file mode 100644 index 0000000000..a42b4c7e32 --- /dev/null +++ b/libraries/shared/src/TextVerticalAlignment.cpp @@ -0,0 +1,25 @@ +// +// Created by HifiExperiments on 8/17/24 +// Copyright 2024 Overte e.V contributors. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "TextVerticalAlignment.h" + +const char* textVerticalAlignmentNames[] = { + "top", + "bottom", + "center" +}; + +static const size_t TEXT_VERTICAL_ALIGNMENT_NAMES = (sizeof(textVerticalAlignmentNames) / sizeof(textVerticalAlignmentNames[0])); + +QString TextVerticalAlignmentHelpers::getNameForTextVerticalAlignment(TextVerticalAlignment verticalAlignment) { + if (((int)verticalAlignment <= 0) || ((int)verticalAlignment >= (int)TEXT_VERTICAL_ALIGNMENT_NAMES)) { + verticalAlignment = (TextVerticalAlignment)0; + } + + return textVerticalAlignmentNames[(int)verticalAlignment]; +} \ No newline at end of file diff --git a/libraries/shared/src/TextVerticalAlignment.h b/libraries/shared/src/TextVerticalAlignment.h new file mode 100644 index 0000000000..938bb93abe --- /dev/null +++ b/libraries/shared/src/TextVerticalAlignment.h @@ -0,0 +1,40 @@ +// +// Created by HifiExperiments on 8/17/24 +// Copyright 2024 Overte e.V contributors. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_TextVerticalAlignment_h +#define hifi_TextVerticalAlignment_h + +#include "QString" + +/*@jsdoc + *

A {@link Entities.EntityProperties-Text|Text} entity may use one of the following vertical alignments:

+ * + * + * + * + * + * + * + * + * + *
ValueDescription
"top"Text is aligned to the top.
"bottom"Text is aligned to the bottom.
"center"Text is centered vertically.
+ * @typedef {string} Entities.TextVerticalAlignment + */ + +enum class TextVerticalAlignment : uint8_t { + TOP = 0, + BOTTOM, + CENTER, +}; + +class TextVerticalAlignmentHelpers { +public: + static QString getNameForTextVerticalAlignment(TextVerticalAlignment alignment); +}; + +#endif // hifi_TextVerticalAlignment_h \ No newline at end of file diff --git a/libraries/shared/src/TonemappingCurve.h b/libraries/shared/src/TonemappingCurve.h index f13cb3d437..f5f4d3fbb5 100644 --- a/libraries/shared/src/TonemappingCurve.h +++ b/libraries/shared/src/TonemappingCurve.h @@ -27,7 +27,7 @@ * @typedef {string} TonemappingCurve */ -enum class TonemappingCurve { +enum class TonemappingCurve : uint8_t { RGB = 0, SRGB, REINHARD, diff --git a/libraries/shared/src/WebInputMode.h b/libraries/shared/src/WebInputMode.h index a65ae1341c..e1bd7b7984 100644 --- a/libraries/shared/src/WebInputMode.h +++ b/libraries/shared/src/WebInputMode.h @@ -25,7 +25,7 @@ * @typedef {string} WebInputMode */ -enum class WebInputMode { +enum class WebInputMode : uint8_t { TOUCH = 0, MOUSE, }; diff --git a/scripts/system/create/assets/data/createAppTooltips.json b/scripts/system/create/assets/data/createAppTooltips.json index a6feb44b99..fcbad7b320 100644 --- a/scripts/system/create/assets/data/createAppTooltips.json +++ b/scripts/system/create/assets/data/createAppTooltips.json @@ -45,6 +45,9 @@ "textAlignment": { "tooltip": "How the text is aligned within its left and right bounds." }, + "textVerticalAlignment": { + "tooltip": "How the text is aligned within its top and bottom bounds." + }, "topMargin": { "tooltip": "The top margin, in meters." }, diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index dd97620eea..20f34ba8b8 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -273,6 +273,17 @@ const GROUPS = [ propertyID: "textAlignment", propertyName: "alignment", // actual entity property name }, + { + label: "Vertical Alignment", + type: "dropdown", + options: { + top: "Top", + center: "Center", + bottom: "Bottom" + }, + propertyID: "textVerticalAlignment", + propertyName: "verticalAlignment", // actual entity property name + }, { label: "Top Margin", type: "number-draggable",