Move map cursor UI and grid to foreground

This commit is contained in:
GriffinR 2021-12-12 12:19:59 -05:00 committed by huderlem
parent 39cd1d335b
commit 36dc1c6649
13 changed files with 118 additions and 75 deletions

View file

@ -344,7 +344,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="GraphicsView" name="graphicsView_Map"> <widget class="MapView" name="graphicsView_Map">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>

View file

@ -102,6 +102,8 @@ public:
void duplicateSelectedEvents(); void duplicateSelectedEvents();
void redrawObject(DraggablePixmapItem *item); void redrawObject(DraggablePixmapItem *item);
QList<DraggablePixmapItem *> getObjects(); QList<DraggablePixmapItem *> getObjects();
void updateCursorRectPos(int x, int y);
void setCursorRectVisible(bool visible);
QGraphicsScene *scene = nullptr; QGraphicsScene *scene = nullptr;
QGraphicsPixmapItem *current_view = nullptr; QGraphicsPixmapItem *current_view = nullptr;

View file

@ -41,10 +41,10 @@ public:
} }
painter->setPen(this->color); painter->setPen(this->color);
painter->drawRect(-1, -1, width + 2, height + 2); painter->drawRect(x() - 1, y() - 1, width + 2, height + 2);
painter->setPen(QColor(0, 0, 0)); painter->setPen(QColor(0, 0, 0));
painter->drawRect(-2, -2, width + 4, height + 4); painter->drawRect(x() - 2, y() - 2, width + 4, height + 4);
painter->drawRect(0, 0, width, height); painter->drawRect(x(), y(), width, height);
} }
void initAnchor(int coordX, int coordY); void initAnchor(int coordX, int coordY);
void stopAnchor(); void stopAnchor();
@ -58,10 +58,10 @@ public:
void stopSingleTileMode(); void stopSingleTileMode();
void updateLocation(int x, int y); void updateLocation(int x, int y);
void updateSelectionSize(int width, int height); void updateSelectionSize(int width, int height);
void setVisibility(bool visible); void setActive(bool active);
bool *enabled; bool *enabled;
private: private:
bool visible; bool active;
int width; int width;
int height; int height;
bool anchored; bool anchored;

View file

@ -1,7 +1,6 @@
#ifndef GRAPHICSVIEW_H #ifndef GRAPHICSVIEW_H
#define GRAPHICSVIEW_H #define GRAPHICSVIEW_H
#include "overlay.h"
#include <QGraphicsView> #include <QGraphicsView>
#include <QMouseEvent> #include <QMouseEvent>
@ -12,23 +11,14 @@ class GraphicsView : public QGraphicsView
public: public:
GraphicsView() : QGraphicsView() {} GraphicsView() : QGraphicsView() {}
GraphicsView(QWidget *parent) : QGraphicsView(parent) {} GraphicsView(QWidget *parent) : QGraphicsView(parent) {}
Overlay * getOverlay(int layer);
void clearOverlays();
void setOverlaysHidden(bool hidden);
void setOverlaysX(int x);
void setOverlaysY(int y);
void setOverlaysPosition(int x, int y);
void moveOverlays(int deltaX, int deltaY);
public: public:
// GraphicsView_Object object; // GraphicsView_Object object;
Editor *editor; Editor *editor;
QMap<int, Overlay*> overlayMap;
protected: protected:
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event);
void drawForeground(QPainter *painter, const QRectF &rect);
void moveEvent(QMoveEvent *event); void moveEvent(QMoveEvent *event);
}; };

View file

