diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-12-10 17:38:21 +0100 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-01-15 15:02:11 +0200 |
commit | 5a1e4c6b816ef495e53e54f563ecfcef3c5839aa (patch) | |
tree | f5654a0a5f9c517170b231dfb23ec4d430479761 /src/mbgl/text/shaping.hpp | |
parent | 027e803b722301a03e9ef53b584c2795ff47e7bd (diff) | |
download | qtlocation-mapboxgl-5a1e4c6b816ef495e53e54f563ecfcef3c5839aa.tar.gz |
[core] implement stretchable icons for icon-text-fit
Diffstat (limited to 'src/mbgl/text/shaping.hpp')
-rw-r--r-- | src/mbgl/text/shaping.hpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/mbgl/text/shaping.hpp b/src/mbgl/text/shaping.hpp index 0c238d36b0..5343d4c3b2 100644 --- a/src/mbgl/text/shaping.hpp +++ b/src/mbgl/text/shaping.hpp @@ -26,16 +26,37 @@ style::TextJustifyType getAnchorJustification(style::SymbolAnchorType anchor); class SymbolFeature; class BiDi; +class Padding { +public: + float left = 0; + float top = 0; + float right = 0; + float bottom = 0; + + explicit operator bool() const { return left != 0 || top != 0 || right != 0 || bottom != 0; } + + bool operator==(const Padding& rhs) const { + return left == rhs.left && top == rhs.top && right == rhs.right && bottom == rhs.bottom; + } +}; + class PositionedIcon { private: - PositionedIcon(ImagePosition image_, float top_, float bottom_, float left_, float right_) - : _image(image_), _top(top_), _bottom(bottom_), _left(left_), _right(right_) {} + PositionedIcon( + ImagePosition image_, float top_, float bottom_, float left_, float right_, const Padding& collisionPadding_) + : _image(image_), + _top(top_), + _bottom(bottom_), + _left(left_), + _right(right_), + _collisionPadding(collisionPadding_) {} ImagePosition _image; float _top; float _bottom; float _left; float _right; + Padding _collisionPadding; public: static PositionedIcon shapeIcon(const ImagePosition&, @@ -55,6 +76,7 @@ public: float bottom() const { return _bottom; } float left() const { return _left; } float right() const { return _right; } + const Padding& collisionPadding() const { return _collisionPadding; } }; const Shaping getShaping(const TaggedString& string, |