This commit is contained in:
2026-05-14 13:30:06 +08:00
parent 974946cee4
commit e43171521d
91 changed files with 10485 additions and 3254 deletions
@@ -1,6 +1,7 @@
#include "props/BackgroundPropertySection.h"
#include <QCheckBox>
#include "widgets/PropertyPanelControls.h"
#include <QFormLayout>
#include <QLabel>
#include <QVBoxLayout>
@@ -10,23 +11,22 @@ namespace gui {
BackgroundPropertySection::BackgroundPropertySection(QWidget* parent)
: PropertySectionWidget(parent) {
auto* lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(6);
polishPropertyVBoxLayout(lay);
auto* form = new QFormLayout();
form->setContentsMargins(0, 0, 0, 0);
form->setSpacing(6);
polishPropertyFormLayout(form);
m_sizeLabel = new QLabel(QStringLiteral("-"), this);
m_sizeLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
m_sizeLabel->setWordWrap(true);
form->addRow(QStringLiteral("背景尺寸"), m_sizeLabel);
m_showBackground = new QCheckBox(QStringLiteral("显示背景"), this);
m_showBackground->setToolTip(QStringLiteral("是否绘制背景图"));
m_showBackground = new PropertyPanelCheckBox(QStringLiteral("显示背景"), this);
m_showBackground->setToolTip({});
form->addRow(QString(), m_showBackground);
m_depthOverlay = new QCheckBox(QStringLiteral("叠加深度"), this);
m_depthOverlay->setToolTip(QStringLiteral("在背景上叠加深度伪彩图"));
m_depthOverlay = new PropertyPanelCheckBox(QStringLiteral("叠加深度"), this);
m_depthOverlay->setToolTip({});
form->addRow(QString(), m_depthOverlay);
lay->addLayout(form);
@@ -1,5 +1,7 @@
#include "props/BlackholePropertySection.h"
#include "widgets/PropertyPanelControls.h"
#include <QFormLayout>
#include <QLabel>
#include <QVBoxLayout>
@@ -9,17 +11,17 @@ namespace gui {
BlackholePropertySection::BlackholePropertySection(QWidget* parent)
: PropertySectionWidget(parent) {
auto* lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(6);
polishPropertyVBoxLayout(lay);
auto* form = new QFormLayout();
form->setContentsMargins(0, 0, 0, 0);
form->setSpacing(6);
polishPropertyFormLayout(form);
m_name = new QLabel(this);
m_status = new QLabel(this);
m_method = new QLabel(this);
m_method->setWordWrap(true);
for (QLabel* lab : {m_name, m_status, m_method}) {
lab->setWordWrap(true);
}
form->addRow(QStringLiteral("黑洞"), m_name);
form->addRow(QStringLiteral("是否解决"), m_status);
+16 -16
View File
@@ -4,6 +4,9 @@
#include <QCheckBox>
#include <QDoubleSpinBox>
#include "widgets/CompactNumericSpinBox.h"
#include "widgets/PropertyPanelControls.h"
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
@@ -13,32 +16,29 @@ namespace gui {
CameraPropertySection::CameraPropertySection(QWidget* parent) : PropertySectionWidget(parent) {
auto* lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(6);
polishPropertyVBoxLayout(lay);
auto* form = new QFormLayout();
form->setContentsMargins(0, 0, 0, 0);
form->setSpacing(6);
polishPropertyFormLayout(form);
m_name = new QLineEdit(this);
m_name = new PropertyPanelLineEdit(this);
m_name->setPlaceholderText(QStringLiteral("显示名称…"));
polishPropertyStretchyTextField(m_name);
form->addRow(QStringLiteral("名称"), m_name);
m_center = new Vec2ParamControl(this);
m_center->setToolTip(QStringLiteral("摄像机中心(世界坐标),与画布上黄色圆点一致"));
m_center->setToolTip({});
form->addRow(QStringLiteral("中心"), m_center);
m_viewScale = new QDoubleSpinBox(this);
m_viewScale = new CompactDoubleSpinBox(this, 56);
m_viewScale->setRange(1e-4, 1000.0);
m_viewScale->setDecimals(5);
m_viewScale->setSingleStep(0.01);
m_viewScale->setToolTip(QStringLiteral(
"视口缩放:在参考分辨率 1600×900 下的像素/世界单位比(与预览、画布上镜头框一致);"
"不随当前窗口大小改变镜头覆盖的世界范围。数值越小,可见的世界范围越大。"));
m_viewScale->setToolTip({});
form->addRow(QStringLiteral("缩放"), m_viewScale);
m_activePreview = new QCheckBox(QStringLiteral("用作预览展示镜头"), this);
m_activePreview->setToolTip(QStringLiteral("进入预览展示时,按该摄像机在当前帧的位置与缩放呈现画面"));
m_activePreview = new PropertyPanelCheckBox(QStringLiteral("用作预览展示镜头"), this);
m_activePreview->setToolTip({});
form->addRow(QStringLiteral("预览"), m_activePreview);
lay->addLayout(form);
@@ -47,7 +47,7 @@ CameraPropertySection::CameraPropertySection(QWidget* parent) : PropertySectionW
connect(m_name, &QLineEdit::editingFinished, this, [this]() {
if (m_name) emit displayNameCommitted(m_name->text());
});
connect(m_center, &Vec2ParamControl::valueChanged, this, [this](double x, double y) { emit centerEdited(x, y); });
connect(m_center, &Vec2ParamControl::valueChanged, this, [this](int x, int y) { emit centerEdited(x, y); });
connect(m_viewScale, qOverload<double>(&QDoubleSpinBox::valueChanged), this,
&CameraPropertySection::viewScaleEdited);
connect(m_activePreview, &QCheckBox::toggled, this, &CameraPropertySection::activePreviewToggled);
@@ -69,7 +69,7 @@ void CameraPropertySection::clearDisconnected() {
}
if (m_center) {
m_center->blockSignals(true);
m_center->setValue(0.0, 0.0);
m_center->setValue(0, 0);
m_center->blockSignals(false);
}
if (m_viewScale) {
@@ -91,9 +91,9 @@ void CameraPropertySection::applyState(const CameraPropertyUiState& s) {
m_name->setText(s.displayName);
m_name->blockSignals(false);
}
if (m_center) {
if (m_center && !m_center->isActivelyEditing()) {
m_center->blockSignals(true);
m_center->setValue(s.centerWorld.x(), s.centerWorld.y());
m_center->setValue(qRound(s.centerWorld.x()), qRound(s.centerWorld.y()));
m_center->blockSignals(false);
}
if (m_viewScale) {
+1 -1
View File
@@ -33,7 +33,7 @@ public:
signals:
void displayNameCommitted(const QString& text);
void centerEdited(double x, double y);
void centerEdited(int x, int y);
void viewScaleEdited(double viewScale);
void activePreviewToggled(bool on);
+135 -66
View File
@@ -3,7 +3,11 @@
#include "params/ParamControls.h"
#include <QDoubleSpinBox>
#include "widgets/CompactNumericSpinBox.h"
#include "widgets/PropertyPanelControls.h"
#include <QFormLayout>
#include <QFrame>
#include <QHBoxLayout>
#include <QCheckBox>
#include <QLabel>
@@ -20,101 +24,143 @@ namespace gui {
EntityPropertySection::EntityPropertySection(QWidget* parent)
: PropertySectionWidget(parent) {
auto* lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(6);
polishPropertyVBoxLayout(lay);
auto* form = new QFormLayout();
form->setContentsMargins(0, 0, 0, 0);
form->setSpacing(6);
polishPropertyFormLayout(form);
m_name = new QLineEdit(this);
m_name = new PropertyPanelLineEdit(this);
m_name->setPlaceholderText(QStringLiteral("显示名称"));
m_name->setToolTip(QStringLiteral("仅显示用;内部 id 不变"));
m_name->setToolTip({});
polishPropertyStretchyTextField(m_name);
form->addRow(QStringLiteral("名称"), m_name);
m_depth = new QLabel(QStringLiteral("-"), this);
m_distScale = new QLabel(QStringLiteral("-"), this);
for (QLabel* lab : {m_depth, m_distScale}) {
lab->setTextInteractionFlags(Qt::TextSelectableByMouse);
lab->setWordWrap(true);
}
form->addRow(QStringLiteral("深度"), m_depth);
form->addRow(QStringLiteral("距离缩放"), m_distScale);
m_pivotLabel = new QLabel(QStringLiteral("中心坐标"), this);
m_pivot = new Vec2ParamControl(this);
m_pivot->setToolTip(QStringLiteral("枢轴在世界坐标中的位置(限制在轮廓包络内),用于重定位局部原点"));
form->addRow(m_pivotLabel, m_pivot);
m_centerLabel = new QLabel(QStringLiteral("中心"), this);
m_centerPosition = new Vec2DoubleParamControl(this);
m_centerPosition->setToolTip(
QStringLiteral("无父级:形心世界坐标。有父级:形心相对父级形心的偏移。"));
form->addRow(m_centerLabel, m_centerPosition);
m_centroidLabel = new QLabel(QStringLiteral("位置"), this);
m_centroid = new Vec2ParamControl(this);
m_centroid->setToolTip(QStringLiteral("实体几何质心的世界坐标;修改将整体平移实体"));
form->addRow(m_centroidLabel, m_centroid);
m_relativeLabel = new QLabel(QStringLiteral("相对位置"), this);
m_relativeToOwnCenter = new Vec2DoubleParamControl(this);
m_relativeToOwnCenter->setToolTip(QStringLiteral("变换原点相对自身形心的偏移"));
form->addRow(m_relativeLabel, m_relativeToOwnCenter);
m_userScale = new QDoubleSpinBox(this);
m_priority = new CompactIntSpinBox(this, 72);
m_priority->setRange(-1000000, 1000000);
m_priority->setSingleStep(1);
m_priority->setAccelerated(true);
m_priority->setToolTip(QStringLiteral("优先级越高越靠上。背景为 0,实体默认 1;同优先级按距离缩放/深度决定覆盖关系。"));
form->addRow(QStringLiteral("优先级"), m_priority);
m_userScale = new CompactDoubleSpinBox(this, 56);
m_userScale->setRange(0.05, 20.0);
m_userScale->setDecimals(3);
m_userScale->setSingleStep(0.05);
m_userScale->setValue(1.0);
m_userScale->setToolTip(QStringLiteral("人为整体缩放,与深度距离缩放相乘"));
m_userScale->setToolTip({});
form->addRow(QStringLiteral("整体缩放"), m_userScale);
m_ignoreDistanceScale = new QCheckBox(QStringLiteral("不受距离缩放影响"), this);
m_ignoreDistanceScale->setToolTip(QStringLiteral("开启后实体不受深度驱动的距离缩放影响,仅受整体缩放影响(对话气泡默认开启)"));
m_ignoreDistanceScale = new PropertyPanelCheckBox(QStringLiteral("不受距离缩放影响"), this);
m_ignoreDistanceScale->setToolTip({});
form->addRow(QStringLiteral("距离缩放"), m_ignoreDistanceScale);
m_visible = new QCheckBox(QString(), this);
m_visible = new PropertyPanelCheckBox(QString(), this);
m_visible->setChecked(true);
m_visible->setToolTip(QStringLiteral("随帧变化:在当前帧切换会写入可见性关键帧(10帧淡入淡出)"));
m_visible->setToolTip({});
form->addRow(QStringLiteral("可见性"), m_visible);
m_spritePreview = new QLabel(this);
// 贴图预览必须稳定占位:若用 setPixmap(pm.scaled(label->size()))QLabel 的 sizeHint 会被 pixmap 反向撑大,
// 再触发布局扩张,形成“拖动刷新属性 → 预览越来越大”的正反馈。
// 因此固定预览区域尺寸,pixmap 仅按该尺寸缩放。
constexpr int kSpritePreviewW = 200;
constexpr int kSpritePreviewH = 120;
m_spritePreview->setFixedSize(kSpritePreviewW, kSpritePreviewH);
m_spritePreview->setFrameShape(QFrame::StyledPanel);
m_spritePreview->setAlignment(Qt::AlignCenter);
m_spritePreview->setText(QStringLiteral("无图像"));
form->addRow(QStringLiteral("贴图"), m_spritePreview);
m_btnEditSprite = new PropertyPanelPushButton(QStringLiteral("编辑"), this);
m_btnEditSprite->setToolTip(QStringLiteral("编辑当前帧贴图/逐帧动画"));
form->addRow(QString(), m_btnEditSprite);
lay->addLayout(form);
auto* sep = new QFrame(this);
sep->setObjectName(QStringLiteral("PropertySectionSeparator"));
sep->setFrameShape(QFrame::HLine);
lay->addWidget(sep);
m_introHeader = new QWidget(this);
polishPropertyStretchyTextField(m_introHeader);
auto* headLay = new QHBoxLayout(m_introHeader);
headLay->setContentsMargins(0, 2, 0, 2);
headLay->setSpacing(6);
headLay->setContentsMargins(0, 6, 0, 2);
headLay->setSpacing(4);
m_introToggle = new QToolButton(m_introHeader);
m_introToggle->setAutoRaise(true);
m_introToggle->setToolButtonStyle(Qt::ToolButtonTextOnly);
m_introToggle->setCursor(Qt::PointingHandCursor);
m_introToggle->setToolTip(QStringLiteral("展开折叠介绍设置"));
m_introToggle->setToolTip(QStringLiteral("展开/折叠介绍"));
m_introToggle->setText(QStringLiteral(""));
m_introToggle->setFixedWidth(22);
m_introToggle->setFixedHeight(22);
auto* introTitleLab = new QLabel(QStringLiteral("介绍"), m_introHeader);
introTitleLab->setStyleSheet(QStringLiteral("QLabel { font-weight: 600; }"));
introTitleLab->setObjectName(QStringLiteral("PropertyPanelHeading"));
headLay->addWidget(m_introToggle, 0, Qt::AlignVCenter);
headLay->addWidget(introTitleLab, 1, Qt::AlignVCenter);
m_introContent = new QWidget(this);
polishPropertyStretchyTextField(m_introContent);
auto* introLay = new QVBoxLayout(m_introContent);
introLay->setContentsMargins(8, 4, 0, 0);
introLay->setSpacing(6);
polishPropertyVBoxLayout(introLay);
introLay->setContentsMargins(0, 4, 0, 0);
m_introTitle = new QLineEdit(m_introContent);
m_introTitle = new PropertyPanelLineEdit(m_introContent);
m_introTitle->setPlaceholderText(QStringLiteral("标题"));
introLay->addWidget(new QLabel(QStringLiteral("标题"), m_introContent));
introLay->addWidget(m_introTitle);
m_introBody = new QTextEdit(m_introContent);
m_introBody->setPlaceholderText(QStringLiteral("正文(纯文本)"));
m_introBody->setMaximumHeight(100);
m_introBody = new PropertyPanelTextEdit(m_introContent);
m_introBody->setPlaceholderText(QStringLiteral("正文"));
m_introBody->setMaximumHeight(80);
introLay->addWidget(new QLabel(QStringLiteral("正文"), m_introContent));
introLay->addWidget(m_introBody);
m_introImages = new QListWidget(m_introContent);
m_introImages->setMinimumHeight(72);
m_introImages->setToolTip(QStringLiteral("配图相对路径列表;使用下方按钮从文件添加"));
m_introImages->setObjectName(QStringLiteral("PropertyPanelListWidget"));
m_introImages->setMinimumHeight(56);
m_introImages->setToolTip({});
m_introImages->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_introImages->setWordWrap(true);
introLay->addWidget(new QLabel(QStringLiteral("配图"), m_introContent));
introLay->addWidget(m_introImages);
m_btnIntroAddImage = new PropertyPanelPushButton(QStringLiteral("添加"), m_introContent);
m_btnIntroRemoveImage = new PropertyPanelPushButton(QStringLiteral("删除"), m_introContent);
m_btnIntroAddImage->setFixedWidth(52);
m_btnIntroRemoveImage->setFixedWidth(52);
m_btnIntroAddImage->setToolTip(QStringLiteral("添加配图"));
m_btnIntroRemoveImage->setToolTip(QStringLiteral("删除当前选中的配图"));
auto* imgRow = new QHBoxLayout();
m_btnIntroAddImage = new QPushButton(QStringLiteral("添加配图…"), m_introContent);
m_btnIntroRemoveImage = new QPushButton(QStringLiteral("移除选中"), m_introContent);
imgRow->addWidget(m_btnIntroAddImage);
imgRow->addWidget(m_btnIntroRemoveImage);
imgRow->setContentsMargins(0, 0, 0, 0);
imgRow->setSpacing(8);
imgRow->addWidget(m_btnIntroAddImage, 0);
imgRow->addWidget(m_btnIntroRemoveImage, 0);
imgRow->addStretch(1);
introLay->addLayout(imgRow);
m_introVideo = new QLineEdit(m_introContent);
m_introVideo = new PropertyPanelLineEdit(m_introContent);
m_introVideo->setPlaceholderText(QStringLiteral("可选:视频相对路径(如 assets/entities/xxx.mp4"));
introLay->addWidget(new QLabel(QStringLiteral("视频路径(预留)"), m_introContent));
introLay->addWidget(m_introVideo);
@@ -141,11 +187,14 @@ EntityPropertySection::EntityPropertySection(QWidget* parent)
emit displayNameCommitted(m_name->text());
}
});
connect(m_pivot, &Vec2ParamControl::valueChanged, this, &EntityPropertySection::pivotEdited);
connect(m_centroid, &Vec2ParamControl::valueChanged, this, &EntityPropertySection::centroidEdited);
connect(m_centerPosition, &Vec2DoubleParamControl::valueChanged, this, &EntityPropertySection::centerPositionEdited);
connect(m_relativeToOwnCenter, &Vec2DoubleParamControl::valueChanged, this,
&EntityPropertySection::relativeToOwnCenterEdited);
connect(m_priority, qOverload<int>(&QSpinBox::valueChanged), this, &EntityPropertySection::priorityEdited);
connect(m_userScale, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &EntityPropertySection::userScaleEdited);
connect(m_ignoreDistanceScale, &QCheckBox::toggled, this, &EntityPropertySection::ignoreDistanceScaleToggled);
connect(m_visible, &QCheckBox::toggled, this, &EntityPropertySection::visibleToggled);
connect(m_btnEditSprite, &QPushButton::clicked, this, &EntityPropertySection::spriteEditRequested);
connect(m_introTitle, &QLineEdit::textChanged, this, [this](const QString&) { scheduleIntroPersist(); });
connect(m_introBody, &QTextEdit::textChanged, this, [this]() { scheduleIntroPersist(); });
@@ -189,16 +238,15 @@ void EntityPropertySection::clearDisconnected() {
}
if (m_depth) m_depth->setText(QStringLiteral("-"));
if (m_distScale) m_distScale->setText(QStringLiteral("-"));
if (m_pivot) m_pivot->setValue(0.0, 0.0);
if (m_centroid) m_centroid->setValue(0.0, 0.0);
if (m_pivotLabel) m_pivotLabel->setText(QStringLiteral("中心坐标"));
if (m_centroidLabel) m_centroidLabel->setText(QStringLiteral("位置"));
if (m_pivot) {
m_pivot->setToolTip(QStringLiteral("枢轴在世界坐标中的位置(限制在轮廓包络内),用于重定位局部原点"));
}
if (m_centroid) {
m_centroid->setToolTip(QStringLiteral("实体几何质心的世界坐标;修改将整体平移实体"));
if (m_centerPosition) m_centerPosition->setValue(0, 0);
if (m_relativeToOwnCenter) m_relativeToOwnCenter->setValue(0, 0);
if (m_priority) {
m_priority->blockSignals(true);
m_priority->setValue(1);
m_priority->blockSignals(false);
}
if (m_centerLabel) m_centerLabel->setText(QStringLiteral("中心"));
if (m_relativeLabel) m_relativeLabel->setText(QStringLiteral("相对位置"));
if (m_userScale) {
m_userScale->blockSignals(true);
m_userScale->setValue(1.0);
@@ -230,6 +278,10 @@ void EntityPropertySection::clearDisconnected() {
m_introVideo->blockSignals(false);
}
if (m_introImages) m_introImages->clear();
if (m_spritePreview) {
m_spritePreview->setPixmap(QPixmap());
m_spritePreview->setText(QStringLiteral("无图像"));
}
setIntroSectionExpanded(true);
m_introBulkUpdate = false;
}
@@ -248,26 +300,23 @@ void EntityPropertySection::applyState(const EntityPropertyUiState& s) {
}
if (m_depth) m_depth->setText(QString::number(s.depthZ));
if (m_distScale) m_distScale->setText(s.distanceScaleText);
if (m_pivotLabel) {
m_pivotLabel->setText(QStringLiteral("中心坐标"));
if (m_centerLabel) {
m_centerLabel->setText(s.hasParent ? QStringLiteral("相对中心") : QStringLiteral("世界中心"));
}
if (m_centroidLabel) {
m_centroidLabel->setText(QStringLiteral("位置"));
if (m_relativeLabel) {
m_relativeLabel->setText(QStringLiteral("相对位置"));
}
if (m_pivot) {
m_pivot->setToolTip(
s.parentRelativeMode
? QStringLiteral("枢轴相对父对象的坐标;修改将写入相对父对象的位置关键帧")
: QStringLiteral("枢轴在世界坐标中的位置(限制在轮廓包络内),用于重定位局部原点"));
if (m_centerPosition && !m_centerPosition->isActivelyEditing()) {
m_centerPosition->setValue(s.centerPosition.x(), s.centerPosition.y());
}
if (m_centroid) {
m_centroid->setToolTip(
s.parentRelativeMode
? QStringLiteral("几何质心相对父对象的坐标;修改将写入相对父对象的位置关键帧")
: QStringLiteral("实体几何质心的世界坐标;修改将整体平移实体"));
if (m_relativeToOwnCenter && !m_relativeToOwnCenter->isActivelyEditing()) {
m_relativeToOwnCenter->setValue(s.relativeToOwnCenter.x(), s.relativeToOwnCenter.y());
}
if (m_priority) {
m_priority->blockSignals(true);
m_priority->setValue(s.priority);
m_priority->blockSignals(false);
}
if (m_pivot) m_pivot->setValue(s.pivot.x(), s.pivot.y());
if (m_centroid) m_centroid->setValue(s.centroid.x(), s.centroid.y());
if (m_userScale) {
m_userScale->blockSignals(true);
m_userScale->setValue(s.userScale);
@@ -283,6 +332,24 @@ void EntityPropertySection::applyState(const EntityPropertyUiState& s) {
m_visible->setChecked(s.visible);
m_visible->blockSignals(false);
}
if (m_spritePreview && !s.spritePreview.isNull()) {
const QSize target = m_spritePreview->contentsRect().size().isValid()
? m_spritePreview->contentsRect().size()
: m_spritePreview->size();
const quint64 key = static_cast<quint64>(s.spritePreview.cacheKey());
if (m_spritePreviewCacheKey != key || m_spritePreviewLastTargetSize != target) {
const QPixmap pm = QPixmap::fromImage(s.spritePreview);
m_spritePreview->setPixmap(
pm.scaled(target, Qt::KeepAspectRatio, Qt::SmoothTransformation));
m_spritePreviewCacheKey = key;
m_spritePreviewLastTargetSize = target;
}
} else if (m_spritePreview) {
m_spritePreview->setPixmap(QPixmap());
m_spritePreview->setText(QStringLiteral("无图像"));
m_spritePreviewCacheKey = 0;
m_spritePreviewLastTargetSize = {};
}
if (m_introTitle) {
m_introTitle->blockSignals(true);
m_introTitle->setText(s.intro.title);
@@ -343,11 +410,13 @@ core::EntityIntroContent EntityPropertySection::introSnapshot() const {
void EntityPropertySection::setEditingEnabled(bool on) {
if (m_name) m_name->setEnabled(on);
if (m_pivot) m_pivot->setEnabled(on);
if (m_centroid) m_centroid->setEnabled(on);
if (m_centerPosition) m_centerPosition->setEnabled(on);
if (m_relativeToOwnCenter) m_relativeToOwnCenter->setEnabled(on);
if (m_priority) m_priority->setEnabled(on);
if (m_userScale) m_userScale->setEnabled(on);
if (m_ignoreDistanceScale) m_ignoreDistanceScale->setEnabled(on);
if (m_visible) m_visible->setEnabled(on);
if (m_btnEditSprite) m_btnEditSprite->setEnabled(on);
if (m_introHeader) m_introHeader->setEnabled(on);
if (m_introToggle) m_introToggle->setEnabled(on);
if (m_introTitle) m_introTitle->setEnabled(on);
+26 -10
View File
@@ -4,11 +4,14 @@
#include "props/PropertySectionWidget.h"
#include <QPointF>
#include <QImage>
#include <QString>
#include <QtGlobal>
class QLabel;
class QLineEdit;
class QDoubleSpinBox;
class QSpinBox;
class QCheckBox;
class QTextEdit;
class QListWidget;
@@ -18,7 +21,7 @@ class QTimer;
class QWidget;
namespace gui {
class Vec2ParamControl;
class Vec2DoubleParamControl;
}
namespace gui {
@@ -27,12 +30,16 @@ struct EntityPropertyUiState {
QString displayName;
int depthZ = 0;
QString distanceScaleText;
QPointF pivot;
QPointF centroid;
/// 中心:无父级时为形心世界坐标(与画布十字一致,用于距离/位置缩放);有父级时为形心相对父级形心的偏移。
QPointF centerPosition;
/// 相对位置:变换原点相对自身形心(世界坐标差)。
QPointF relativeToOwnCenter;
bool hasParent = false;
int priority = 1;
double userScale = 1.0;
bool ignoreDistanceScale = false;
bool visible = true;
bool parentRelativeMode = false;
QImage spritePreview;
core::EntityIntroContent intro;
};
@@ -50,8 +57,11 @@ public:
signals:
void displayNameCommitted(const QString& text);
void pivotEdited(double x, double y);
void centroidEdited(double x, double y);
/// 编辑中心:无父为形心世界坐标;有父为形心相对父形心的偏移(整体平移实体)
void centerPositionEdited(double x, double y);
/// 编辑相对自身形心的原点偏移(改枢轴、外形世界位置不变)
void relativeToOwnCenterEdited(double x, double y);
void priorityEdited(int value);
void userScaleEdited(double value);
void ignoreDistanceScaleToggled(bool on);
// 可见性(动画通道):在当前帧写关键帧
@@ -59,6 +69,7 @@ signals:
/// 介绍字段变更后防抖触发,由主窗口写入工程
void introContentEdited();
void introAddImageRequested();
void spriteEditRequested();
private:
void scheduleIntroPersist();
@@ -67,13 +78,18 @@ private:
QLineEdit* m_name = nullptr;
QLabel* m_depth = nullptr;
QLabel* m_distScale = nullptr;
QLabel* m_pivotLabel = nullptr;
QLabel* m_centroidLabel = nullptr;
Vec2ParamControl* m_pivot = nullptr;
Vec2ParamControl* m_centroid = 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;
+151
View File
@@ -0,0 +1,151 @@
#include "props/HotspotPropertySection.h"
#include <QComboBox>
#include <QFormLayout>
#include <QHash>
#include <QLabel>
#include <QListWidget>
#include <QMenu>
#include <QPushButton>
#include <QVBoxLayout>
namespace gui {
HotspotPropertySection::HotspotPropertySection(QWidget* parent) : PropertySectionWidget(parent) {
auto* root = new QVBoxLayout(this);
root->setContentsMargins(0, 0, 0, 0);
auto* title = new QLabel(QStringLiteral("已添加热点"), this);
root->addWidget(title);
m_hotspotList = new QListWidget(this);
m_hotspotList->setObjectName(QStringLiteral("PropertyPanelListWidget"));
m_hotspotList->setMinimumHeight(120);
m_hotspotList->setContextMenuPolicy(Qt::CustomContextMenu);
root->addWidget(m_hotspotList);
auto* form = new QFormLayout();
form->setSpacing(6);
root->addLayout(form);
m_targetAnim = new QComboBox(this);
m_targetAnim->setMinimumWidth(120);
form->addRow(QStringLiteral("目标"), m_targetAnim);
m_btnDelete = new QPushButton(QStringLiteral("删除"), this);
root->addWidget(m_btnDelete);
connect(m_targetAnim, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int) {
if (m_hotspotId.isEmpty() || !m_targetAnim) {
return;
}
const QString aid = m_targetAnim->currentData().toString();
emit targetAnimationChanged(m_hotspotId, aid);
});
connect(m_hotspotList, &QListWidget::currentItemChanged, this, [this](QListWidgetItem* current, QListWidgetItem*) {
const QString hotspotId = current ? current->data(Qt::UserRole).toString() : QString();
if (hotspotId == m_hotspotId) {
return;
}
m_hotspotId = hotspotId;
emit hotspotSelected(hotspotId);
});
connect(m_hotspotList, &QListWidget::customContextMenuRequested, this, [this](const QPoint& pos) {
if (!m_hotspotList) {
return;
}
auto* item = m_hotspotList->itemAt(pos);
if (!item) {
return;
}
const QString hotspotId = item->data(Qt::UserRole).toString();
if (hotspotId.isEmpty()) {
return;
}
m_hotspotList->setCurrentItem(item);
QMenu menu(this);
auto* actDelete = menu.addAction(QStringLiteral("移除热点"));
if (menu.exec(m_hotspotList->viewport()->mapToGlobal(pos)) == actDelete) {
emit deleteRequested(hotspotId);
}
});
connect(m_btnDelete, &QPushButton::clicked, this, [this]() {
if (!m_hotspotId.isEmpty()) {
emit deleteRequested(m_hotspotId);
}
});
}
void HotspotPropertySection::clearDisconnected() {
m_hotspotId.clear();
}
void HotspotPropertySection::applyState(const QVector<core::Project::PresentationHotspot>& hotspots,
const QString& selectedHotspotId,
const QVector<QPair<QString, QString>>& animIdToLabelNonNone) {
m_hotspotId = selectedHotspotId;
if (!m_targetAnim || !m_hotspotList) {
return;
}
QString targetAnimationId;
QHash<QString, QString> animLabelById;
for (const auto& p : animIdToLabelNonNone) {
animLabelById.insert(p.first, p.second);
}
m_hotspotList->blockSignals(true);
m_hotspotList->clear();
QListWidgetItem* selectedItem = nullptr;
for (const auto& hotspot : hotspots) {
QString text = hotspot.id;
const QString animLabel = animLabelById.value(hotspot.targetAnimationId);
if (!animLabel.isEmpty()) {
text += QStringLiteral(" -> ") + animLabel;
} else if (!hotspot.targetAnimationId.isEmpty()) {
text += QStringLiteral(" -> ") + hotspot.targetAnimationId;
} else {
text += QStringLiteral(" -> 未设");
}
auto* item = new QListWidgetItem(text, m_hotspotList);
item->setData(Qt::UserRole, hotspot.id);
if (hotspot.id == selectedHotspotId) {
selectedItem = item;
targetAnimationId = hotspot.targetAnimationId;
}
}
if (selectedItem) {
m_hotspotList->setCurrentItem(selectedItem);
} else {
m_hotspotList->setCurrentRow(-1);
m_hotspotId.clear();
}
m_hotspotList->blockSignals(false);
m_targetAnim->blockSignals(true);
m_targetAnim->clear();
m_targetAnim->addItem(QStringLiteral("未设"), QString());
for (const auto& p : animIdToLabelNonNone) {
m_targetAnim->addItem(p.second, p.first);
}
int idx = -1;
for (int i = 0; i < m_targetAnim->count(); ++i) {
if (m_targetAnim->itemData(i).toString() == targetAnimationId) {
idx = i;
break;
}
}
if (idx >= 0) {
m_targetAnim->setCurrentIndex(idx);
} else {
m_targetAnim->setCurrentIndex(0);
}
m_targetAnim->blockSignals(false);
const bool ok = !m_hotspotId.isEmpty() && m_targetAnim->count() > 0;
m_targetAnim->setEnabled(ok);
if (m_btnDelete) {
m_btnDelete->setEnabled(!m_hotspotId.isEmpty());
}
}
} // namespace gui
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include "core/domain/Project.h"
#include "props/PropertySectionWidget.h"
#include <QString>
class QComboBox;
class QListWidget;
class QPushButton;
namespace gui {
class HotspotPropertySection final : public PropertySectionWidget {
Q_OBJECT
public:
explicit HotspotPropertySection(QWidget* parent = nullptr);
void clearDisconnected();
void applyState(const QVector<core::Project::PresentationHotspot>& hotspots,
const QString& selectedHotspotId,
const QVector<QPair<QString, QString>>& animIdToLabelNonNone);
signals:
void hotspotSelected(const QString& hotspotId);
void targetAnimationChanged(const QString& hotspotId, const QString& animationId);
void deleteRequested(const QString& hotspotId);
private:
QString m_hotspotId;
QListWidget* m_hotspotList = nullptr;
QComboBox* m_targetAnim = nullptr;
QPushButton* m_btnDelete = nullptr;
};
} // namespace gui
+38 -19
View File
@@ -11,6 +11,9 @@
#include <QLineEdit>
#include <QSlider>
#include <QSpinBox>
#include "widgets/CompactNumericSpinBox.h"
#include "widgets/PropertyPanelControls.h"
#include <QVBoxLayout>
namespace gui {
@@ -18,43 +21,50 @@ namespace gui {
ToolPropertySection::ToolPropertySection(QWidget* parent)
: PropertySectionWidget(parent) {
auto* lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(6);
polishPropertyVBoxLayout(lay);
auto* form = new QFormLayout();
form->setContentsMargins(0, 0, 0, 0);
form->setSpacing(6);
polishPropertyFormLayout(form);
m_text = new QLineEdit(this);
m_text = new PropertyPanelLineEdit(this);
m_text->setPlaceholderText(QStringLiteral("对话内容…"));
polishPropertyStretchyTextField(m_text);
form->addRow(QStringLiteral("文字"), m_text);
m_positionLabel = new QLabel(QStringLiteral("位置"), this);
m_position = new Vec2ParamControl(this);
m_position->setToolTip(QStringLiteral("工具在世界坐标中的位置"));
m_position->setToolTip({});
form->addRow(m_positionLabel, m_position);
m_priority = new CompactIntSpinBox(this, 72);
m_priority->setRange(-1000000, 1000000);
m_priority->setSingleStep(1);
m_priority->setAccelerated(true);
m_priority->setToolTip(QStringLiteral("优先级越高越靠上。背景为 0;工具默认 10。"));
form->addRow(QStringLiteral("优先级"), m_priority);
m_pointerT = new QSlider(Qt::Horizontal, this);
m_pointerT->setRange(0, 1000);
m_pointerT->setSingleStep(10);
m_pointerT->setPageStep(50);
m_pointerT->setValue(500);
m_pointerT->setToolTip(QStringLiteral("发言实体位置"));
m_pointerT->setToolTip({});
form->addRow(QStringLiteral("指向"), m_pointerT);
m_fontPx = new QSpinBox(this);
m_fontPx = new CompactIntSpinBox(this);
m_fontPx->setRange(8, 120);
m_fontPx->setSingleStep(1);
m_fontPx->setValue(18);
form->addRow(QStringLiteral("字号"), m_fontPx);
m_align = new QComboBox(this);
m_align = new PropertyPanelComboBox(this);
m_align->addItems({QStringLiteral("左对齐"), QStringLiteral("居中"), QStringLiteral("右对齐")});
polishPropertyStretchyTextField(m_align);
form->addRow(QStringLiteral("对齐"), m_align);
m_visible = new QCheckBox(QString(), this);
m_visible = new PropertyPanelCheckBox(QString(), this);
m_visible->setChecked(true);
m_visible->setToolTip(QStringLiteral("随帧变化:在当前帧切换会写入可见性关键帧"));
m_visible->setToolTip({});
form->addRow(QStringLiteral("可见性"), m_visible);
lay->addLayout(form);
@@ -67,11 +77,13 @@ ToolPropertySection::ToolPropertySection(QWidget* parent)
connect(m_fontPx, qOverload<int>(&QSpinBox::valueChanged), this, &ToolPropertySection::fontPxChanged);
connect(m_align, qOverload<int>(&QComboBox::currentIndexChanged), this, &ToolPropertySection::alignChanged);
connect(m_position, &Vec2ParamControl::valueChanged, this, &ToolPropertySection::positionEdited);
connect(m_priority, qOverload<int>(&QSpinBox::valueChanged), this, &ToolPropertySection::priorityEdited);
connect(m_visible, &QCheckBox::toggled, this, &ToolPropertySection::visibleToggled);
}
void ToolPropertySection::setEditingEnabled(bool on) {
for (auto* w : {static_cast<QWidget*>(m_text), static_cast<QWidget*>(m_position),
static_cast<QWidget*>(m_priority),
static_cast<QWidget*>(m_pointerT),
static_cast<QWidget*>(m_fontPx), static_cast<QWidget*>(m_align),
static_cast<QWidget*>(m_visible)}) {
@@ -89,10 +101,15 @@ void ToolPropertySection::clearDisconnected() {
if (m_positionLabel) m_positionLabel->setText(QStringLiteral("位置"));
if (m_position) {
m_position->blockSignals(true);
m_position->setToolTip(QStringLiteral("工具在世界坐标中的位置"));
m_position->setValue(0.0, 0.0);
m_position->setToolTip({});
m_position->setValue(0, 0);
m_position->blockSignals(false);
}
if (m_priority) {
m_priority->blockSignals(true);
m_priority->setValue(10);
m_priority->blockSignals(false);
}
if (m_pointerT) {
m_pointerT->blockSignals(true);
m_pointerT->setValue(500);
@@ -125,15 +142,17 @@ void ToolPropertySection::applyState(const ToolPropertyUiState& s) {
if (m_positionLabel) {
m_positionLabel->setText(QStringLiteral("位置"));
}
if (m_position) {
if (m_position && !m_position->isActivelyEditing()) {
m_position->blockSignals(true);
m_position->setToolTip(
s.parentRelativeMode
? QStringLiteral("工具相对父对象的位置;修改将写入相对父对象的位置关键帧")
: QStringLiteral("工具在世界坐标中的位置"));
m_position->setValue(s.position.x(), s.position.y());
m_position->setToolTip({});
m_position->setValue(qRound(s.position.x()), qRound(s.position.y()));
m_position->blockSignals(false);
}
if (m_priority) {
m_priority->blockSignals(true);
m_priority->setValue(s.priority);
m_priority->blockSignals(false);
}
if (m_pointerT) {
m_pointerT->blockSignals(true);
m_pointerT->setValue(std::clamp(s.pointerTThousandths, 0, 1000));
+4 -1
View File
@@ -23,6 +23,7 @@ struct ToolPropertyUiState {
QString text;
QPointF position;
bool parentRelativeMode = false;
int priority = 10;
int pointerTThousandths = 500; // bubblePointerT01 * 10000=左 1000=右
int fontPx = 18;
int alignIndex = 1; // 0=left,1=center,2=right
@@ -43,13 +44,15 @@ signals:
void pointerTChanged(int thousandths);
void fontPxChanged(int px);
void alignChanged(int alignIndex);
void positionEdited(double x, double y);
void positionEdited(int x, int y);
void priorityEdited(int value);
// 可见性(动画通道):在当前帧写关键帧
void visibleToggled(bool on);
private:
QLabel* m_positionLabel = nullptr;
Vec2ParamControl* m_position = nullptr;
QSpinBox* m_priority = nullptr;
QLineEdit* m_text = nullptr;
QSlider* m_pointerT = nullptr;
QSpinBox* m_fontPx = nullptr;