From 5d2f1205ccd44be5905fcc885ba97b50bb051de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 26 Mar 2022 16:22:51 +0100 Subject: [PATCH] Removed the extra padding breaking item location/ propper positioning --- src/map/mapsforge/rastertile.cpp | 4 ++-- src/map/textpointitem.cpp | 11 +++++------ src/map/textpointitem.h | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/map/mapsforge/rastertile.cpp b/src/map/mapsforge/rastertile.cpp index 1db5b347..c6dd89b5 100644 --- a/src/map/mapsforge/rastertile.cpp +++ b/src/map/mapsforge/rastertile.cpp @@ -126,7 +126,7 @@ void RasterTile::processPointLabels(QList &textItems) TextPointItem *item = new TextPointItem( ll2xy(point.coordinates).toPoint(), label, font, img, color, - hColor, 0, false); + hColor, 0); if (item->isValid() && !item->collides(textItems)) textItems.append(item); else @@ -181,7 +181,7 @@ void RasterTile::processAreaLabels(QList &textItems) ? centroid(path.path) : ll2xy(path.labelPos); TextPointItem *item = new TextPointItem(pos.toPoint(), label, font, img, - color, hColor, 0, false); + color, hColor, 0); if (item->isValid() && _rect.contains(item->boundingRect().toRect()) && !item->collides(textItems)) textItems.append(item); diff --git a/src/map/textpointitem.cpp b/src/map/textpointitem.cpp index e436ecbd..ed11e119 100644 --- a/src/map/textpointitem.cpp +++ b/src/map/textpointitem.cpp @@ -18,7 +18,7 @@ static void expand(QRectF &rect, int width) TextPointItem::TextPointItem(const QPoint &point, const QString *text, const QFont *font, const QImage *img, const QColor *color, - const QColor *haloColor, const QColor *bgColor, bool padding) + const QColor *haloColor, const QColor *bgColor) : TextItem(font ? text : 0), _font(font), _img(img), _color(color), _haloColor(haloColor), _bgColor(bgColor) { @@ -32,19 +32,18 @@ TextPointItem::TextPointItem(const QPoint &point, const QString *text, expand(_textRect, _font->pixelSize() * MIN_BOX_WIDTH); } - setPos(point, padding); + setPos(point); } -void TextPointItem::setPos(const QPoint &point, bool padding) +void TextPointItem::setPos(const QPoint &point) { QPainterPath shape; QRectF iconRect; if (_img && !_img->isNull()) { QSizeF s(_img->size() / _img->devicePixelRatioF()); - int xOffset = padding ? s.width() : s.width() / 2; - iconRect = QRectF(QPointF(point.x() - xOffset, point.y() - - s.height()/2), s); + iconRect = QRectF(QPointF(point.x() - s.width() / 2, + point.y() - s.height()/2), s); _textRect.moveTopLeft(QPointF(point.x() + s.width()/2, point.y() - _textRect.height()/2)); } else diff --git a/src/map/textpointitem.h b/src/map/textpointitem.h index 10704d72..cf950863 100644 --- a/src/map/textpointitem.h +++ b/src/map/textpointitem.h @@ -17,7 +17,7 @@ public: TextPointItem() : TextItem(0), _font(0), _img(0) {} TextPointItem(const QPoint &point, const QString *text, const QFont *font, const QImage *img, const QColor *color, const QColor *haloColor, - const QColor *bgColor = 0, bool padding = true); + const QColor *bgColor = 0); bool isValid() const {return !_rect.isEmpty();} @@ -25,7 +25,7 @@ public: QPainterPath shape() const {return _shape;} void paint(QPainter *painter) const; - void setPos(const QPoint &point, bool padding = true); + void setPos(const QPoint &point); private: const QFont *_font;