#ifndef METATILESELECTOR_H #define METATILESELECTOR_H #include "selectablepixmapitem.h" #include "tileset.h" class MetatileSelector: public SelectablePixmapItem { Q_OBJECT public: MetatileSelector(int numMetatilesWide, Tileset *primaryTileset, Tileset *secondaryTileset): SelectablePixmapItem(16, 16) { this->externalSelection = false; this->numMetatilesWide = numMetatilesWide; this->primaryTileset = primaryTileset; this->secondaryTileset = secondaryTileset; this->selectedMetatiles = new QList(); this->externalSelectedMetatiles = new QList(); setAcceptHoverEvents(true); } QPoint getSelectionDimensions(); void draw(); void select(uint16_t metatile); void setTilesets(Tileset*, Tileset*); QList* getSelectedMetatiles(); void setExternalSelection(int, int, QList*); protected: void mousePressEvent(QGraphicsSceneMouseEvent*); void mouseMoveEvent(QGraphicsSceneMouseEvent*); void mouseReleaseEvent(QGraphicsSceneMouseEvent*); void hoverMoveEvent(QGraphicsSceneHoverEvent*); void hoverLeaveEvent(QGraphicsSceneHoverEvent*); private: bool externalSelection; int numMetatilesWide; Tileset *primaryTileset; Tileset *secondaryTileset; QList *selectedMetatiles; int externalSelectionWidth; int externalSelectionHeight; QList *externalSelectedMetatiles; void updateSelectedMetatiles(); uint16_t getMetatileId(int x, int y); QPoint getMetatileIdCoords(uint16_t); signals: void hoveredMetatileSelectionChanged(uint16_t); void hoveredMetatileSelectionCleared(); void selectedMetatilesChanged(); }; #endif // METATILESELECTOR_H