1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Removed the extra padding breaking item location/ propper positioning

This commit is contained in:
Martin Tůma 2022-03-26 16:22:51 +01:00
parent 1385482689
commit 5d2f1205cc
3 changed files with 9 additions and 10 deletions

View File

@ -126,7 +126,7 @@ void RasterTile::processPointLabels(QList<TextItem*> &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<TextItem*> &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);

View File

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

View File

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