Merge branch 'main' into dev-LayerStyle
commit
43719bc81a
|
@ -180,6 +180,12 @@
|
||||||
<property name="accessibleName">
|
<property name="accessibleName">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>10</width>
|
||||||
|
<height>10</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>图层名</string>
|
<string>图层名</string>
|
||||||
|
@ -190,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>
|
||||||
|
|
|
@ -25,6 +25,7 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
treeWidget->refresh();
|
treeWidget->refresh();
|
||||||
previewWindow->refresh();
|
previewWindow->refresh();
|
||||||
};
|
};
|
||||||
|
connect(previewWindow, &PreviewWindow::triggerCentralRefresh, centralRefresh);
|
||||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
||||||
connect(elementInfoDisplayWidget, &ElementPoolWidget::triggerCentralRefresh, centralRefresh);
|
connect(elementInfoDisplayWidget, &ElementPoolWidget::triggerCentralRefresh, centralRefresh);
|
||||||
connect(treeWidget, &LayerTreeWidget::triggerCentralRefresh, centralRefresh);
|
connect(treeWidget, &LayerTreeWidget::triggerCentralRefresh, centralRefresh);
|
||||||
|
@ -33,15 +34,15 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
connect(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
|
connect(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
|
||||||
connect(previewWindow, &PreviewWindow::layerInfoChanged, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
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);
|
||||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
||||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
||||||
&EditorWidgetItem::triggerRefreshPreview);
|
// &EditorWidgetItem::triggerRefreshPreview);
|
||||||
connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
|
// connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
|
||||||
&EditorWidgetItem::triggerRefreshPreview);
|
// &EditorWidgetItem::triggerRefreshPreview);
|
||||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireSelfRefresh, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
//connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireSelfRefresh, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
||||||
connect(elementInfoDisplayWidget, &ElementPoolWidget::refreshLayerTree, treeWidget, &LayerTreeWidget::refresh);
|
// connect(elementInfoDisplayWidget, &ElementPoolWidget::refreshLayerTree, treeWidget, &LayerTreeWidget::refresh);
|
||||||
// &EditorWidget::triggerRefreshPreview);
|
// &EditorWidget::triggerRefreshPreview);
|
||||||
// test
|
// test
|
||||||
QFile settingFile;
|
QFile settingFile;
|
||||||
|
@ -73,9 +74,10 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
this->projectName = source.value("project-name").toString();
|
this->projectName = source.value("project-name").toString();
|
||||||
qDebug() << this->backgroundColor;
|
qDebug() << this->backgroundColor;
|
||||||
qDebug() << this->projectName;
|
qDebug() << this->projectName;
|
||||||
QTimer::singleShot(300, this, [this]() {
|
QTimer::singleShot(300, this, [this, centralRefresh]() {
|
||||||
handleBackgroundColorChange(this->backgroundColor);
|
handleBackgroundColorChange(this->backgroundColor);
|
||||||
handleProjectNameChange(this->projectName);
|
handleProjectNameChange(this->projectName);
|
||||||
|
centralRefresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ bool SimpleElement::isClosed() const
|
||||||
|
|
||||||
void GroupElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles)
|
void GroupElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles)
|
||||||
{
|
{
|
||||||
sourceLayer->paint(painter, transform);
|
sourceLayer->paint(painter, transform, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GroupElement::isClosed() const
|
bool GroupElement::isClosed() const
|
||||||
|
|
|
@ -47,6 +47,7 @@ LayerWrapper::LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementM
|
||||||
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()};
|
||||||
selected = false;
|
selected = false;
|
||||||
|
hidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent)
|
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent)
|
||||||
|
@ -199,6 +200,7 @@ void FolderLayerWrapper::delSelf() {
|
||||||
QTreeWidgetItem* LayerWrapper::getQTreeItem()
|
QTreeWidgetItem* LayerWrapper::getQTreeItem()
|
||||||
{
|
{
|
||||||
this->qTreeWidgetItem->setData(0, Qt::UserRole, QVariant::fromValue(this));
|
this->qTreeWidgetItem->setData(0, Qt::UserRole, QVariant::fromValue(this));
|
||||||
|
this->qTreeWidgetItem->setCheckState(0, Qt::Checked);
|
||||||
return this->qTreeWidgetItem;
|
return this->qTreeWidgetItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,31 +282,27 @@ int FolderLayerWrapper::getReferencedBy()const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerWrapper::paint(QPainter* painter, QTransform transform, bool ignoreSelected)
|
void LayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
||||||
{
|
{
|
||||||
if (!ignoreSelected && this->selected)
|
|
||||||
{
|
|
||||||
painter->save();
|
|
||||||
painter->setTransform(transform, ignoreSelected);
|
|
||||||
painter->setPen(QPen(Qt::gray, 2));
|
|
||||||
painter->setPen(Qt::DashLine);
|
|
||||||
painter->drawRect(cache.getBoundingRect());
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool ignoreSelected)
|
void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
||||||
{
|
{
|
||||||
LayerWrapper::paint(painter, transform, ignoreSelected);
|
if (hidden && !force)
|
||||||
|
return;
|
||||||
|
LayerWrapper::paint(painter, transform, force);
|
||||||
transform = property.transform * transform;
|
transform = property.transform * transform;
|
||||||
//qDebug() << transform;
|
//qDebug() << transform;
|
||||||
for (auto& child : children)
|
for (auto& child : children)
|
||||||
child->paint(painter, transform, ignoreSelected);
|
child->paint(painter, transform, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool ignoreSelected)
|
void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
||||||
{
|
{
|
||||||
LayerWrapper::paint(painter, transform, ignoreSelected);
|
if (hidden && !force)
|
||||||
|
return;
|
||||||
|
LayerWrapper::paint(painter, transform, force);
|
||||||
transform = property.transform * transform;
|
transform = property.transform * transform;
|
||||||
//qDebug() << transform;
|
//qDebug() << transform;
|
||||||
if (wrappedElement != nullptr)
|
if (wrappedElement != nullptr)
|
||||||
|
@ -347,11 +345,12 @@ void FolderLayerWrapper::collectDownReachable(std::set<LayerWrapper*>& reachable
|
||||||
|
|
||||||
void LayerWrapper::refreshTreeItem()
|
void LayerWrapper::refreshTreeItem()
|
||||||
{
|
{
|
||||||
|
hidden = qTreeWidgetItem->checkState(0) == Qt::Unchecked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeafLayerWrapper::refreshTreeItem()
|
void LeafLayerWrapper::refreshTreeItem()
|
||||||
{
|
{
|
||||||
|
LayerWrapper::refreshTreeItem();
|
||||||
if (typeid(*wrappedElement) == typeid(GroupElement))
|
if (typeid(*wrappedElement) == typeid(GroupElement))
|
||||||
{
|
{
|
||||||
this->qTreeWidgetItem->setText(0, "@ " + this->property.name);
|
this->qTreeWidgetItem->setText(0, "@ " + this->property.name);
|
||||||
|
@ -366,6 +365,7 @@ void LeafLayerWrapper::refreshTreeItem()
|
||||||
|
|
||||||
void FolderLayerWrapper::refreshTreeItem()
|
void FolderLayerWrapper::refreshTreeItem()
|
||||||
{
|
{
|
||||||
|
LayerWrapper::refreshTreeItem();
|
||||||
for (auto& child : this->children) {
|
for (auto& child : this->children) {
|
||||||
child->refreshTreeItem();
|
child->refreshTreeItem();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ class LayerWrapper
|
||||||
public:
|
public:
|
||||||
QTreeWidgetItem* qTreeWidgetItem;
|
QTreeWidgetItem* qTreeWidgetItem;
|
||||||
bool selected;
|
bool selected;
|
||||||
|
bool hidden;
|
||||||
struct SimpleProperty
|
struct SimpleProperty
|
||||||
{
|
{
|
||||||
QString name = "";
|
QString name = "";
|
||||||
|
@ -58,7 +59,7 @@ class LayerWrapper
|
||||||
FolderLayerWrapper*getParent() const; // invoke by manager, then invoke parent's applyStyles
|
FolderLayerWrapper*getParent() const; // invoke by manager, then invoke parent's applyStyles
|
||||||
LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementManager* elementManager=nullptr);
|
LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementManager* elementManager=nullptr);
|
||||||
LayerWrapper() = default;
|
LayerWrapper() = default;
|
||||||
virtual void paint(QPainter* painter, QTransform transform=QTransform(), bool ignoreSelected = false);
|
virtual void paint(QPainter* painter, QTransform transform=QTransform(), bool force = false);
|
||||||
// TODO : export Function
|
// TODO : export Function
|
||||||
// virtual LayerWrapper *addChild() = 0; // Leaf Child Only
|
// virtual LayerWrapper *addChild() = 0; // Leaf Child Only
|
||||||
// virtual LayerWrapper *addParent() = 0; // Folder Parent Only
|
// virtual LayerWrapper *addParent() = 0; // Folder Parent Only
|
||||||
|
@ -97,7 +98,7 @@ class FolderLayerWrapper : public LayerWrapper
|
||||||
QTreeWidgetItem* getQTreeItem() override;
|
QTreeWidgetItem* getQTreeItem() override;
|
||||||
QJsonObject toJson() const override;
|
QJsonObject toJson() const override;
|
||||||
int getReferencedBy()const;
|
int getReferencedBy()const;
|
||||||
void paint(QPainter* painter, QTransform transform = QTransform(), bool ignoreSelected = false) override;
|
void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false) override;
|
||||||
void collectDownReachable(std::set<LayerWrapper*>& reachable) override;
|
void collectDownReachable(std::set<LayerWrapper*>& reachable) override;
|
||||||
void refreshTreeItem() override;
|
void refreshTreeItem() override;
|
||||||
size_t referencedCount(bool excludeSelf = false) const override;
|
size_t referencedCount(bool excludeSelf = false) const override;
|
||||||
|
@ -115,7 +116,7 @@ class LeafLayerWrapper : public LayerWrapper
|
||||||
void refresh(LayerWrapper* layer = nullptr) override;
|
void refresh(LayerWrapper* layer = nullptr) override;
|
||||||
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent);
|
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent);
|
||||||
QJsonObject toJson() const override;
|
QJsonObject toJson() const override;
|
||||||
void paint(QPainter* painter, QTransform transform = QTransform(), bool ignoreSelected = false) override;
|
void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false) override;
|
||||||
void collectDownReachable(std::set<LayerWrapper*>& reachable) override;
|
void collectDownReachable(std::set<LayerWrapper*>& reachable) override;
|
||||||
QTreeWidgetItem* getQTreeItem() override;
|
QTreeWidgetItem* getQTreeItem() override;
|
||||||
void refreshTreeItem() override;
|
void refreshTreeItem() override;
|
||||||
|
|
|
@ -100,19 +100,18 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event)
|
||||||
auto index = -1;
|
auto index = -1;
|
||||||
if (typeid(*layer) == typeid(FolderLayerWrapper))
|
if (typeid(*layer) == typeid(FolderLayerWrapper))
|
||||||
index = dynamic_cast<FolderLayerWrapper*>(layer)->getReferencedBy();
|
index = dynamic_cast<FolderLayerWrapper*>(layer)->getReferencedBy();
|
||||||
if (index != -1)
|
|
||||||
emit refreshElementPreviewByIndex(index);
|
|
||||||
layer = layer->getParent();
|
layer = layer->getParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 更新上一次的位置
|
// 更新上一次的位置
|
||||||
|
emit triggerCentralRefresh();
|
||||||
m_lastPos = event->pos();
|
m_lastPos = event->pos();
|
||||||
this->repaint();
|
this->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWindow::mouseReleaseEvent(QMouseEvent* event)
|
void PreviewWindow::mouseReleaseEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
emit layerInfoChanged();
|
//emit layerInfoChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWindow::setBackgroundColor(QColor color)
|
void PreviewWindow::setBackgroundColor(QColor color)
|
||||||
|
|
|
@ -46,4 +46,5 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
void layerInfoChanged();
|
void layerInfoChanged();
|
||||||
void refreshElementPreview(GraphicElement*);
|
void refreshElementPreview(GraphicElement*);
|
||||||
void refreshElementPreviewByIndex(int);
|
void refreshElementPreviewByIndex(int);
|
||||||
|
void triggerCentralRefresh();
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,12 +21,11 @@ void InfoDisplayWidget::generateLayerForm()
|
||||||
{
|
{
|
||||||
while (this->layout()->count() > 0 && (item = this->layout()->takeAt(0)) != nullptr)
|
while (this->layout()->count() > 0 && (item = this->layout()->takeAt(0)) != nullptr)
|
||||||
{
|
{
|
||||||
delete item->widget();
|
item->widget()->deleteLater();
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
delete this->layout();
|
delete this->layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
QFormLayout *layout = new QFormLayout();
|
QFormLayout *layout = new QFormLayout();
|
||||||
layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
||||||
if (this->displayLayer == nullptr)
|
if (this->displayLayer == nullptr)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include "./EditorWidgetComponent/LayerCreateWidget.h"
|
#include "./EditorWidgetComponent/LayerCreateWidget.h"
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
||||||
{
|
{
|
||||||
|
@ -26,6 +27,10 @@ LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
||||||
}
|
}
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
|
connect(this, &QTreeWidget::itemChanged, this, [=]() {
|
||||||
|
emit triggerCentralRefresh();
|
||||||
|
});
|
||||||
|
|
||||||
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue