From 40078888f8b653512744c8eb99a1cc134b37d279 Mon Sep 17 00:00:00 2001 From: garak Date: Mon, 7 Sep 2020 14:05:17 -0400 Subject: [PATCH] show or hide rects immediately with shortcuts --- include/ui/mappixmapitem.h | 2 ++ src/mainwindow.cpp | 6 ++++++ src/ui/mappixmapitem.cpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/include/ui/mappixmapitem.h b/include/ui/mappixmapitem.h index 554e6f77..e8a1cd1c 100644 --- a/include/ui/mappixmapitem.h +++ b/include/ui/mappixmapitem.h @@ -33,6 +33,7 @@ public: MetatileSelector *metatileSelector; Settings *settings; bool active; + bool has_mouse = false; bool right_click; int paint_tile_initial_x; int paint_tile_initial_y; @@ -93,6 +94,7 @@ signals: protected: void hoverMoveEvent(QGraphicsSceneHoverEvent*); + void hoverEnterEvent(QGraphicsSceneHoverEvent*); void hoverLeaveEvent(QGraphicsSceneHoverEvent*); void mousePressEvent(QGraphicsSceneMouseEvent*); void mouseMoveEvent(QGraphicsSceneMouseEvent*); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 930f7988..ee1bd97e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1366,6 +1366,9 @@ void MainWindow::on_actionPlayer_View_Rectangle_triggered() bool enabled = ui->actionPlayer_View_Rectangle->isChecked(); porymapConfig.setShowPlayerView(enabled); this->editor->settings->playerViewRectEnabled = enabled; + if (this->editor->map_item->has_mouse) { + this->editor->playerViewRect->setVisible(enabled); + } } void MainWindow::on_actionCursor_Tile_Outline_triggered() @@ -1373,6 +1376,9 @@ void MainWindow::on_actionCursor_Tile_Outline_triggered() bool enabled = ui->actionCursor_Tile_Outline->isChecked(); porymapConfig.setShowCursorTile(enabled); this->editor->settings->cursorTileRectEnabled = enabled; + if (this->editor->map_item->has_mouse) { + this->editor->cursorMapTileRect->setVisible(enabled); + } } void MainWindow::on_actionUse_Encounter_Json_triggered(bool checked) diff --git a/src/ui/mappixmapitem.cpp b/src/ui/mappixmapitem.cpp index 593e071e..60555d84 100644 --- a/src/ui/mappixmapitem.cpp +++ b/src/ui/mappixmapitem.cpp @@ -747,11 +747,15 @@ void MapPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { setCursor(this->settings->mapCursor); } } +void MapPixmapItem::hoverEnterEvent(QGraphicsSceneHoverEvent *) { + this->has_mouse = true; +} void MapPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) { emit this->hoveredMapMetatileCleared(); if (this->settings->betterCursors && this->paintingMode != MapPixmapItem::PaintMode::Disabled) { unsetCursor(); } + this->has_mouse = false; } void MapPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { QPointF pos = event->pos();