From cee219409ed8671e7daaa3cf5d1ee0c80a8186eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=99=BD=E5=B0=81=E7=BE=BD?= <2360164671@qq.com>
Date: Tue, 17 Jan 2023 20:21:04 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90layer=E4=BF=A1=E6=81=AF?=
=?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=92=8C=E6=95=B0=E6=8D=AE=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=EF=BC=88=E9=83=A8=E5=88=86=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ArchitectureColoredPainting.vcxproj | 2 +
...rchitectureColoredPainting.vcxproj.filters | 6 ++
ArchitectureColoredPainting/EditorWidget.ui | 25 +++++++-
.../src/Editor/EditorWidget.cpp | 13 ++++
.../src/Editor/EditorWidget.h | 12 +++-
.../src/Editor/RightBar/InfoDisplayWidget.cpp | 62 +++++++++++++++++++
.../src/Editor/RightBar/InfoDisplayWidget.h | 19 ++++++
.../src/Editor/RightBar/LayerTreeWidget.cpp | 6 ++
.../src/Editor/RightBar/LayerTreeWidget.h | 3 +
9 files changed, 146 insertions(+), 2 deletions(-)
create mode 100644 ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp
diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
index 6555ec8..5867370 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
@@ -105,6 +105,7 @@
+
@@ -163,6 +164,7 @@
+
diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
index d127dfd..305767a 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
@@ -177,6 +177,9 @@
Source Files
+
+ Source Files
+
@@ -209,6 +212,9 @@
Header Files
+
+ Header Files
+
diff --git a/ArchitectureColoredPainting/EditorWidget.ui b/ArchitectureColoredPainting/EditorWidget.ui
index b4a34e5..38ca891 100644
--- a/ArchitectureColoredPainting/EditorWidget.ui
+++ b/ArchitectureColoredPainting/EditorWidget.ui
@@ -49,7 +49,24 @@
-
-
+
+
-
+
+
+ 0
+
+
+
+ Layer
+
+
+
+
+ Element
+
+
+
+
-
@@ -79,6 +96,12 @@
QTreeWidget
+
+ InfoDisplayWidget
+ QWidget
+
+ 1
+
diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp
index 17bd5f9..fbf2262 100644
--- a/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp
+++ b/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp
@@ -2,9 +2,14 @@
EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
{
+ displayLayer = nullptr;
+ displayElement = nullptr;
ui.setupUi(this);
previewWindow = ui.Preview;
treeWidget = ui.LayerTree;
+ tabWidget = ui.DisplayTab;
+ qDebug() << tabWidget;
+ connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidget::onLayerChange);
qDebug() << "123";
// test
QFile settingFile;
@@ -33,3 +38,11 @@ EditorWidget::~EditorWidget()
void EditorWidget::paintEvent(QPaintEvent *event)
{
}
+
+void EditorWidget::onLayerChange(LayerWrapper *layer)
+{
+ displayLayer = layer;
+ // TODO : notify InfoDisplayWidget and update
+ dynamic_cast(tabWidget->widget(0))->setLayer(layer);
+ this->update();
+}
diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidget.h b/ArchitectureColoredPainting/src/Editor/EditorWidget.h
index 26ac4c0..9b41934 100644
--- a/ArchitectureColoredPainting/src/Editor/EditorWidget.h
+++ b/ArchitectureColoredPainting/src/Editor/EditorWidget.h
@@ -1,6 +1,7 @@
#pragma once
#include "ElementManager.h"
+#include "InfoDisplayWidget.h"
#include "LayerManager.h"
#include "LayerTreeWidget.h"
#include "PreviewWindow.h"
@@ -13,14 +14,23 @@ class EditorWidget : public QWidget
Q_OBJECT
private:
- Ui::EditorWidgetClass ui;
+ // DATA PART
PreviewWindow *previewWindow;
ElementManager *elementManager;
LayerManager *layerManager;
+ // QT GUI PART
+ Ui::EditorWidgetClass ui;
LayerTreeWidget *treeWidget;
+ QTabWidget *tabWidget;
+ // QT DATA PART
+ LayerWrapper *displayLayer;
+ GraphicElement *displayElement;
public:
EditorWidget(QWidget *parent = nullptr);
~EditorWidget();
void paintEvent(QPaintEvent *event) override;
+
+ private slots:
+ void onLayerChange(LayerWrapper *layer);
};
diff --git a/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp b/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp
new file mode 100644
index 0000000..eb3d186
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp
@@ -0,0 +1,62 @@
+#include "InfoDisplayWidget.h"
+#include
+#include
+void InfoDisplayWidget::setLayer(LayerWrapper *layer)
+{
+ this->displayLayer = layer;
+ generateLayerForm();
+}
+void InfoDisplayWidget::setElement(GraphicElement *element)
+{
+ this->displayElement = element;
+ generateElementForm();
+}
+void InfoDisplayWidget::generateLayerForm()
+{
+ QLayoutItem *item;
+ if (this->layout() != nullptr)
+ {
+ while ((item = this->layout()->takeAt(0)) != nullptr)
+ {
+ delete item->widget();
+ delete item;
+ }
+ delete this->layout();
+ }
+
+ 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);
+ name->setDisabled(true);
+ rotation->setValidator(new QIntValidator(-1000, 1000, this));
+ connect(rotation, &QLineEdit::textChanged,
+ [=](QString content) { this->displayLayer->property.rotation = content.toDouble(); });
+ offsetX->setValidator(new QIntValidator(-1000, 1000, this));
+ connect(offsetX, &QLineEdit::textChanged, [=](QString content) {
+ this->displayLayer->property.offset = {content.toDouble(), this->displayLayer->property.offset.y()};
+ });
+ offsetY->setValidator(new QIntValidator(-1000, 1000, this));
+ connect(offsetY, &QLineEdit::textChanged, [=](QString content) {
+ this->displayLayer->property.offset = {this->displayLayer->property.offset.x(), content.toDouble()};
+ ;
+ });
+
+ layout->addRow("layer name:", name);
+ layout->addRow("rotation:", rotation);
+ layout->addRow("offset-X:", offsetX);
+ layout->addRow("offset-Y:", offsetY);
+ }
+ this->setLayout(layout);
+}
+void InfoDisplayWidget::generateElementForm()
+{
+}
diff --git a/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.h b/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.h
index 6f70f09..1e5f225 100644
--- a/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.h
+++ b/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.h
@@ -1 +1,20 @@
#pragma once
+#include "GraphicElement.h"
+#include "LayerWrapper.h"
+#include
+#include
+#include
+
+class InfoDisplayWidget : public QWidget
+{
+ Q_OBJECT
+ private:
+ LayerWrapper *displayLayer;
+ GraphicElement *displayElement;
+
+ public:
+ void setLayer(LayerWrapper *layer);
+ void setElement(GraphicElement *element);
+ void generateLayerForm();
+ void generateElementForm();
+};
diff --git a/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp b/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp
index 13137c5..bb59b9b 100644
--- a/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp
+++ b/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp
@@ -3,11 +3,16 @@
#include
LayerTreeWidget::LayerTreeWidget(QWidget *parent)
{
+ emit displayLayerChange(nullptr);
this->selectedItem = nullptr;
this->copiedItem = nullptr;
this->setContextMenuPolicy(Qt::CustomContextMenu);
this->setHeaderLabel("Layer Content");
connect(this, &QTreeWidget::customContextMenuRequested, this, &LayerTreeWidget::popMenu);
+ connect(this, &QTreeWidget::currentItemChanged, [=](QTreeWidgetItem *currentItem) {
+ this->selectedItem = currentItem;
+ emit displayLayerChange(this->selectedItem->data(0, Qt::UserRole).value());
+ });
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
}
@@ -50,4 +55,5 @@ void LayerTreeWidget::onRenameEvent()
this->selectedItem->setText(0, sName);
this->selectedItem->data(0, Qt::UserRole).value()->property.name = sName;
}
+ emit displayLayerChange(this->selectedItem->data(0, Qt::UserRole).value());
}
diff --git a/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.h b/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.h
index cf6359a..e8510a1 100644
--- a/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.h
+++ b/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.h
@@ -15,4 +15,7 @@ class LayerTreeWidget : public QTreeWidget
void popMenu(const QPoint &pos);
// void mouseDoubleClickEvent(QMouseEvent *event) override;
// void onItemDoubleClicked(QTreeWidgetItem *item, int column = 0);
+
+ signals:
+ void displayLayerChange(LayerWrapper *);
};