@ -40,6 +40,7 @@ public:
bool prevStraightPathState; bool prevStraightPathState;
int straight_path_initial_x; int straight_path_initial_x;
int straight_path_initial_y; int straight_path_initial_y;
QPoint metatilePos;
enum Axis { enum Axis {
None = 0, None = 0,
X, X,

26
include/ui/mapview.h Normal file
View file

@ -0,0 +1,26 @@
#ifndef MAPVIEW_H
#define MAPVIEW_H
#include "graphicsview.h"
#include "overlay.h"
class MapView : public GraphicsView
{
public:
MapView() : GraphicsView() {}
MapView(QWidget *parent) : GraphicsView(parent) {}
Overlay * getOverlay(int layer);
void clearOverlays();
void setOverlaysHidden(bool hidden);
void setOverlaysX(int x);
void setOverlaysY(int y);
void setOverlaysPosition(int x, int y);
void moveOverlays(int deltaX, int deltaY);
public:
QMap<int, Overlay*> overlayMap;
protected:
void drawForeground(QPainter *painter, const QRectF &rect);
};
#endif // GRAPHICSVIEW_H

View file

@ -20,11 +20,12 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
{ {
if (!(*enabled)) return;
painter->setPen(this->color); painter->setPen(this->color);
painter->drawRect(-2, -2, this->width + 3, this->height + 3); painter->drawRect(x() - 2, y() - 2, this->width + 3, this->height + 3);
painter->setPen(QColor(0, 0, 0)); painter->setPen(QColor(0, 0, 0));
painter->drawRect(-3, -3, this->width + 5, this->height + 5); painter->drawRect(x() - 3, y() - 3, this->width + 5, this->height + 5);
painter->drawRect(-1, -1, this->width + 1, this->height + 1); painter->drawRect(x() - 1, y() - 1, this->width + 1, this->height + 1);
} }
void updateLocation(int x, int y); void updateLocation(int x, int y);
bool *enabled; bool *enabled;

View file

@ -96,7 +96,7 @@ void Editor::setEditingMap() {
setBorderItemsVisible(ui->checkBox_ToggleBorder->isChecked()); setBorderItemsVisible(ui->checkBox_ToggleBorder->isChecked());
setConnectionItemsVisible(false); setConnectionItemsVisible(false);
this->cursorMapTileRect->stopSingleTileMode(); this->cursorMapTileRect->stopSingleTileMode();
this->cursorMapTileRect->setVisibility(true); this->cursorMapTileRect->setActive(true);
setMapEditingButtonsEnabled(true); setMapEditingButtonsEnabled(true);
} }
@ -119,7 +119,7 @@ void Editor::setEditingCollision() {
setBorderItemsVisible(ui->checkBox_ToggleBorder->isChecked()); setBorderItemsVisible(ui->checkBox_ToggleBorder->isChecked());
setConnectionItemsVisible(false); setConnectionItemsVisible(false);
this->cursorMapTileRect->setSingleTileMode(); this->cursorMapTileRect->setSingleTileMode();
this->cursorMapTileRect->setVisibility(true); this->cursorMapTileRect->setActive(true);
setMapEditingButtonsEnabled(true); setMapEditingButtonsEnabled(true);
} }
@ -142,7 +142,7 @@ void Editor::setEditingObjects() {
setBorderItemsVisible(ui->checkBox_ToggleBorder->isChecked()); setBorderItemsVisible(ui->checkBox_ToggleBorder->isChecked());
setConnectionItemsVisible(false); setConnectionItemsVisible(false);
this->cursorMapTileRect->setSingleTileMode(); this->cursorMapTileRect->setSingleTileMode();
this->cursorMapTileRect->setVisibility(false); this->cursorMapTileRect->setActive(false);
setMapEditingButtonsEnabled(false); setMapEditingButtonsEnabled(false);
} }
@ -190,7 +190,7 @@ void Editor::setEditingConnections() {
setBorderItemsVisible(true, 0.4); setBorderItemsVisible(true, 0.4);
setConnectionItemsVisible(true); setConnectionItemsVisible(true);
this->cursorMapTileRect->setSingleTileMode(); this->cursorMapTileRect->setSingleTileMode();
this->cursorMapTileRect->setVisibility(false); this->cursorMapTileRect->setActive(false);
} }
void Editor::displayWildMonTables() { void Editor::displayWildMonTables() {
@ -985,9 +985,26 @@ void Editor::scaleMapView(int s) {
ui->graphicsView_Connections->setTransform(transform); ui->graphicsView_Connections->setTransform(transform);
} }
void Editor::updateCursorRectPos(int x, int y) {
if (this->playerViewRect)
this->playerViewRect->updateLocation(x, y);
if (this->cursorMapTileRect)
this->cursorMapTileRect->updateLocation(x, y);
if (ui->graphicsView_Map->scene())
ui->graphicsView_Map->scene()->update();
}
void Editor::setCursorRectVisible(bool visible) {
if (this->playerViewRect)
this->playerViewRect->setVisible(visible);
if (this->cursorMapTileRect)
this->cursorMapTileRect->setVisible(visible);
if (ui->graphicsView_Map->scene())
ui->graphicsView_Map->scene()->update();
}
void Editor::onHoveredMapMetatileChanged(const QPoint &pos) { void Editor::onHoveredMapMetatileChanged(const QPoint &pos) {
this->playerViewRect->updateLocation(pos.x(), pos.y()); this->updateCursorRectPos(pos.x(), pos.y());
this->cursorMapTileRect->updateLocation(pos.x(), pos.y());
if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles
&& pos.x() >= 0 && pos.x() < map->getWidth() && pos.y() >= 0 && pos.y() < map->getHeight()) { && pos.x() >= 0 && pos.x() < map->getWidth() && pos.y() >= 0 && pos.y() < map->getHeight()) {
int blockIndex = pos.y() * map->getWidth() + pos.x(); int blockIndex = pos.y() * map->getWidth() + pos.x();
@ -1007,8 +1024,7 @@ void Editor::onHoveredMapMetatileChanged(const QPoint &pos) {
} }
void Editor::onHoveredMapMetatileCleared() { void Editor::onHoveredMapMetatileCleared() {
this->playerViewRect->setVisible(false); this->setCursorRectVisible(false);
this->cursorMapTileRect->setVisible(false);
if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles
|| map_item->paintingMode == MapPixmapItem::PaintMode::EventObjects) { || map_item->paintingMode == MapPixmapItem::PaintMode::EventObjects) {
this->ui->statusBar->clearMessage(); this->ui->statusBar->clearMessage();
@ -1016,8 +1032,7 @@ void Editor::onHoveredMapMetatileCleared() {
} }
void Editor::onHoveredMapMovementPermissionChanged(int x, int y) { void Editor::onHoveredMapMovementPermissionChanged(int x, int y) {
this->playerViewRect->updateLocation(x, y); this->updateCursorRectPos(x, y);
this->cursorMapTileRect->updateLocation(x, y);
if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles
&& x >= 0 && x < map->getWidth() && y >= 0 && y < map->getHeight()) { && x >= 0 && x < map->getWidth() && y >= 0 && y < map->getHeight()) {
int blockIndex = y * map->getWidth() + x; int blockIndex = y * map->getWidth() + x;
@ -1032,8 +1047,7 @@ void Editor::onHoveredMapMovementPermissionChanged(int x, int y) {
} }
void Editor::onHoveredMapMovementPermissionCleared() { void Editor::onHoveredMapMovementPermissionCleared() {
this->playerViewRect->setVisible(false); this->setCursorRectVisible(false);
this->cursorMapTileRect->setVisible(false);
if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles) { if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles) {
this->ui->statusBar->clearMessage(); this->ui->statusBar->clearMessage();
} }
@ -1243,8 +1257,6 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item
} }
} }
} }
this->playerViewRect->updateLocation(pos.x(), pos.y());
this->cursorMapTileRect->updateLocation(pos.x(), pos.y());
} }
void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item) { void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item) {
@ -1291,8 +1303,6 @@ void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixm
} }
item->shift(event); item->shift(event);
} }
this->playerViewRect->updateLocation(pos.x(), pos.y());
this->cursorMapTileRect->updateLocation(pos.x(), pos.y());
} }
bool Editor::displayMap() { bool Editor::displayMap() {
@ -1307,8 +1317,6 @@ bool Editor::displayMap() {
if (map_item && scene) { if (map_item && scene) {
scene->removeItem(map_item); scene->removeItem(map_item);
delete map_item; delete map_item;
scene->removeItem(this->playerViewRect);
scene->removeItem(this->cursorMapTileRect);
scene->removeItem(this->map_ruler); scene->removeItem(this->map_ruler);
} }
@ -1324,11 +1332,7 @@ bool Editor::displayMap() {
displayMapGrid(); displayMapGrid();
displayWildMonTables(); displayWildMonTables();
this->playerViewRect->setZValue(1000); this->map_ruler->setZValue(1000);
this->cursorMapTileRect->setZValue(1001);
this->map_ruler->setZValue(1002);
scene->addItem(this->playerViewRect);
scene->addItem(this->cursorMapTileRect);
scene->addItem(this->map_ruler); scene->addItem(this->map_ruler);
if (map_item) { if (map_item) {
@ -1670,14 +1674,13 @@ int Editor::getBorderDrawDistance(int dimension) {
void Editor::onToggleGridClicked(bool checked) { void Editor::onToggleGridClicked(bool checked) {
porymapConfig.setShowGrid(checked); porymapConfig.setShowGrid(checked);
if (ui->graphicsView_Map->scene())
ui->graphicsView_Map->scene()->update();
} }
void Editor::displayMapGrid() { void Editor::displayMapGrid() {
for (QGraphicsLineItem* item : gridLines) { for (QGraphicsLineItem* item : gridLines) {
if (item && item->scene()) { if (item) delete item;
item->scene()->removeItem(item);
}
delete item;
} }
gridLines.clear(); gridLines.clear();
ui->checkBox_ToggleGrid->disconnect(); ui->checkBox_ToggleGrid->disconnect();
@ -1686,14 +1689,14 @@ void Editor::displayMapGrid() {
int pixelHeight = map->getHeight() * 16; int pixelHeight = map->getHeight() * 16;
for (int i = 0; i <= map->getWidth(); i++) { for (int i = 0; i <= map->getWidth(); i++) {
int x = i * 16; int x = i * 16;
QGraphicsLineItem *line = scene->addLine(x, 0, x, pixelHeight); QGraphicsLineItem *line = new QGraphicsLineItem(x, 0, x, pixelHeight);
line->setVisible(ui->checkBox_ToggleGrid->isChecked()); line->setVisible(ui->checkBox_ToggleGrid->isChecked());
gridLines.append(line); gridLines.append(line);
connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);}); connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);});
} }
for (int j = 0; j <= map->getHeight(); j++) { for (int j = 0; j <= map->getHeight(); j++) {
int y = j * 16; int y = j * 16;
QGraphicsLineItem *line = scene->addLine(0, y, pixelWidth, y); QGraphicsLineItem *line = new QGraphicsLineItem(0, y, pixelWidth, y);
line->setVisible(ui->checkBox_ToggleGrid->isChecked()); line->setVisible(ui->checkBox_ToggleGrid->isChecked());
gridLines.append(line); gridLines.append(line);
connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);}); connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);});

