完成layer信息展示和数据修改(部分)
parent
3d770ea92f
commit
cee219409e
|
@ -105,6 +105,7 @@
|
|||
<ClCompile Include="src\Editor\LayerManager.cpp" />
|
||||
<ClCompile Include="src\Editor\LayerWrapper.cpp" />
|
||||
<ClCompile Include="src\Editor\PreviewWindow.cpp" />
|
||||
<ClCompile Include="src\Editor\RightBar\InfoDisplayWidget.cpp" />
|
||||
<ClCompile Include="src\Editor\RightBar\LayerTreeWidget.cpp" />
|
||||
<ClCompile Include="src\Editor\third-party modules\qquick\qquicksvgparser.cpp" />
|
||||
<ClCompile Include="src\Editor\third-party modules\util\SvgFileLoader.cpp" />
|
||||
|
@ -163,6 +164,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="src\Editor\RightBar\LayerTreeWidget.h" />
|
||||
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h" />
|
||||
<ClInclude Include="src\Editor\third-party modules\qquick\qtquickglobal.h" />
|
||||
<ClInclude Include="src\Editor\third-party modules\qquick\qtquickglobal_p.h" />
|
||||
<ClInclude Include="src\Editor\third-party modules\qquick\qquicksvgparser_p.h" />
|
||||
|
|
|
@ -177,6 +177,9 @@
|
|||
<ClCompile Include="src\Editor\RightBar\LayerTreeWidget.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Editor\RightBar\InfoDisplayWidget.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||
|
@ -209,6 +212,9 @@
|
|||
<QtMoc Include="src\Editor\RightBar\LayerTreeWidget.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Shaders\shader.frag">
|
||||
|
|
|
@ -49,7 +49,24 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="RightBar" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="1,2">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="DisplayTab">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="InfoDisplayWidget" name="LayerDisplay">
|
||||
<attribute name="title">
|
||||
<string>Layer</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="ElementDisplay">
|
||||
<attribute name="title">
|
||||
<string>Element</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LayerTreeWidget" name="LayerTree">
|
||||
<property name="contextMenuPolicy">
|
||||
|
@ -79,6 +96,12 @@
|
|||
<extends>QTreeWidget</extends>
|
||||
<header location="global">LayerTreeWidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>InfoDisplayWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">InfoDisplayWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -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<InfoDisplayWidget *>(tabWidget->widget(0))->setLayer(layer);
|
||||
this->update();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#include "InfoDisplayWidget.h"
|
||||
#include <QLineEdit>
|
||||
#include <QTextBlock>
|
||||
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()
|
||||
{
|
||||
}
|
|
@ -1 +1,20 @@
|
|||
#pragma once
|
||||
#include "GraphicElement.h"
|
||||
#include "LayerWrapper.h"
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
|
||||
class InfoDisplayWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
LayerWrapper *displayLayer;
|
||||
GraphicElement *displayElement;
|
||||
|
||||
public:
|
||||
void setLayer(LayerWrapper *layer);
|
||||
void setElement(GraphicElement *element);
|
||||
void generateLayerForm();
|
||||
void generateElementForm();
|
||||
};
|
||||
|
|
|
@ -3,11 +3,16 @@
|
|||
#include <QMenu>
|
||||
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<LayerWrapper *>());
|
||||
});
|
||||
// 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<LayerWrapper *>()->property.name = sName;
|
||||
}
|
||||
emit displayLayerChange(this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper *>());
|
||||
}
|
||||
|
|
|
@ -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 *);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue