#pragma once #include "core/domain/EntityIntro.h" #include "props/PropertySectionWidget.h" #include #include #include #include class QLabel; class QLineEdit; class QDoubleSpinBox; class QSpinBox; class QCheckBox; class QTextEdit; class QListWidget; class QPushButton; class QToolButton; class QTimer; class QWidget; namespace gui { class Vec2DoubleParamControl; } namespace gui { struct EntityPropertyUiState { QString displayName; int depthZ = 0; QString distanceScaleText; /// 中心:无父级时为形心世界坐标(与画布十字一致,用于距离/位置缩放);有父级时为形心相对父级形心的偏移。 QPointF centerPosition; /// 相对位置:变换原点相对自身形心(世界坐标差)。 QPointF relativeToOwnCenter; bool hasParent = false; int priority = 1; double userScale = 1.0; bool ignoreDistanceScale = false; bool visible = true; QImage spritePreview; core::EntityIntroContent intro; }; // 实体相关属性(可嵌入 QStackedWidget 的一页) class EntityPropertySection final : public PropertySectionWidget { Q_OBJECT public: explicit EntityPropertySection(QWidget* parent = nullptr); void clearDisconnected(); void applyState(const EntityPropertyUiState& s); void setEditingEnabled(bool on); [[nodiscard]] core::EntityIntroContent introSnapshot() const; void appendIntroImagePath(const QString& relativePath); signals: void displayNameCommitted(const QString& text); /// 编辑中心:无父为形心世界坐标;有父为形心相对父形心的偏移(整体平移实体) void centerPositionEdited(double x, double y); /// 编辑相对自身形心的原点偏移(改枢轴、外形世界位置不变) void relativeToOwnCenterEdited(double x, double y); void priorityEdited(int value); void userScaleEdited(double value); void ignoreDistanceScaleToggled(bool on); // 可见性(动画通道):在当前帧写关键帧 void visibleToggled(bool on); /// 介绍字段变更后防抖触发,由主窗口写入工程 void introContentEdited(); void introAddImageRequested(); void spriteEditRequested(); private: void scheduleIntroPersist(); void setIntroSectionExpanded(bool expanded); QLineEdit* m_name = nullptr; QLabel* m_depth = nullptr; QLabel* m_distScale = nullptr; QLabel* m_centerLabel = nullptr; QLabel* m_relativeLabel = nullptr; QSpinBox* m_priority = nullptr; Vec2DoubleParamControl* m_centerPosition = nullptr; Vec2DoubleParamControl* m_relativeToOwnCenter = nullptr; QDoubleSpinBox* m_userScale = nullptr; QCheckBox* m_ignoreDistanceScale = nullptr; QCheckBox* m_visible = nullptr; QLabel* m_spritePreview = nullptr; QPushButton* m_btnEditSprite = nullptr; quint64 m_spritePreviewCacheKey = 0; QSize m_spritePreviewLastTargetSize; QLineEdit* m_introTitle = nullptr; QTextEdit* m_introBody = nullptr; QLineEdit* m_introVideo = nullptr; QListWidget* m_introImages = nullptr; QPushButton* m_btnIntroAddImage = nullptr; QPushButton* m_btnIntroRemoveImage = nullptr; QWidget* m_introHeader = nullptr; QToolButton* m_introToggle = nullptr; QWidget* m_introContent = nullptr; QTimer* m_introSaveTimer = nullptr; bool m_introBulkUpdate = false; }; } // namespace gui