porymap/include/ui/metatilelayersitem.h

47 lines
1.5 KiB
C
Raw Permalink Normal View History

2018-09-30 22:15:04 +01:00
#ifndef METATILELAYERSITEM_H
#define METATILELAYERSITEM_H
#include "tileset.h"
#include "selectablepixmapitem.h"
2018-09-30 22:15:04 +01:00
#include <QGraphicsPixmapItem>
#include <QGraphicsSceneMouseEvent>
class MetatileLayersItem: public SelectablePixmapItem {
2018-09-30 22:15:04 +01:00
Q_OBJECT
public:
MetatileLayersItem(Metatile *metatile, Tileset *primaryTileset, Tileset *secondaryTileset): SelectablePixmapItem(16, 16, 6, 2) {
2018-09-30 22:15:04 +01:00
this->metatile = metatile;
this->primaryTileset = primaryTileset;
this->secondaryTileset = secondaryTileset;
this->clearLastModifiedCoords();
this->clearLastHoveredCoords();
setAcceptHoverEvents(true);
2018-09-30 22:15:04 +01:00
}
void draw();
void setTilesets(Tileset*, Tileset*);
void setMetatile(Metatile*);
void clearLastModifiedCoords();
void clearLastHoveredCoords();
2023-12-20 02:21:16 +00:00
bool showGrid;
2018-09-30 22:15:04 +01:00
private:
Metatile* metatile;
Tileset *primaryTileset;
Tileset *secondaryTileset;
QPoint prevChangedPos;
QPoint prevHoveredPos;
QPoint getBoundedPos(const QPointF &);
2018-09-30 22:15:04 +01:00
signals:
void tileChanged(int, int);
void selectedTilesChanged(QPoint, int, int);
void hoveredTileChanged(uint16_t);
void hoveredTileCleared();
2018-09-30 22:15:04 +01:00
protected:
void mousePressEvent(QGraphicsSceneMouseEvent*);
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
2018-09-30 22:15:04 +01:00
};
#endif // METATILELAYERSITEM_H