初步完成Layer新建
parent
6f8bfa1558
commit
25eec60e5c
|
@ -104,6 +104,7 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidget.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidgetItem.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetItem.cpp" />
|
||||||
<ClCompile Include="src\Editor\ElementManager.cpp" />
|
<ClCompile Include="src\Editor\ElementManager.cpp" />
|
||||||
|
@ -154,6 +155,7 @@
|
||||||
<QtUic Include="EditorWidgetItem.ui" />
|
<QtUic Include="EditorWidgetItem.ui" />
|
||||||
<QtUic Include="MainWindow.ui" />
|
<QtUic Include="MainWindow.ui" />
|
||||||
<QtUic Include="RendererWidget.ui" />
|
<QtUic Include="RendererWidget.ui" />
|
||||||
|
<QtUic Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.ui" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\data.json" />
|
<None Include="..\data.json" />
|
||||||
|
@ -188,6 +190,7 @@
|
||||||
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h" />
|
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h" />
|
||||||
<QtMoc Include="src\MainWindow.h" />
|
<QtMoc Include="src\MainWindow.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidget.h" />
|
||||||
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h" />
|
||||||
<ClInclude Include="src\Editor\ElementManager.h" />
|
<ClInclude Include="src\Editor\ElementManager.h" />
|
||||||
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
||||||
<ClInclude Include="src\Editor\GraphicElement.h" />
|
<ClInclude Include="src\Editor\GraphicElement.h" />
|
||||||
|
|
|
@ -73,6 +73,9 @@
|
||||||
<QtUic Include="EditorWidget.ui">
|
<QtUic Include="EditorWidget.ui">
|
||||||
<Filter>Form Files</Filter>
|
<Filter>Form Files</Filter>
|
||||||
</QtUic>
|
</QtUic>
|
||||||
|
<QtUic Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.ui">
|
||||||
|
<Filter>Form Files</Filter>
|
||||||
|
</QtUic>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\Editor\EditorWidgetItem.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetItem.cpp">
|
||||||
|
@ -213,6 +216,9 @@
|
||||||
<ClCompile Include="src\Editor\util\PaintingUtil.cpp">
|
<ClCompile Include="src\Editor\util\PaintingUtil.cpp">
|
||||||
<Filter>Source Files\Editor\util</Filter>
|
<Filter>Source Files\Editor\util</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||||
|
@ -248,6 +254,9 @@
|
||||||
<QtMoc Include="src\FluentMenu.h">
|
<QtMoc Include="src\FluentMenu.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\data.json" />
|
<None Include="..\data.json" />
|
||||||
|
@ -441,9 +450,6 @@
|
||||||
<ClInclude Include="src\Renderer\VirtualTextureManager.h">
|
<ClInclude Include="src\Renderer\VirtualTextureManager.h">
|
||||||
<Filter>Header Files\Renderer</Filter>
|
<Filter>Header Files\Renderer</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="resource.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Editor\util\PaintingUtil.h">
|
<ClInclude Include="src\Editor\util\PaintingUtil.h">
|
||||||
<Filter>Header Files\Editor\util</Filter>
|
<Filter>Header Files\Editor\util</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
#include "LayerCreateWidget.h"
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
|
LayerCreateWidget::LayerCreateWidget(ElementManager* elementManager, QWidget* parent) :
|
||||||
|
QDialog(parent)
|
||||||
|
{
|
||||||
|
ui.setupUi(this);
|
||||||
|
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
|
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
|
||||||
|
elementPool = new ElementPoolWidget(ui.elementPool);
|
||||||
|
elementPool->setElementList(elementManager->elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerCreateWidget::~LayerCreateWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerCreateWidget::accept()
|
||||||
|
{
|
||||||
|
QJsonObject jsonObj;
|
||||||
|
jsonObj.insert("name", ui.name->text());
|
||||||
|
if (ui.comboBox->currentIndex() == 0) {
|
||||||
|
jsonObj.insert("is-folder", false);
|
||||||
|
jsonObj.insert("element", elementPool->currentIndex);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
jsonObj.insert("is-folder", true);
|
||||||
|
jsonObj.insert("children", QJsonArray());
|
||||||
|
}
|
||||||
|
jsonObj.insert("tranform", "{\"offset\":{\"x\":0,\"y\":0},\"scale\":{\"x\":1,\"y\":1},\"rotation\":0}");
|
||||||
|
jsonObj.insert("referenced-by", QJsonValue());
|
||||||
|
emit LayerInfoReturned(jsonObj);
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerCreateWidget::onCurrentIndexChanged(int index) {
|
||||||
|
if (index == 0) {// leaf layer
|
||||||
|
elementPool->setVisible(true);
|
||||||
|
}
|
||||||
|
else {// folder layer
|
||||||
|
elementPool->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
#pragma once
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include "ElementPoolWidget.h"
|
||||||
|
#include "ElementManager.h"
|
||||||
|
#include "ui_LayerCreateWidget.h"
|
||||||
|
|
||||||
|
class LayerCreateWidget :
|
||||||
|
public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::LayerCreateWidget ui;
|
||||||
|
ElementPoolWidget* elementPool;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
LayerCreateWidget(ElementManager* elementManager,QWidget* parent = nullptr);
|
||||||
|
~LayerCreateWidget();
|
||||||
|
void accept() override;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onCurrentIndexChanged(int index);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void LayerInfoReturned(QJsonObject jsonObj);
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>LayerCreateWidget</class>
|
||||||
|
<widget class="QWidget" name="LayerCreateWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>326</width>
|
||||||
|
<height>355</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,5,1,0">
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBox">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>90</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="maxVisibleItems">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="maxCount">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="insertPolicy">
|
||||||
|
<enum>QComboBox::NoInsert</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QComboBox::AdjustToContents</enum>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>叶子节点</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>组合节点</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>图层名:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="name"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="elementPool" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
<property name="centerButtons">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -36,6 +36,7 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
elementManager = new ElementManager(source,previewWindow->getRenderer());
|
elementManager = new ElementManager(source,previewWindow->getRenderer());
|
||||||
layerManager = new LayerManager(source, elementManager);
|
layerManager = new LayerManager(source, elementManager);
|
||||||
elementInfoDisplayWidget->setElementManager(elementManager);
|
elementInfoDisplayWidget->setElementManager(elementManager);
|
||||||
|
treeWidget->elementManager = elementManager;
|
||||||
qDebug() << layerManager->toJson();
|
qDebug() << layerManager->toJson();
|
||||||
previewWindow->initialize(layerManager,QSize(jsonDoc.object().value("width").toDouble(),jsonDoc.object().value("height").toDouble()));
|
previewWindow->initialize(layerManager,QSize(jsonDoc.object().value("width").toDouble(),jsonDoc.object().value("height").toDouble()));
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,9 @@ void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
|
||||||
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
||||||
pictureList->insertItem(index, pItem);
|
pictureList->insertItem(index, pItem);
|
||||||
}
|
}
|
||||||
|
if(elements.size() > 0)
|
||||||
|
pictureList->setCurrentRow(0),
|
||||||
|
currentIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementPoolWidget::~ElementPoolWidget() {
|
ElementPoolWidget::~ElementPoolWidget() {
|
||||||
|
@ -61,6 +64,7 @@ ElementPoolWidget::~ElementPoolWidget() {
|
||||||
|
|
||||||
int ElementPoolWidget::pictureItemClicked(QListWidgetItem* item) {
|
int ElementPoolWidget::pictureItemClicked(QListWidgetItem* item) {
|
||||||
//qDebug() << pictureList->currentRow();
|
//qDebug() << pictureList->currentRow();
|
||||||
|
currentIndex = pictureList->currentRow();
|
||||||
emit elementSelected(this->elements[pictureList->currentRow()]);
|
emit elementSelected(this->elements[pictureList->currentRow()]);
|
||||||
return pictureList->currentRow();
|
return pictureList->currentRow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ private:
|
||||||
ElementManager* elementManager;
|
ElementManager* elementManager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
int currentIndex = -1;
|
||||||
ElementPoolWidget(QWidget* parent = nullptr);
|
ElementPoolWidget(QWidget* parent = nullptr);
|
||||||
void setElementList(std::vector<GraphicElement*> elementList);
|
void setElementList(std::vector<GraphicElement*> elementList);
|
||||||
void setElementManager(ElementManager* element);
|
void setElementManager(ElementManager* element);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "LayerTreeWidget.h"
|
#include "LayerTreeWidget.h"
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include "./EditorWidgetComponent/LayerCreateWidget.h"
|
||||||
|
|
||||||
LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
||||||
{
|
{
|
||||||
emit displayLayerChange(nullptr);
|
emit displayLayerChange(nullptr);
|
||||||
|
@ -39,7 +41,23 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
|
||||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||||
if (layer != nullptr) {
|
if (layer != nullptr) {
|
||||||
if (typeid(*layer) == typeid(FolderLayerWrapper)) {
|
if (typeid(*layer) == typeid(FolderLayerWrapper)) {
|
||||||
menu.addAction(QString::fromLocal8Bit("创建子节点"), this, &LayerTreeWidget::onRenameEvent);
|
menu.addAction(QString::fromLocal8Bit("´´½¨×Ó½Úµã"), this, [this, layer]() {
|
||||||
|
auto dialog = new LayerCreateWidget(elementManager, this);
|
||||||
|
connect(dialog, &LayerCreateWidget::LayerInfoReturned, this, [this, layer](QJsonObject jsonObj) {
|
||||||
|
auto folderLayer = dynamic_cast<FolderLayerWrapper*>(layer);
|
||||||
|
LayerWrapper* newLayer;
|
||||||
|
if(jsonObj.value("is-folder").toBool())
|
||||||
|
newLayer = new FolderLayerWrapper(jsonObj, this->elementManager, folderLayer);
|
||||||
|
else
|
||||||
|
newLayer = new LeafLayerWrapper(jsonObj, this->elementManager, folderLayer);
|
||||||
|
folderLayer->addChild(std::shared_ptr<LayerWrapper>(newLayer));
|
||||||
|
folderLayer->qTreeWidgetItem.addChild(newLayer->getQTreeItem());
|
||||||
|
qDebug() << jsonObj<<"----------------------";
|
||||||
|
this->refresh();
|
||||||
|
emit requireRefreshPreview();
|
||||||
|
});
|
||||||
|
dialog->exec();
|
||||||
|
});
|
||||||
menu.addAction(QString::fromLocal8Bit("ɾ³ý£¨±£Áô×ӽڵ㣩"), this, [this]() {
|
menu.addAction(QString::fromLocal8Bit("ɾ³ý£¨±£Áô×ӽڵ㣩"), this, [this]() {
|
||||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||||
layer->delSelf();
|
layer->delSelf();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "LayerWrapper.h"
|
#include "LayerWrapper.h"
|
||||||
|
#include "ElementManager.h"
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
class LayerTreeWidget : public QTreeWidget
|
class LayerTreeWidget : public QTreeWidget
|
||||||
|
@ -10,6 +11,7 @@ class LayerTreeWidget : public QTreeWidget
|
||||||
LayerWrapper *copiedItem;
|
LayerWrapper *copiedItem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
ElementManager* elementManager;
|
||||||
LayerWrapper* root;
|
LayerWrapper* root;
|
||||||
LayerTreeWidget(QWidget *parent = nullptr);
|
LayerTreeWidget(QWidget *parent = nullptr);
|
||||||
void onRenameEvent();
|
void onRenameEvent();
|
||||||
|
|
Loading…
Reference in New Issue