DraggaglePixmapItem -> EventPixmapItem

This commit is contained in:
GriffinR
2025-04-08 12:42:23 -04:00
parent c53e9fcb28
commit 714cce670f
12 changed files with 41 additions and 41 deletions

View File

@@ -14,7 +14,7 @@ class Map;
class Layout;
class Blockdata;
class Event;
class DraggablePixmapItem;
class EventPixmapItem;
class Editor;
enum CommandId {

View File

@@ -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> eventFrame;

View File

@@ -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<Event*> &events);
void selectMapEvent(Event *event, bool toggle = false);
@@ -116,7 +116,7 @@ public:
void duplicateSelectedEvents();
void redrawAllEvents();
void redrawEvents(const QList<Event*> &events);
void redrawEventPixmapItem(DraggablePixmapItem *item);
void redrawEventPixmapItem(EventPixmapItem *item);
qreal getEventOpacity(const Event *event) const;
void updateCursorRectPos(int x, int y);

View File

@@ -1,5 +1,5 @@
#ifndef DRAGGABLEPIXMAPITEM_H
#define DRAGGABLEPIXMAPITEM_H
#ifndef EVENTPIXMAPITEM_H
#define EVENTPIXMAPITEM_H
#include <QString>
#include <QGraphicsItemGroup>
@@ -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

View File

@@ -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 \

View File

@@ -1,5 +1,5 @@
#include "editcommands.h"
#include "draggablepixmapitem.h"
#include "eventpixmapitem.h"
#include "bordermetatilespixmapitem.h"
#include "editor.h"

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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"

View File

@@ -1,7 +1,7 @@
#include "eventframes.h"
#include "customattributesframe.h"
#include "editcommands.h"
#include "draggablepixmapitem.h"
#include "eventpixmapitem.h"
#include <limits>
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<int>::of(&QSpinBox::valueChanged), [this](int value) {
@@ -123,7 +123,7 @@ void EventFrame::connectSignals(MainWindow *) {
this->event->getMap()->commit(new EventMove(QList<Event *>() << 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<int>::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();

View File

@@ -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;

View File

@@ -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).