View file

@ -1674,8 +1674,7 @@ void MainWindow::setMapViewTabInternal(int index)
} else if (index == 1) { } else if (index == 1) {
editor->setEditingCollision(); editor->setEditingCollision();
} }
editor->playerViewRect->setVisible(false); editor->setCursorRectVisible(false);
editor->cursorMapTileRect->setVisible(false);
} }
void MainWindow::on_action_Exit_triggered() void MainWindow::on_action_Exit_triggered()
@ -1738,6 +1737,7 @@ void MainWindow::on_actionPlayer_View_Rectangle_triggered()
this->editor->settings->playerViewRectEnabled = enabled; this->editor->settings->playerViewRectEnabled = enabled;
if (this->editor->map_item->has_mouse) { if (this->editor->map_item->has_mouse) {
this->editor->playerViewRect->setVisible(enabled); this->editor->playerViewRect->setVisible(enabled);
ui->graphicsView_Map->scene()->update();
} }
} }
@ -1747,7 +1747,8 @@ void MainWindow::on_actionCursor_Tile_Outline_triggered()
porymapConfig.setShowCursorTile(enabled); porymapConfig.setShowCursorTile(enabled);
this->editor->settings->cursorTileRectEnabled = enabled; this->editor->settings->cursorTileRectEnabled = enabled;
if (this->editor->map_item->has_mouse) { if (this->editor->map_item->has_mouse) {
this->editor->cursorMapTileRect->setVisibility(enabled); this->editor->cursorMapTileRect->setVisible(enabled);
ui->graphicsView_Map->scene()->update();
} }
} }

