Compare commits
No commits in common. "c77114b7f33c3545b25b1c7d2a4aee8fb912c3ac" and "3a693de9fe58e5f97a69e7a67cee4d1fc4d9bd29" have entirely different histories.
c77114b7f3
...
3a693de9fe
|
@ -196,6 +196,11 @@
|
||||||
<string>关联图元</string>
|
<string>关联图元</string>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>可见</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -36,6 +36,7 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
connect(editorSettingWidget, &EditorSettingWidget::backgroundColorChanged, this, &EditorWidgetItem::handleBackgroundColorChange);
|
connect(editorSettingWidget, &EditorSettingWidget::backgroundColorChanged, this, &EditorWidgetItem::handleBackgroundColorChange);
|
||||||
connect(editorSettingWidget, &EditorSettingWidget::projectNameChanged, this, &EditorWidgetItem::handleProjectNameChange);
|
connect(editorSettingWidget, &EditorSettingWidget::projectNameChanged, this, &EditorWidgetItem::handleProjectNameChange);
|
||||||
connect(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
|
connect(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
|
||||||
|
connect(previewWindow, &PreviewWindow::layerInfoChanged, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
||||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
||||||
//connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
//connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||||
|
|
|
@ -46,8 +46,6 @@ LayerWrapper::LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementM
|
||||||
property.scale = {transformJson.value("scale").toObject().value("x").toDouble(),
|
property.scale = {transformJson.value("scale").toObject().value("x").toDouble(),
|
||||||
transformJson.value("scale").toObject().value("y").toDouble()};
|
transformJson.value("scale").toObject().value("y").toDouble()};
|
||||||
property.rotation = {transformJson.value("rotation").toDouble()};
|
property.rotation = {transformJson.value("rotation").toDouble()};
|
||||||
property.flipX = { transformJson.value("flipX").toBool() };
|
|
||||||
property.flipY = { transformJson.value("flipY").toBool() };
|
|
||||||
selected = false;
|
selected = false;
|
||||||
hidden = false;
|
hidden = false;
|
||||||
}
|
}
|
||||||
|
@ -102,10 +100,6 @@ void LayerWrapper::SimpleProperty::apply(PixelPath&cache)
|
||||||
transform.translate(centerX, centerY);
|
transform.translate(centerX, centerY);
|
||||||
transform.translate(offset.x(), offset.y());
|
transform.translate(offset.x(), offset.y());
|
||||||
transform.rotate(rotation);
|
transform.rotate(rotation);
|
||||||
if (flipX)
|
|
||||||
transform.scale(-1, 1);
|
|
||||||
if (flipY)
|
|
||||||
transform.scale(1, -1);
|
|
||||||
transform.scale(scale.x(), scale.y());
|
transform.scale(scale.x(), scale.y());
|
||||||
transform.translate(-centerX, -centerY);
|
transform.translate(-centerX, -centerY);
|
||||||
cache = cache.trans(transform);
|
cache = cache.trans(transform);
|
||||||
|
@ -251,8 +245,6 @@ QJsonObject LayerWrapper::toJson() const
|
||||||
QJsonObject transformJson;
|
QJsonObject transformJson;
|
||||||
transformJson.insert("offset", QJsonObject({ {"x", property.offset.x()}, {"y", property.offset.y()} }));
|
transformJson.insert("offset", QJsonObject({ {"x", property.offset.x()}, {"y", property.offset.y()} }));
|
||||||
transformJson.insert("scale", QJsonObject({ {"x", property.scale.x()}, {"y", property.scale.y()} }));
|
transformJson.insert("scale", QJsonObject({ {"x", property.scale.x()}, {"y", property.scale.y()} }));
|
||||||
transformJson.insert("filpX", property.flipX);
|
|
||||||
transformJson.insert("filpY", property.flipY);
|
|
||||||
transformJson.insert("rotation", property.rotation);
|
transformJson.insert("rotation", property.rotation);
|
||||||
json.insert("transform", transformJson);
|
json.insert("transform", transformJson);
|
||||||
return json;
|
return json;
|
||||||
|
|
|
@ -44,8 +44,8 @@ class LayerWrapper
|
||||||
QPointF scale = {1.0, 1.0};
|
QPointF scale = {1.0, 1.0};
|
||||||
QPointF offset = {0, 0};
|
QPointF offset = {0, 0};
|
||||||
double rotation = 0;
|
double rotation = 0;
|
||||||
bool flipX = 0;
|
bool flipHorizontally = 0;
|
||||||
bool flipY = 0;
|
bool flipVertically = 0;
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
// TODO: 将QPainterPath改为BitmapPath
|
// TODO: 将QPainterPath改为BitmapPath
|
||||||
void apply(PixelPath&cache);
|
void apply(PixelPath&cache);
|
||||||
|
|
|
@ -7,77 +7,181 @@
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <qtmaterialraisedbutton.h>
|
#include <qtmaterialraisedbutton.h>
|
||||||
#include <qtmaterialflatbutton.h>
|
#include <qtmaterialflatbutton.h>
|
||||||
#include <QLabel>
|
|
||||||
#include <QCheckBox>
|
|
||||||
|
|
||||||
void InfoDisplayWidget::setLayer(LayerWrapper *layer)
|
void InfoDisplayWidget::setLayer(LayerWrapper *layer)
|
||||||
{
|
{
|
||||||
this->displayLayer = layer;
|
this->displayLayer = layer;
|
||||||
this->refresh();
|
generateLayerForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
InfoDisplayWidget::InfoDisplayWidget(QWidget* parent) :QWidget(parent)
|
void InfoDisplayWidget::generateLayerForm()
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
QLayoutItem *item;
|
||||||
this->displayLayer = nullptr;
|
if (this->layout() != nullptr)
|
||||||
ui.name->setDisabled(true);
|
{
|
||||||
ui.offsetX->setLabel(("水平偏移"));
|
while (this->layout()->count() > 0 && (item = this->layout()->takeAt(0)) != nullptr)
|
||||||
ui.offsetY->setLabel(("垂直偏移"));
|
{
|
||||||
ui.rotation->setLabel(("旋转角度"));
|
item->widget()->deleteLater();
|
||||||
ui.scaleX->setLabel(("水平缩放"));
|
delete item;
|
||||||
ui.scaleY->setLabel(("垂直缩放"));
|
}
|
||||||
ui.rotation->setValidator(new QIntValidator(-10000, 10000, this));
|
delete this->layout();
|
||||||
connect(ui.rotation, &QLineEdit::textChanged, [=](QString content) {
|
}
|
||||||
|
QFormLayout *layout = new QFormLayout();
|
||||||
|
layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
||||||
|
if (this->displayLayer == nullptr)
|
||||||
|
{
|
||||||
|
layout->addRow("no selected layer", new QLabel());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QLineEdit *name = new QLineEdit(this->displayLayer->property.name, this);
|
||||||
|
QLineEdit *rotation = new QLineEdit(QString::number(this->displayLayer->property.rotation, 'f', 0), this);
|
||||||
|
QLineEdit *offsetX = new QLineEdit(QString::number(this->displayLayer->property.offset.x()), this);
|
||||||
|
QLineEdit *offsetY = new QLineEdit(QString::number(this->displayLayer->property.offset.y()), this);
|
||||||
|
QLineEdit *scaleX = new QLineEdit(QString::number(this->displayLayer->property.scale.x()), this);
|
||||||
|
QLineEdit *scaleY = new QLineEdit(QString::number(this->displayLayer->property.scale.y()), this);
|
||||||
|
name->setDisabled(true);
|
||||||
|
rotation->setValidator(new QIntValidator(-10000, 10000, this));
|
||||||
|
connect(rotation, &QLineEdit::textChanged, [=](QString content) {
|
||||||
this->displayLayer->property.rotation = content.toDouble();
|
this->displayLayer->property.rotation = content.toDouble();
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
ui.offsetX->setValidator(new QIntValidator(-10000, 10000, this));
|
offsetX->setValidator(new QIntValidator(-10000, 10000, this));
|
||||||
connect(ui.offsetX, &QLineEdit::textChanged, [=](QString content) {
|
connect(offsetX, &QLineEdit::textChanged, [=](QString content) {
|
||||||
this->displayLayer->property.offset = {content.toDouble(), this->displayLayer->property.offset.y()};
|
this->displayLayer->property.offset = {content.toDouble(), this->displayLayer->property.offset.y()};
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
ui.offsetY->setValidator(new QIntValidator(-10000, 10000, this));
|
offsetY->setValidator(new QIntValidator(-10000, 10000, this));
|
||||||
connect(ui.offsetY, &QLineEdit::textChanged, [=](QString content) {
|
connect(offsetY, &QLineEdit::textChanged, [=](QString content) {
|
||||||
this->displayLayer->property.offset = {this->displayLayer->property.offset.x(), content.toDouble()};
|
this->displayLayer->property.offset = {this->displayLayer->property.offset.x(), content.toDouble()};
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
ui.scaleX->setValidator(new QDoubleValidator(0, 1000, 4, this));
|
scaleX->setValidator(new QDoubleValidator(-1000, 1000, 4, this));
|
||||||
connect(ui.scaleX, &QLineEdit::textChanged, [=](QString content) {
|
connect(scaleX, &QLineEdit::textChanged, [=](QString content) {
|
||||||
this->displayLayer->property.scale = {content.toDouble(), this->displayLayer->property.scale.y()};
|
this->displayLayer->property.scale = {content.toDouble(), this->displayLayer->property.scale.y()};
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
ui.scaleY->setValidator(new QDoubleValidator(0, 1000, 4, this));
|
scaleY->setValidator(new QDoubleValidator(-1000, 1000, 4, this));
|
||||||
connect(ui.scaleY, &QLineEdit::textChanged, [=](QString content) {
|
connect(scaleY, &QLineEdit::textChanged, [=](QString content) {
|
||||||
this->displayLayer->property.scale = {this->displayLayer->property.scale.x(), content.toDouble()};
|
this->displayLayer->property.scale = {this->displayLayer->property.scale.x(), content.toDouble()};
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
connect(ui.flipX, &QtMaterialCheckBox::toggled, [=](bool state) {
|
|
||||||
this->displayLayer->property.flipX = state;
|
layout->addRow("layer name:", name);
|
||||||
emit triggerCentralRefresh();
|
layout->addRow("rotation:", rotation);
|
||||||
});
|
layout->addRow("offset-X:", offsetX);
|
||||||
connect(ui.flipY, &QtMaterialCheckBox::toggled, [=](bool state) {
|
layout->addRow("offset-Y:", offsetY);
|
||||||
this->displayLayer->property.flipY = state;
|
layout->addRow("scale-X:", scaleX);
|
||||||
|
layout->addRow("scale-Y:", scaleY);
|
||||||
|
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
|
||||||
|
|
||||||
|
if (auto* leafP = dynamic_cast<LeafLayerWrapper*>(this->displayLayer); leafP) {
|
||||||
|
auto* styleList = new QListWidget(this);
|
||||||
|
|
||||||
|
auto* header = new QListWidgetItem;
|
||||||
|
auto* headerWidget = new QWidget(styleList);
|
||||||
|
auto* headerLayout = new QHBoxLayout;
|
||||||
|
|
||||||
|
auto* headerLabel = new QLabel(headerWidget);
|
||||||
|
headerLabel->setText("样式列表");
|
||||||
|
headerLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||||
|
|
||||||
|
//QtMaterialRaisedButton* addStyleButton = new QtMaterialRaisedButton("+", headerWidget);
|
||||||
|
auto* addStyleButton = new QPushButton("+", headerWidget);
|
||||||
|
addStyleButton->setFixedSize(QSize(20, 20));
|
||||||
|
if (leafP->styles.full())
|
||||||
|
{
|
||||||
|
addStyleButton->setDisabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connect(addStyleButton, &QPushButton::clicked, [&, leafP] {
|
||||||
|
auto* dialog = new LayerStyleDialog(leafP->styles, nullptr, this);
|
||||||
|
dialog->exec();
|
||||||
|
if (dialog->layerStyle)
|
||||||
|
{
|
||||||
|
leafP->styles.useStyle(dialog->layerStyle);
|
||||||
|
leafP->styles.computeNewHash();
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoDisplayWidget::setVisiable(bool visiable)
|
headerLayout->addWidget(headerLabel);
|
||||||
|
headerLayout->addWidget(addStyleButton);
|
||||||
|
headerLayout->setContentsMargins(5, 0, 5, 0);
|
||||||
|
headerWidget->setLayout(headerLayout);
|
||||||
|
|
||||||
|
header->setFlags(Qt::NoItemFlags);
|
||||||
|
styleList->addItem(header);
|
||||||
|
styleList->setItemWidget(header, headerWidget);
|
||||||
|
|
||||||
|
auto* styles = &leafP->styles;
|
||||||
|
for (auto styleIterator = styles->begin(); styleIterator != styles->end(); ++styleIterator)
|
||||||
{
|
{
|
||||||
this->setHidden(!visiable);
|
auto* item = new QListWidgetItem;
|
||||||
|
auto* w = new QWidget(this);
|
||||||
|
item->setSizeHint(QSize(50, 40));
|
||||||
|
auto* layout = new QHBoxLayout(w);
|
||||||
|
layout->setAlignment(Qt::AlignmentFlag::AlignRight);
|
||||||
|
//QtMaterialFlatButton* detailButton = new QtMaterialFlatButton(w);
|
||||||
|
//QtMaterialFlatButton* removeButton = new QtMaterialFlatButton(w);
|
||||||
|
auto* detailButton = new QPushButton(w);
|
||||||
|
auto* removeButton = new QPushButton(w);
|
||||||
|
detailButton->setText("...");
|
||||||
|
detailButton->setFixedSize(QSize(20, 20));
|
||||||
|
removeButton->setText("×");
|
||||||
|
removeButton->setFixedSize(QSize(20, 20));
|
||||||
|
|
||||||
|
connect(detailButton, &QPushButton::clicked, this,
|
||||||
|
[this, styles, styleIterator]
|
||||||
|
{
|
||||||
|
auto* dialog =
|
||||||
|
new LayerStyleDialog(*styles, styleIterator->second, this);
|
||||||
|
dialog->exec();
|
||||||
|
|
||||||
|
if (dialog->layerStyle)
|
||||||
|
{
|
||||||
|
styleIterator->second = dialog->layerStyle;
|
||||||
|
styles->computeNewHash();
|
||||||
|
emit triggerCentralRefresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(removeButton, &QPushButton::clicked, this,
|
||||||
|
[this, styleIterator, styles]
|
||||||
|
{
|
||||||
|
styles->dropStyle(styleIterator->first);
|
||||||
|
styles->computeNewHash();
|
||||||
|
emit triggerCentralRefresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
QWidget* styleDisplayWidget = styleIterator->second->getListDisplayWidget();
|
||||||
|
styleDisplayWidget->setParent(w);
|
||||||
|
styleDisplayWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||||
|
|
||||||
|
layout->addWidget(styleDisplayWidget);
|
||||||
|
layout->addWidget(detailButton);
|
||||||
|
layout->addWidget(removeButton);
|
||||||
|
w->setLayout(layout);
|
||||||
|
|
||||||
|
styleList->addItem(item);
|
||||||
|
styleList->setItemWidget(item, w);
|
||||||
|
}
|
||||||
|
layout->addRow(styleList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InfoDisplayWidget::triggerSelfRefresh()
|
||||||
|
{
|
||||||
|
if (this->displayLayer != nullptr)
|
||||||
|
this->generateLayerForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoDisplayWidget::refresh()
|
void InfoDisplayWidget::refresh()
|
||||||
{
|
{
|
||||||
if (this->displayLayer != nullptr)
|
if (this->displayLayer != nullptr)
|
||||||
{
|
this->generateLayerForm();
|
||||||
//this->setVisiable(true);
|
|
||||||
ui.name->setText(this->displayLayer->property.name);
|
|
||||||
ui.offsetX->setText(QString::number(this->displayLayer->property.offset.x()));
|
|
||||||
ui.offsetY->setText(QString::number(this->displayLayer->property.offset.y()));
|
|
||||||
ui.rotation->setText(QString::number(this->displayLayer->property.rotation));
|
|
||||||
ui.scaleX->setText(QString::number(this->displayLayer->property.scale.x()));
|
|
||||||
ui.scaleY->setText(QString::number(this->displayLayer->property.scale.y()));
|
|
||||||
ui.flipX->setChecked(this->displayLayer->property.flipX);
|
|
||||||
ui.flipY->setChecked(this->displayLayer->property.flipY);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -5,23 +5,26 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "ElementPoolWidget.h"
|
#include "ElementPoolWidget.h"
|
||||||
#include "ui_EditorLayerInfoWidget.h"
|
|
||||||
|
|
||||||
class InfoDisplayWidget : public QWidget
|
class InfoDisplayWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
LayerWrapper *displayLayer;
|
LayerWrapper *displayLayer;
|
||||||
Ui::EditorLayerInfoWidget ui;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InfoDisplayWidget(QWidget* parent=nullptr);
|
|
||||||
void setLayer(LayerWrapper *layer);
|
void setLayer(LayerWrapper *layer);
|
||||||
|
void generateLayerForm();
|
||||||
void refresh();
|
void refresh();
|
||||||
void setVisiable(bool visiable);
|
|
||||||
|
public slots:
|
||||||
|
void triggerSelfRefresh();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void triggerCentralRefresh();
|
void triggerCentralRefresh();
|
||||||
|
void requireRefreshPreview();
|
||||||
|
void requireSelfRefresh();
|
||||||
|
void requireRefreshElementWidget();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue