mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-22 00:26:37 -05:00
Fix MapRuler dimensions tooltip and refactor
This commit is contained in:
@@ -22,6 +22,7 @@ protected:
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void drawForeground(QPainter *painter, const QRectF &rect);
|
||||
void moveEvent(QMoveEvent *event);
|
||||
};
|
||||
|
||||
//Q_DECLARE_METATYPE(GraphicsView)
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
#define MAPRULER_H
|
||||
|
||||
#include <QGraphicsObject>
|
||||
#include <QPainter>
|
||||
#include <QColor>
|
||||
#include <QLine>
|
||||
|
||||
|
||||
class MapRuler : public QGraphicsObject, private QLine
|
||||
@@ -14,11 +13,15 @@ public:
|
||||
MapRuler(QColor innerColor = Qt::yellow, QColor borderColor = Qt::black) :
|
||||
innerColor(innerColor),
|
||||
borderColor(borderColor),
|
||||
mapSize(QSize())
|
||||
{
|
||||
init();
|
||||
}
|
||||
void init();
|
||||
mapSize(QSize()),
|
||||
statusMessage(QString()),
|
||||
xRuler(QRect()),
|
||||
yRuler(QRect()),
|
||||
cornerTick(QLine()),
|
||||
anchored(false),
|
||||
locked(false)
|
||||
{ }
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
QPainterPath shape() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||
@@ -45,16 +48,18 @@ public:
|
||||
// Ruler height in metatiles
|
||||
int height() const { return qAbs(deltaY()); }
|
||||
|
||||
QString statusMessage;
|
||||
|
||||
public slots:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *event);
|
||||
void setMapDimensions(const QSize &size);
|
||||
|
||||
signals:
|
||||
void statusChanged(const QString &statusMessage);
|
||||
|
||||
private:
|
||||
QColor innerColor;
|
||||
QColor borderColor;
|
||||
QSize mapSize;
|
||||
QString statusMessage;
|
||||
QRect xRuler;
|
||||
QRect yRuler;
|
||||
QLineF cornerTick;
|
||||
@@ -63,19 +68,13 @@ private:
|
||||
|
||||
static int thickness;
|
||||
|
||||
void init();
|
||||
void setAnchor(const QPointF &scenePos);
|
||||
void setEndPos(const QPointF &scenePos);
|
||||
QPoint snapToWithinBounds(QPoint pos) const;
|
||||
void setAnchor(const QPointF &scenePos, const QPoint &screenPos);
|
||||
void endAnchor();
|
||||
void setEndPos(const QPointF &scenePos, const QPoint &screenPos);
|
||||
void showDimensions(const QPoint &screenPos) const;
|
||||
void hideDimensions() const;
|
||||
void updateGeometry();
|
||||
int pixWidth() const { return width() * 16; }
|
||||
int pixHeight() const { return height() * 16; }
|
||||
|
||||
signals:
|
||||
void lengthChanged();
|
||||
void deactivated(const QPoint &endPos);
|
||||
};
|
||||
|
||||
#endif // MAPRULER_H
|
||||
|
||||
Reference in New Issue
Block a user