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
+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));