diff --git a/src/map/IMG/rastertile.cpp b/src/map/IMG/rastertile.cpp index 12c31572..81ef1e26 100644 --- a/src/map/IMG/rastertile.cpp +++ b/src/map/IMG/rastertile.cpp @@ -11,6 +11,8 @@ using namespace IMG; +#define ICON_PADDING 2 + #define AREA(rect) \ (rect.size().width() * rect.size().height()) @@ -450,7 +452,8 @@ void RasterTile::processPoints(QList &textItems) continue; TextPointItem *item = new TextPointItem(QPoint(point.coordinates.lon(), - point.coordinates.lat()), label, fnt, img, color, &haloColor); + point.coordinates.lat()), label, fnt, img, color, &haloColor, 0, + ICON_PADDING); if (item->isValid() && !item->collides(textItems)) textItems.append(item); else diff --git a/src/map/textpointitem.cpp b/src/map/textpointitem.cpp index ed11e119..5e02d69e 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) + const QColor *haloColor, const QColor *bgColor, int padding) : TextItem(font ? text : 0), _font(font), _img(img), _color(color), _haloColor(haloColor), _bgColor(bgColor) { @@ -32,10 +32,10 @@ TextPointItem::TextPointItem(const QPoint &point, const QString *text, expand(_textRect, _font->pixelSize() * MIN_BOX_WIDTH); } - setPos(point); + setPos(point, padding); } -void TextPointItem::setPos(const QPoint &point) +void TextPointItem::setPos(const QPoint &point, int padding) { QPainterPath shape; QRectF iconRect; @@ -44,8 +44,8 @@ void TextPointItem::setPos(const QPoint &point) QSizeF s(_img->size() / _img->devicePixelRatioF()); 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)); + _textRect.moveTopLeft(QPointF(point.x() + s.width()/2 + padding, + point.y() - _textRect.height()/2)); } else _textRect.moveCenter(point); diff --git a/src/map/textpointitem.h b/src/map/textpointitem.h index cf950863..0f068b0a 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); + const QColor *bgColor = 0, int padding = 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); + void setPos(const QPoint &point, int padding = 0); private: const QFont *_font;