mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Reintroduce the IMG icon padding
(but this time properly)
This commit is contained in:
parent
a6390bf8a5
commit
b2bcea5e78
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
using namespace IMG;
|
using namespace IMG;
|
||||||
|
|
||||||
|
#define ICON_PADDING 2
|
||||||
|
|
||||||
#define AREA(rect) \
|
#define AREA(rect) \
|
||||||
(rect.size().width() * rect.size().height())
|
(rect.size().width() * rect.size().height())
|
||||||
|
|
||||||
@ -450,7 +452,8 @@ void RasterTile::processPoints(QList<TextItem*> &textItems)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
TextPointItem *item = new TextPointItem(QPoint(point.coordinates.lon(),
|
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))
|
if (item->isValid() && !item->collides(textItems))
|
||||||
textItems.append(item);
|
textItems.append(item);
|
||||||
else
|
else
|
||||||
|
@ -18,7 +18,7 @@ static void expand(QRectF &rect, int width)
|
|||||||
|
|
||||||
TextPointItem::TextPointItem(const QPoint &point, const QString *text,
|
TextPointItem::TextPointItem(const QPoint &point, const QString *text,
|
||||||
const QFont *font, const QImage *img, const QColor *color,
|
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),
|
: TextItem(font ? text : 0), _font(font), _img(img), _color(color),
|
||||||
_haloColor(haloColor), _bgColor(bgColor)
|
_haloColor(haloColor), _bgColor(bgColor)
|
||||||
{
|
{
|
||||||
@ -32,10 +32,10 @@ TextPointItem::TextPointItem(const QPoint &point, const QString *text,
|
|||||||
expand(_textRect, _font->pixelSize() * MIN_BOX_WIDTH);
|
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;
|
QPainterPath shape;
|
||||||
QRectF iconRect;
|
QRectF iconRect;
|
||||||
@ -44,8 +44,8 @@ void TextPointItem::setPos(const QPoint &point)
|
|||||||
QSizeF s(_img->size() / _img->devicePixelRatioF());
|
QSizeF s(_img->size() / _img->devicePixelRatioF());
|
||||||
iconRect = QRectF(QPointF(point.x() - s.width() / 2,
|
iconRect = QRectF(QPointF(point.x() - s.width() / 2,
|
||||||
point.y() - s.height()/2), s);
|
point.y() - s.height()/2), s);
|
||||||
_textRect.moveTopLeft(QPointF(point.x() + s.width()/2, point.y()
|
_textRect.moveTopLeft(QPointF(point.x() + s.width()/2 + padding,
|
||||||
- _textRect.height()/2));
|
point.y() - _textRect.height()/2));
|
||||||
} else
|
} else
|
||||||
_textRect.moveCenter(point);
|
_textRect.moveCenter(point);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
TextPointItem() : TextItem(0), _font(0), _img(0) {}
|
TextPointItem() : TextItem(0), _font(0), _img(0) {}
|
||||||
TextPointItem(const QPoint &point, const QString *text, const QFont *font,
|
TextPointItem(const QPoint &point, const QString *text, const QFont *font,
|
||||||
const QImage *img, const QColor *color, const QColor *haloColor,
|
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();}
|
bool isValid() const {return !_rect.isEmpty();}
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ public:
|
|||||||
QPainterPath shape() const {return _shape;}
|
QPainterPath shape() const {return _shape;}
|
||||||
void paint(QPainter *painter) const;
|
void paint(QPainter *painter) const;
|
||||||
|
|
||||||
void setPos(const QPoint &point);
|
void setPos(const QPoint &point, int padding = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QFont *_font;
|
const QFont *_font;
|
||||||
|
Loading…
Reference in New Issue
Block a user