From 714cce670fdbb2682e3f49f8402f10635ee02d8a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 8 Apr 2025 12:42:23 -0400 Subject: [PATCH] DraggaglePixmapItem -> EventPixmapItem --- include/core/editcommands.h | 2 +- include/core/events.h | 8 ++++---- include/editor.h | 6 +++--- ...draggablepixmapitem.h => eventpixmapitem.h} | 12 ++++++------ porymap.pro | 4 ++-- src/core/editcommands.cpp | 2 +- src/core/events.cpp | 2 +- src/editor.cpp | 14 +++++++------- src/mainwindow.cpp | 2 +- src/ui/eventframes.cpp | 10 +++++----- ...gablepixmapitem.cpp => eventpixmapitem.cpp} | 18 +++++++++--------- src/ui/mapimageexporter.cpp | 2 +- 12 files changed, 41 insertions(+), 41 deletions(-) rename include/ui/{draggablepixmapitem.h => eventpixmapitem.h} (77%) rename src/ui/{draggablepixmapitem.cpp => eventpixmapitem.cpp} (85%) diff --git a/include/core/editcommands.h b/include/core/editcommands.h index 9a54063c..5dc4bf0c 100644 --- a/include/core/editcommands.h +++ b/include/core/editcommands.h @@ -14,7 +14,7 @@ class Map; class Layout; class Blockdata; class Event; -class DraggablePixmapItem; +class EventPixmapItem; class Editor; enum CommandId { diff --git a/include/core/events.h b/include/core/events.h index 2b2f5e40..3963e022 100644 --- a/include/core/events.h +++ b/include/core/events.h @@ -19,7 +19,7 @@ class EventFrame; class ObjectFrame; class CloneObjectFrame; class WarpFrame; -class DraggablePixmapItem; +class EventPixmapItem; class Event; class ObjectEvent; @@ -154,8 +154,8 @@ public: void setPixmap(QPixmap newPixmap) { this->pixmap = newPixmap; } QPixmap getPixmap() const { return this->pixmap; } - void setPixmapItem(DraggablePixmapItem *item); - DraggablePixmapItem *getPixmapItem() const { return this->pixmapItem; } + void setPixmapItem(EventPixmapItem *item); + EventPixmapItem *getPixmapItem() const { return this->pixmapItem; } void setUsesDefaultPixmap(bool newUsesDefaultPixmap) { this->usesDefaultPixmap = newUsesDefaultPixmap; } bool getUsesDefaultPixmap() const { return this->usesDefaultPixmap; } @@ -194,7 +194,7 @@ protected: QJsonObject customAttributes; QPixmap pixmap; - DraggablePixmapItem *pixmapItem = nullptr; + EventPixmapItem *pixmapItem = nullptr; QPointer eventFrame; diff --git a/include/editor.h b/include/editor.h index a4d3d6c3..60ead193 100644 --- a/include/editor.h +++ b/include/editor.h @@ -30,7 +30,7 @@ #include "mapruler.h" #include "encountertablemodel.h" -class DraggablePixmapItem; +class EventPixmapItem; class MetatilesPixmapItem; class Editor : public QObject @@ -107,7 +107,7 @@ public: void toggleBorderVisibility(bool visible, bool enableScriptCallback = true); void updateCustomMapAttributes(); - DraggablePixmapItem *addEventPixmapItem(Event *event); + EventPixmapItem *addEventPixmapItem(Event *event); void removeEventPixmapItem(Event *event); bool canAddEvents(const QList &events); void selectMapEvent(Event *event, bool toggle = false); @@ -116,7 +116,7 @@ public: void duplicateSelectedEvents(); void redrawAllEvents(); void redrawEvents(const QList &events); - void redrawEventPixmapItem(DraggablePixmapItem *item); + void redrawEventPixmapItem(EventPixmapItem *item); qreal getEventOpacity(const Event *event) const; void updateCursorRectPos(int x, int y); diff --git a/include/ui/draggablepixmapitem.h b/include/ui/eventpixmapitem.h similarity index 77% rename from include/ui/draggablepixmapitem.h rename to include/ui/eventpixmapitem.h index 5c617099..18813bc0 100644 --- a/include/ui/draggablepixmapitem.h +++ b/include/ui/eventpixmapitem.h @@ -1,5 +1,5 @@ -#ifndef DRAGGABLEPIXMAPITEM_H -#define DRAGGABLEPIXMAPITEM_H +#ifndef EVENTPIXMAPITEM_H +#define EVENTPIXMAPITEM_H #include #include @@ -12,12 +12,12 @@ class Editor; -class DraggablePixmapItem : public QObject, public QGraphicsPixmapItem { +class EventPixmapItem : public QObject, public QGraphicsPixmapItem { Q_OBJECT public: - DraggablePixmapItem(QPixmap pixmap): QGraphicsPixmapItem(pixmap) {} + EventPixmapItem(QPixmap pixmap): QGraphicsPixmapItem(pixmap) {} - DraggablePixmapItem(Event *event, Editor *editor) : QGraphicsPixmapItem(event->getPixmap()) { + EventPixmapItem(Event *event, Editor *editor) : QGraphicsPixmapItem(event->getPixmap()) { this->event = event; event->setPixmapItem(this); this->editor = editor; @@ -52,4 +52,4 @@ protected: virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override { emit doubleClicked(this->event); } }; -#endif // DRAGGABLEPIXMAPITEM_H +#endif // EVENTPIXMAPITEM_H diff --git a/porymap.pro b/porymap.pro index 35fd6af2..7374ac30 100644 --- a/porymap.pro +++ b/porymap.pro @@ -73,7 +73,7 @@ SOURCES += src/core/advancemapparser.cpp \ src/ui/customscriptseditor.cpp \ src/ui/customscriptslistitem.cpp \ src/ui/divingmappixmapitem.cpp \ - src/ui/draggablepixmapitem.cpp \ + src/ui/eventpixmapitem.cpp \ src/ui/bordermetatilespixmapitem.cpp \ src/ui/collisionpixmapitem.cpp \ src/ui/connectionpixmapitem.cpp \ @@ -184,7 +184,7 @@ HEADERS += include/core/advancemapparser.h \ include/ui/customscriptseditor.h \ include/ui/customscriptslistitem.h \ include/ui/divingmappixmapitem.h \ - include/ui/draggablepixmapitem.h \ + include/ui/eventpixmapitem.h \ include/ui/bordermetatilespixmapitem.h \ include/ui/collisionpixmapitem.h \ include/ui/connectionpixmapitem.h \ diff --git a/src/core/editcommands.cpp b/src/core/editcommands.cpp index 8850448d..684d98c7 100644 --- a/src/core/editcommands.cpp +++ b/src/core/editcommands.cpp @@ -1,5 +1,5 @@ #include "editcommands.h" -#include "draggablepixmapitem.h" +#include "eventpixmapitem.h" #include "bordermetatilespixmapitem.h" #include "editor.h" diff --git a/src/core/events.cpp b/src/core/events.cpp index fbd4e568..694919c0 100644 --- a/src/core/events.cpp +++ b/src/core/events.cpp @@ -34,7 +34,7 @@ void Event::destroyEventFrame() { this->eventFrame = nullptr; } -void Event::setPixmapItem(DraggablePixmapItem *item) { +void Event::setPixmapItem(EventPixmapItem *item) { this->pixmapItem = item; if (this->eventFrame) { this->eventFrame->invalidateConnections(); diff --git a/src/editor.cpp b/src/editor.cpp index 93085d63..f618361c 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -1,5 +1,5 @@ #include "editor.h" -#include "draggablepixmapitem.h" +#include "eventpixmapitem.h" #include "imageproviders.h" #include "log.h" #include "connectionslistitem.h" @@ -1692,10 +1692,10 @@ void Editor::displayMapEvents() { events_group->setHandlesChildEvents(false); } -DraggablePixmapItem *Editor::addEventPixmapItem(Event *event) { +EventPixmapItem *Editor::addEventPixmapItem(Event *event) { this->project->loadEventPixmap(event); - auto item = new DraggablePixmapItem(event, this); - connect(item, &DraggablePixmapItem::doubleClicked, this, &Editor::openEventMap); + auto item = new EventPixmapItem(event, this); + connect(item, &EventPixmapItem::doubleClicked, this, &Editor::openEventMap); redrawEventPixmapItem(item); this->events_group->addToGroup(item); return item; @@ -1971,7 +1971,7 @@ qreal Editor::getEventOpacity(const Event *event) const { return event->getUsesDefaultPixmap() ? 0.7 : 1.0; } -void Editor::redrawEventPixmapItem(DraggablePixmapItem *item) { +void Editor::redrawEventPixmapItem(EventPixmapItem *item) { if (!item || !item->event) return; @@ -2287,8 +2287,8 @@ bool Editor::startDetachedProcess(const QString &command, const QString &working } // It doesn't seem to be possible to prevent the mousePress event -// from triggering both event's DraggablePixmapItem and the background mousePress. -// Since the DraggablePixmapItem's event fires first, we can set a temp +// from triggering both event's EventPixmapItem and the background mousePress. +// Since the EventPixmapItem's event fires first, we can set a temp // variable "selectingEvent" so that we can detect whether or not the user // is clicking on the background instead of an event. void Editor::eventsView_onMousePress(QMouseEvent *event) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9bea0f4a..67f48be7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -10,7 +10,7 @@ #include "customattributesframe.h" #include "scripting.h" #include "adjustingstackedwidget.h" -#include "draggablepixmapitem.h" +#include "eventpixmapitem.h" #include "editcommands.h" #include "flowlayout.h" #include "shortcut.h" diff --git a/src/ui/eventframes.cpp b/src/ui/eventframes.cpp index d392017b..c8682aa7 100644 --- a/src/ui/eventframes.cpp +++ b/src/ui/eventframes.cpp @@ -1,7 +1,7 @@ #include "eventframes.h" #include "customattributesframe.h" #include "editcommands.h" -#include "draggablepixmapitem.h" +#include "eventpixmapitem.h" #include using std::numeric_limits; @@ -114,7 +114,7 @@ void EventFrame::connectSignals(MainWindow *) { } }); - connect(this->event->getPixmapItem(), &DraggablePixmapItem::xChanged, this->spinner_x, &NoScrollSpinBox::setValue); + connect(this->event->getPixmapItem(), &EventPixmapItem::xChanged, this->spinner_x, &NoScrollSpinBox::setValue); this->spinner_y->disconnect(); connect(this->spinner_y, QOverload::of(&QSpinBox::valueChanged), [this](int value) { @@ -123,7 +123,7 @@ void EventFrame::connectSignals(MainWindow *) { this->event->getMap()->commit(new EventMove(QList() << this->event, 0, delta, this->spinner_y->getActionId())); } }); - connect(this->event->getPixmapItem(), &DraggablePixmapItem::yChanged, this->spinner_y, &NoScrollSpinBox::setValue); + connect(this->event->getPixmapItem(), &EventPixmapItem::yChanged, this->spinner_y, &NoScrollSpinBox::setValue); this->spinner_z->disconnect(); connect(this->spinner_z, QOverload::of(&QSpinBox::valueChanged), [this](int value) { @@ -297,7 +297,7 @@ void ObjectFrame::connectSignals(MainWindow *window) { this->object->getPixmapItem()->updatePixmap(); this->object->modify(); }); - connect(this->object->getPixmapItem(), &DraggablePixmapItem::spriteChanged, this->label_icon, &QLabel::setPixmap); + connect(this->object->getPixmapItem(), &EventPixmapItem::spriteChanged, this->label_icon, &QLabel::setPixmap); // movement this->combo_movement->disconnect(); @@ -439,7 +439,7 @@ void CloneObjectFrame::connectSignals(MainWindow *window) { EventFrame::connectSignals(window); // update icon displayed in frame with target - connect(this->clone->getPixmapItem(), &DraggablePixmapItem::spriteChanged, this->label_icon, &QLabel::setPixmap); + connect(this->clone->getPixmapItem(), &EventPixmapItem::spriteChanged, this->label_icon, &QLabel::setPixmap); // target map this->combo_target_map->disconnect(); diff --git a/src/ui/draggablepixmapitem.cpp b/src/ui/eventpixmapitem.cpp similarity index 85% rename from src/ui/draggablepixmapitem.cpp rename to src/ui/eventpixmapitem.cpp index a73a7ace..cc0d76e1 100644 --- a/src/ui/draggablepixmapitem.cpp +++ b/src/ui/eventpixmapitem.cpp @@ -1,4 +1,4 @@ -#include "draggablepixmapitem.h" +#include "eventpixmapitem.h" #include "editor.h" #include "editcommands.h" #include "mapruler.h" @@ -7,7 +7,7 @@ static unsigned currentActionId = 0; -void DraggablePixmapItem::updatePosition() { +void EventPixmapItem::updatePosition() { int x = this->event->getPixelX(); int y = this->event->getPixelY(); setX(x); @@ -15,17 +15,17 @@ void DraggablePixmapItem::updatePosition() { editor->updateWarpEventWarning(event); } -void DraggablePixmapItem::emitPositionChanged() { +void EventPixmapItem::emitPositionChanged() { emit xChanged(event->getX()); emit yChanged(event->getY()); } -void DraggablePixmapItem::updatePixmap() { +void EventPixmapItem::updatePixmap() { editor->redrawEventPixmapItem(this); emit spriteChanged(event->getPixmap()); } -void DraggablePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) { +void EventPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) { if (this->active) return; this->active = true; @@ -49,21 +49,21 @@ void DraggablePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) { this->editor->selectingEvent = true; } -void DraggablePixmapItem::move(int dx, int dy) { +void EventPixmapItem::move(int dx, int dy) { event->setX(event->getX() + dx); event->setY(event->getY() + dy); updatePosition(); emitPositionChanged(); } -void DraggablePixmapItem::moveTo(const QPoint &pos) { +void EventPixmapItem::moveTo(const QPoint &pos) { event->setX(pos.x()); event->setY(pos.y()); updatePosition(); emitPositionChanged(); } -void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) { +void EventPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) { if (!this->active) return; @@ -85,7 +85,7 @@ void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) { this->releaseSelectionQueued = false; } -void DraggablePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouse) { +void EventPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouse) { if (!this->active) return; this->active = false; diff --git a/src/ui/mapimageexporter.cpp b/src/ui/mapimageexporter.cpp index 39607bca..fe2865b0 100644 --- a/src/ui/mapimageexporter.cpp +++ b/src/ui/mapimageexporter.cpp @@ -96,7 +96,7 @@ void MapImageExporter::setModeSpecificUi() { } if (m_mode == ImageExporterMode::Timelapse) { - // TODO: At the moment edit history for events (and the DraggablePixmapItem class) + // TODO: At the moment edit history for events (and the EventPixmapItem class) // explicitly depend on the editor and assume their map is currently open. // Other edit commands rely on this more subtly, like triggering API callbacks or // spending time rendering their layout (which can make creating timelapses very slow).