View file

@ -4,7 +4,7 @@
CursorTileRect::CursorTileRect(bool *enabled, QRgb color) CursorTileRect::CursorTileRect(bool *enabled, QRgb color)
{ {
this->enabled = enabled; this->enabled = enabled;
this->visible = true; this->active = true;
this->color = color; this->color = color;
this->width = 16; this->width = 16;
this->height = 16; this->height = 16;
@ -19,9 +19,9 @@ CursorTileRect::CursorTileRect(bool *enabled, QRgb color)
this->selectionHeight = 1; this->selectionHeight = 1;
} }
void CursorTileRect::setVisibility(bool visible) void CursorTileRect::setActive(bool active)
{ {
this->visible = visible; this->active = active;
} }
void CursorTileRect::initAnchor(int coordX, int coordY) void CursorTileRect::initAnchor(int coordX, int coordY)
@ -105,5 +105,5 @@ void CursorTileRect::updateLocation(int coordX, int coordY)
coordY = qMax(coordY, 0); coordY = qMax(coordY, 0);
this->setX(coordX * 16); this->setX(coordX * 16);
this->setY(coordY * 16); this->setY(coordY * 16);
this->setVisible(*this->enabled && this->visible); this->setVisible(*this->enabled && this->active);
} }

View file

@ -82,8 +82,8 @@ void DraggablePixmapItem::moveTo(const QPoint &pos) {
void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) { void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) {
if (active) { if (active) {
QPoint pos = Metatile::coordFromPixmapCoord(mouse->scenePos()); QPoint pos = Metatile::coordFromPixmapCoord(mouse->scenePos());
emit this->editor->map_item->hoveredMapMetatileChanged(pos);
if (pos.x() != last_x || pos.y() != last_y) { if (pos.x() != last_x || pos.y() != last_y) {
emit this->editor->map_item->hoveredMapMetatileChanged(pos);
QList <Event *> selectedEvents; QList <Event *> selectedEvents;
if (editor->selected_events->contains(this)) { if (editor->selected_events->contains(this)) {
for (DraggablePixmapItem *item : *editor->selected_events) { for (DraggablePixmapItem *item : *editor->selected_events) {

View file

@ -1,4 +1,5 @@
#include "graphicsview.h" #include "graphicsview.h"
#include "mapview.h"
#include "editor.h" #include "editor.h"
void GraphicsView::mousePressEvent(QMouseEvent *event) { void GraphicsView::mousePressEvent(QMouseEvent *event) {
@ -16,12 +17,31 @@ void GraphicsView::mouseReleaseEvent(QMouseEvent *event) {
QGraphicsView::mouseReleaseEvent(event); QGraphicsView::mouseReleaseEvent(event);
} }
void GraphicsView::drawForeground(QPainter *painter, const QRectF&) { void GraphicsView::moveEvent(QMoveEvent *event) {
foreach (Overlay * overlay, this->overlayMap) QGraphicsView::moveEvent(event);
overlay->renderItems(painter); QLabel *label_MapRulerStatus = findChild<QLabel *>("label_MapRulerStatus", Qt::FindDirectChildrenOnly);
if (label_MapRulerStatus && label_MapRulerStatus->isVisible())
label_MapRulerStatus->move(mapToGlobal(QPoint(6, 6)));
} }
void GraphicsView::clearOverlays() { void MapView::drawForeground(QPainter *painter, const QRectF&) {
foreach (Overlay * overlay, this->overlayMap)
overlay->renderItems(painter);
if (!editor) return;
QStyleOptionGraphicsItem option;
for (QGraphicsLineItem* line : editor->gridLines) {
if (line && line->isVisible())
line->paint(painter, &option, this);
}
if (editor->playerViewRect && editor->playerViewRect->isVisible())
editor->playerViewRect->paint(painter, &option, this);
if (editor->cursorMapTileRect && editor->cursorMapTileRect->isVisible())
editor->cursorMapTileRect->paint(painter, &option, this);
}
void MapView::clearOverlays() {
foreach (Overlay * overlay, this->overlayMap) { foreach (Overlay * overlay, this->overlayMap) {
overlay->clearItems(); overlay->clearItems();
delete overlay; delete overlay;
@ -29,32 +49,32 @@ void GraphicsView::clearOverlays() {
this->overlayMap.clear(); this->overlayMap.clear();
} }
void GraphicsView::setOverlaysHidden(bool hidden) { void MapView::setOverlaysHidden(bool hidden) {
foreach (Overlay * overlay, this->overlayMap) foreach (Overlay * overlay, this->overlayMap)
overlay->setHidden(hidden); overlay->setHidden(hidden);
} }
void GraphicsView::setOverlaysX(int x) { void MapView::setOverlaysX(int x) {
foreach (Overlay * overlay, this->overlayMap) foreach (Overlay * overlay, this->overlayMap)
overlay->setX(x); overlay->setX(x);
} }
void GraphicsView::setOverlaysY(int y) { void MapView::setOverlaysY(int y) {
foreach (Overlay * overlay, this->overlayMap) foreach (Overlay * overlay, this->overlayMap)
overlay->setY(y); overlay->setY(y);
} }
void GraphicsView::setOverlaysPosition(int x, int y) { void MapView::setOverlaysPosition(int x, int y) {
foreach (Overlay * overlay, this->overlayMap) foreach (Overlay * overlay, this->overlayMap)
overlay->setPosition(x, y); overlay->setPosition(x, y);
} }
void GraphicsView::moveOverlays(int deltaX, int deltaY) { void MapView::moveOverlays(int deltaX, int deltaY) {
foreach (Overlay * overlay, this->overlayMap) foreach (Overlay * overlay, this->overlayMap)
overlay->move(deltaX, deltaY); overlay->move(deltaX, deltaY);
} }
Overlay * GraphicsView::getOverlay(int layer) { Overlay * MapView::getOverlay(int layer) {
Overlay * overlay = this->overlayMap.value(layer, nullptr); Overlay * overlay = this->overlayMap.value(layer, nullptr);
if (!overlay) { if (!overlay) {
overlay = new Overlay(); overlay = new Overlay();
@ -62,10 +82,3 @@ Overlay * GraphicsView::getOverlay(int layer) {
} }
return overlay; return overlay;
} }
void GraphicsView::moveEvent(QMoveEvent *event) {
QGraphicsView::moveEvent(event);
QLabel *label_MapRulerStatus = findChild<QLabel *>("label_MapRulerStatus", Qt::FindDirectChildrenOnly);
if (label_MapRulerStatus && label_MapRulerStatus->isVisible())
label_MapRulerStatus->move(mapToGlobal(QPoint(6, 6)));
}

View file

@ -675,7 +675,10 @@ void MapPixmapItem::draw(bool ignoreCache) {
void MapPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { void MapPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
QPoint pos = Metatile::coordFromPixmapCoord(event->pos()); QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
emit this->hoveredMapMetatileChanged(pos); if (pos != this->metatilePos) {
this->metatilePos = pos;
emit this->hoveredMapMetatileChanged(pos);
}
if (this->settings->betterCursors && this->paintingMode != MapPixmapItem::PaintMode::Disabled) { if (this->settings->betterCursors && this->paintingMode != MapPixmapItem::PaintMode::Disabled) {
setCursor(this->settings->mapCursor); setCursor(this->settings->mapCursor);
} }
@ -699,7 +702,10 @@ void MapPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
} }
void MapPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { void MapPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
QPoint pos = Metatile::coordFromPixmapCoord(event->pos()); QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
emit this->hoveredMapMetatileChanged(pos); if (pos != this->metatilePos) {
this->metatilePos = pos;
emit this->hoveredMapMetatileChanged(pos);
}
emit mouseEvent(event, this); emit mouseEvent(event, this);
} }
void MapPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { void MapPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {