Compare commits
No commits in common. "73719905db22a3d09664f02fc072059c940d693d" and "7da01fbe92c29a8d6154e4753d4f455236e334a2" have entirely different histories.
73719905db
...
7da01fbe92
|
@ -104,7 +104,6 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\Editor\RightBar\EditorSettingWidget.cpp" />
|
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.cpp" />
|
||||||
|
@ -155,7 +154,6 @@
|
||||||
<ClCompile Include="src\Renderer\VirtualTextureManager.cpp" />
|
<ClCompile Include="src\Renderer\VirtualTextureManager.cpp" />
|
||||||
<ClCompile Include="src\SvgParser.cpp" />
|
<ClCompile Include="src\SvgParser.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\StrokeStyleWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetComponent\StrokeStyleWidget.cpp" />
|
||||||
<QtUic Include="EditorSettingWidget.ui" />
|
|
||||||
<QtUic Include="EditorWidget.ui" />
|
<QtUic Include="EditorWidget.ui" />
|
||||||
<QtUic Include="EditorWidgetItem.ui" />
|
<QtUic Include="EditorWidgetItem.ui" />
|
||||||
<QtUic Include="MainWindow.ui" />
|
<QtUic Include="MainWindow.ui" />
|
||||||
|
@ -199,7 +197,6 @@
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h" />
|
||||||
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h" />
|
|
||||||
<ClInclude Include="src\Editor\util\EncodeUtil.hpp" />
|
<ClInclude Include="src\Editor\util\EncodeUtil.hpp" />
|
||||||
<ClInclude Include="src\Editor\util\JsonUtil.hpp" />
|
<ClInclude Include="src\Editor\util\JsonUtil.hpp" />
|
||||||
<ClInclude Include="src\Editor\ElementManager.h" />
|
<ClInclude Include="src\Editor\ElementManager.h" />
|
||||||
|
|
|
@ -82,9 +82,6 @@
|
||||||
<QtUic Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.ui">
|
<QtUic Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.ui">
|
||||||
<Filter>Form Files</Filter>
|
<Filter>Form Files</Filter>
|
||||||
</QtUic>
|
</QtUic>
|
||||||
<QtUic Include="EditorSettingWidget.ui">
|
|
||||||
<Filter>Form Files</Filter>
|
|
||||||
</QtUic>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\Editor\EditorWidgetItem.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetItem.cpp">
|
||||||
|
@ -237,9 +234,6 @@
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp">
|
||||||
<Filter>Source Files\Editor</Filter>
|
<Filter>Source Files\Editor</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Editor\RightBar\EditorSettingWidget.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||||
|
@ -287,9 +281,6 @@
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h">
|
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h">
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\data.json" />
|
<None Include="..\data.json" />
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>EditorSettingWidget</class>
|
|
||||||
<widget class="QWidget" name="EditorSettingWidget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="backgroundColorButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>设置背景颜色</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>EditorSettingWidget</class>
|
|
||||||
<widget class="QWidget" name="EditorSettingWidget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item alignment="Qt::AlignHCenter">
|
|
||||||
<widget class="QPushButton" name="backgroundColorButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>120</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>设置背景颜色</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item alignment="Qt::AlignHCenter">
|
|
||||||
<widget class="QPushButton" name="renameButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>120</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>设置项目名称</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -147,7 +147,7 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="InfoDisplayWidget" name="LayerDisplay">
|
<widget class="InfoDisplayWidget" name="LayerDisplay">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -159,11 +159,6 @@
|
||||||
<string>图元池</string>
|
<string>图元池</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="EditorSettingWidget" name="EditorSetting">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>设置</string>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -234,12 +229,6 @@
|
||||||
<header>ElementPoolWidget.h</header>
|
<header>ElementPoolWidget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>EditorSettingWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">EditorSettingWidget.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -4,11 +4,6 @@ layout(local_size_x = 8, local_size_y = 8) in;
|
||||||
|
|
||||||
layout(location = 0) uniform ivec2 pixelOffset;
|
layout(location = 0) uniform ivec2 pixelOffset;
|
||||||
|
|
||||||
layout(std140, binding = 1) uniform ubo
|
|
||||||
{
|
|
||||||
vec3 backgroundColor;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout(rgba8, binding = 0) uniform image2D gBaseColor;
|
layout(rgba8, binding = 0) uniform image2D gBaseColor;
|
||||||
layout(rg8, binding = 1) uniform image2D gMetallicRoughness;
|
layout(rg8, binding = 1) uniform image2D gMetallicRoughness;
|
||||||
|
|
||||||
|
@ -1358,7 +1353,7 @@ void main()
|
||||||
vec3 debugBVH = vec3(0);
|
vec3 debugBVH = vec3(0);
|
||||||
// bool debugHit = false;
|
// bool debugHit = false;
|
||||||
//vec4 color = vec4(0.76, 0.33, 0.15, -1);
|
//vec4 color = vec4(0.76, 0.33, 0.15, -1);
|
||||||
vec4 color = vec4(backgroundColor, -1);
|
vec4 color = vec4(1,1,1, -1);
|
||||||
vec2 metallicRoughness = vec2(0, 0.8);
|
vec2 metallicRoughness = vec2(0, 0.8);
|
||||||
stack.top = 0;
|
stack.top = 0;
|
||||||
uint index = 0, visitTime = 0;
|
uint index = 0, visitTime = 0;
|
||||||
|
|
|
@ -47,11 +47,3 @@ EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWidget::renameTab(QWidget* target, QString name)
|
|
||||||
{
|
|
||||||
int index = this->tabWidget->indexOf(target);
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
this->tabWidget->setTabText(index, name);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,6 +18,6 @@ private:
|
||||||
public:
|
public:
|
||||||
EditorWidget(QWidget* parent = nullptr);
|
EditorWidget(QWidget* parent = nullptr);
|
||||||
~EditorWidget()=default;
|
~EditorWidget()=default;
|
||||||
void renameTab(QWidget* target, QString name);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,20 @@
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
LayerStyleDialog::LayerStyleDialog(
|
LayerStyleDialog::LayerStyleDialog(
|
||||||
LayerStyleContainer& styles,
|
QWidget* parent,
|
||||||
std::shared_ptr<LayerStyle> existedStyle,
|
std::shared_ptr<LayerStyle> existedStyle,
|
||||||
QWidget* parent
|
std::vector<std::shared_ptr<LayerStyle>>* excludeStyles
|
||||||
) : QDialog(parent), styles(&styles)
|
) : QDialog(parent)
|
||||||
{
|
{
|
||||||
auto* dialogLayout = new QVBoxLayout(this);
|
QVBoxLayout* dialogLayout = new QVBoxLayout(this);
|
||||||
dialogLayout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
|
dialogLayout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
|
||||||
this->setLayout(dialogLayout);
|
this->setLayout(dialogLayout);
|
||||||
|
|
||||||
if (existedStyle)
|
if (existedStyle)
|
||||||
{
|
{
|
||||||
this->modifyingStyle = existedStyle->clone();
|
this->modifyingStyle = existedStyle->clone();
|
||||||
|
|
||||||
|
@ -26,14 +28,28 @@ LayerStyleDialog::LayerStyleDialog(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QStringList unusedStyleNames = styles.unusedStyleNames();
|
std::unordered_set<QString> excludeStyleNames;
|
||||||
auto* typeSelector = new QComboBox(this);
|
for(auto &style : *excludeStyles)
|
||||||
|
|
||||||
if (!unusedStyleNames.empty())
|
|
||||||
{
|
{
|
||||||
typeSelector->addItems(unusedStyleNames);
|
excludeStyleNames.insert(style->getStyleName());
|
||||||
this->modifyingStyle = std::move(styles.makeUnusedStyle(unusedStyleNames[0]));
|
}
|
||||||
|
|
||||||
|
QComboBox* typeSelector = new QComboBox(this);
|
||||||
|
|
||||||
|
for (auto& pair : LayerStyle::types)
|
||||||
|
{
|
||||||
|
if (!excludeStyleNames.contains(pair.first))
|
||||||
|
{
|
||||||
|
typeSelector->addItem(pair.first);
|
||||||
|
if (!this->modifyingStyle)
|
||||||
|
{
|
||||||
|
this->modifyingStyle = std::move(pair.second());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeSelector->count() > 0)
|
||||||
|
{
|
||||||
dialogLayout->addWidget(typeSelector);
|
dialogLayout->addWidget(typeSelector);
|
||||||
this->styleContainer = new QGridLayout(this);
|
this->styleContainer = new QGridLayout(this);
|
||||||
dialogLayout->addLayout(styleContainer);
|
dialogLayout->addLayout(styleContainer);
|
||||||
|
@ -41,11 +57,11 @@ LayerStyleDialog::LayerStyleDialog(
|
||||||
this->styleWidget = this->modifyingStyle->getInputWidget();
|
this->styleWidget = this->modifyingStyle->getInputWidget();
|
||||||
this->styleWidget->setParent(this);
|
this->styleWidget->setParent(this);
|
||||||
this->styleContainer->addWidget(styleWidget);
|
this->styleContainer->addWidget(styleWidget);
|
||||||
connect(typeSelector, &QComboBox::currentTextChanged,
|
connect(typeSelector, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &LayerStyleDialog::onStyleTypeSelectorChanged);
|
this, &LayerStyleDialog::onStyleTypeSelectorChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &LayerStyleDialog::accept);
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &LayerStyleDialog::accept);
|
||||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &LayerStyleDialog::reject);
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &LayerStyleDialog::reject);
|
||||||
dialogLayout->addWidget(buttonBox);
|
dialogLayout->addWidget(buttonBox);
|
||||||
|
@ -57,7 +73,7 @@ void LayerStyleDialog::accept()
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStyleDialog::onStyleTypeSelectorChanged(const QString& current)
|
void LayerStyleDialog::onStyleTypeSelectorChanged(int index)
|
||||||
{
|
{
|
||||||
if (this->styleWidget)
|
if (this->styleWidget)
|
||||||
{
|
{
|
||||||
|
@ -65,10 +81,8 @@ void LayerStyleDialog::onStyleTypeSelectorChanged(const QString& current)
|
||||||
this->styleWidget->setParent(nullptr);
|
this->styleWidget->setParent(nullptr);
|
||||||
delete styleWidget;
|
delete styleWidget;
|
||||||
}
|
}
|
||||||
this->modifyingStyle = std::move(styles->makeUnusedStyle(current));
|
this->modifyingStyle = std::move(LayerStyle::types[index].second());
|
||||||
this->styleWidget = this->modifyingStyle->getInputWidget();
|
this->styleWidget = this->modifyingStyle->getInputWidget();
|
||||||
this->styleWidget->setParent(this);
|
this->styleWidget->setParent(this);
|
||||||
this->styleContainer->addWidget(styleWidget, 0, 0, 1, 1);
|
this->styleContainer->addWidget(styleWidget, 0, 0, 1, 1);
|
||||||
this->styleWidget->adjustSize();
|
|
||||||
this->adjustSize();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,15 @@ class LayerStyleDialog : public QDialog
|
||||||
private:
|
private:
|
||||||
QWidget* styleWidget;
|
QWidget* styleWidget;
|
||||||
QGridLayout* styleContainer;
|
QGridLayout* styleContainer;
|
||||||
LayerStyleContainer* styles;
|
|
||||||
std::unique_ptr<LayerStyle> modifyingStyle;
|
std::unique_ptr<LayerStyle> modifyingStyle;
|
||||||
public:
|
public:
|
||||||
LayerStyleDialog(
|
LayerStyleDialog(
|
||||||
LayerStyleContainer& styles,
|
QWidget* parent = nullptr,
|
||||||
std::shared_ptr<LayerStyle> existedStyle = nullptr,
|
std::shared_ptr<LayerStyle> existedStyle = nullptr,
|
||||||
QWidget* parent = nullptr
|
std::vector<std::shared_ptr<LayerStyle>>* excludeStyles = nullptr);
|
||||||
);
|
|
||||||
std::shared_ptr<LayerStyle> layerStyle;
|
std::shared_ptr<LayerStyle> layerStyle;
|
||||||
private slots:
|
private slots:
|
||||||
void onStyleTypeSelectorChanged(const QString& current);
|
void onStyleTypeSelectorChanged(int index);
|
||||||
void accept() override;
|
void accept() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include "ColorPicker.h"
|
#include "ColorPicker.h"
|
||||||
#include <qtmaterialraisedbutton.h>
|
#include <qtmaterialraisedbutton.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <lib/qtmaterialstyle.h>
|
|
||||||
|
|
||||||
|
#define radialStroke(stroke) std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(stroke->materialStroke)
|
||||||
constexpr int COLUMN_WIDTH = 0;
|
constexpr int COLUMN_WIDTH = 0;
|
||||||
constexpr int COLUMN_COLOR = 1;
|
constexpr int COLUMN_COLOR = 1;
|
||||||
constexpr int COLUMN_METALLIC = 2;
|
constexpr int COLUMN_METALLIC = 2;
|
||||||
|
@ -15,12 +15,12 @@ StrokeStyleWidget::StrokeStyleWidget(
|
||||||
QWidget* parent
|
QWidget* parent
|
||||||
) : QWidget(parent), stroke(stroke)
|
) : QWidget(parent), stroke(stroke)
|
||||||
{
|
{
|
||||||
auto* viewLayout = new QVBoxLayout(this);
|
QVBoxLayout* viewLayout = new QVBoxLayout(this);
|
||||||
this->setLayout(viewLayout);
|
this->setLayout(viewLayout);
|
||||||
|
|
||||||
initStrokeSettings();
|
initStrokeSettings();
|
||||||
auto* strokeProperties = new QWidget(this);
|
QWidget* strokeProperties = new QWidget(this);
|
||||||
auto* strokePropertiesLayout = new QHBoxLayout(strokeProperties);
|
QHBoxLayout* strokePropertiesLayout = new QHBoxLayout(strokeProperties);
|
||||||
strokePropertiesLayout->setMargin(0);
|
strokePropertiesLayout->setMargin(0);
|
||||||
|
|
||||||
strokeProperties->setLayout(strokePropertiesLayout);
|
strokeProperties->setLayout(strokePropertiesLayout);
|
||||||
|
@ -38,7 +38,7 @@ StrokeStyleWidget::StrokeStyleWidget(
|
||||||
void StrokeStyleWidget::initStrokeSettings()
|
void StrokeStyleWidget::initStrokeSettings()
|
||||||
{
|
{
|
||||||
this->enableGradual = new QtMaterialCheckBox(this);
|
this->enableGradual = new QtMaterialCheckBox(this);
|
||||||
enableGradual->setText(QStringLiteral("½¥±ä"));
|
enableGradual->setText(QStringLiteral("ÆôÓý¥±ä"));
|
||||||
enableGradual->setChecked(radialStroke(stroke)->gradual);
|
enableGradual->setChecked(radialStroke(stroke)->gradual);
|
||||||
connect(enableGradual, &QtMaterialCheckBox::toggled, [this](bool checked) {
|
connect(enableGradual, &QtMaterialCheckBox::toggled, [this](bool checked) {
|
||||||
radialStroke(this->stroke)->gradual = checked;
|
radialStroke(this->stroke)->gradual = checked;
|
||||||
|
@ -72,7 +72,7 @@ void StrokeStyleWidget::initStrokeSettings()
|
||||||
this->widthField = new QtMaterialTextField(this);
|
this->widthField = new QtMaterialTextField(this);
|
||||||
widthField->setLabel(QStringLiteral("±¾²àÃè±ß¿í¶È"));
|
widthField->setLabel(QStringLiteral("±¾²àÃè±ß¿í¶È"));
|
||||||
widthField->setText(QString::number(stroke->halfWidth));
|
widthField->setText(QString::number(stroke->halfWidth));
|
||||||
auto* widthValidator = new QDoubleValidator(0.1, std::numeric_limits<float>::max(), 3, widthField);
|
QDoubleValidator* widthValidator = new QDoubleValidator(0.1, std::numeric_limits<float>::max(), 3, widthField);
|
||||||
widthValidator->setNotation(QDoubleValidator::StandardNotation);
|
widthValidator->setNotation(QDoubleValidator::StandardNotation);
|
||||||
widthField->setValidator(widthValidator);
|
widthField->setValidator(widthValidator);
|
||||||
connect(widthField, &QtMaterialTextField::textChanged, [this](const QString& changed) {
|
connect(widthField, &QtMaterialTextField::textChanged, [this](const QString& changed) {
|
||||||
|
@ -106,12 +106,8 @@ void StrokeStyleWidget::initTable(std::shared_ptr<Renderer::StrokeRadialGradient
|
||||||
}
|
}
|
||||||
// ÐÂÔö°´Å¥
|
// ÐÂÔö°´Å¥
|
||||||
QtMaterialRaisedButton* addButton = new QtMaterialRaisedButton("+", strokeTable);
|
QtMaterialRaisedButton* addButton = new QtMaterialRaisedButton("+", strokeTable);
|
||||||
addButton->setBackgroundColor(QtMaterialStyle::instance().themeColor("primary1"));
|
|
||||||
strokeTable->setSpan(row, 0, 1, 5);
|
strokeTable->setSpan(row, 0, 1, 5);
|
||||||
strokeTable->setCellWidget(row, 0, addButton);
|
strokeTable->setCellWidget(row, 0, addButton);
|
||||||
strokeTable->setMinimumHeight(strokeTable->rowHeight(row) * 5);
|
|
||||||
strokeTable->setMinimumWidth(strokeTable->sizeHint().width());
|
|
||||||
addButton->setFixedHeight(strokeTable->rowHeight(row));
|
|
||||||
connect(addButton, &QtMaterialRaisedButton::clicked, [this]() {
|
connect(addButton, &QtMaterialRaisedButton::clicked, [this]() {
|
||||||
handlingRowInsert = true;
|
handlingRowInsert = true;
|
||||||
auto materialMap = &(radialStroke(this->stroke)->materialMap);
|
auto materialMap = &(radialStroke(this->stroke)->materialMap);
|
||||||
|
@ -133,37 +129,37 @@ void StrokeStyleWidget::initTable(std::shared_ptr<Renderer::StrokeRadialGradient
|
||||||
this->strokeTable->update();
|
this->strokeTable->update();
|
||||||
handlingRowInsert = false;
|
handlingRowInsert = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(strokeTable, &QTableWidget::currentItemChanged, this, &StrokeStyleWidget::onCurrentItemChanged);
|
connect(strokeTable, &QTableWidget::currentItemChanged, this, &StrokeStyleWidget::onCurrentItemChanged);
|
||||||
connect(strokeTable, &QTableWidget::cellChanged, this, &StrokeStyleWidget::onCellChanged);
|
connect(strokeTable, &QTableWidget::cellChanged, this, &StrokeStyleWidget::onCellChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StrokeStyleWidget::setTableRow(int row, float width, Renderer::Material& material)
|
void StrokeStyleWidget::setTableRow(int row, float width, Renderer::Material& material)
|
||||||
{
|
{
|
||||||
auto* widthItem = new QTableWidgetItem;
|
QTableWidgetItem* widthItem = new QTableWidgetItem;
|
||||||
widthItem->setData(Qt::EditRole, width);
|
widthItem->setData(Qt::EditRole, width);
|
||||||
strokeTable->setItem(row, COLUMN_WIDTH, widthItem);
|
strokeTable->setItem(row, COLUMN_WIDTH, widthItem);
|
||||||
|
|
||||||
QColor* colorPtr = &(material.color);
|
QColor* colorPtr = &(material.color);
|
||||||
auto* colorItem = new QTableWidgetItem;
|
QTableWidgetItem* colorItem = new QTableWidgetItem;
|
||||||
colorItem->setData(Qt::DisplayRole, *colorPtr);
|
colorItem->setData(Qt::DisplayRole, *colorPtr);
|
||||||
strokeTable->setItem(row, COLUMN_COLOR, colorItem);
|
strokeTable->setItem(row, COLUMN_COLOR, colorItem);
|
||||||
auto* colorPicker = new ColorPicker(*colorPtr, strokeTable);
|
ColorPicker* colorPicker = new ColorPicker(*colorPtr, strokeTable);
|
||||||
strokeTable->setCellWidget(row, COLUMN_COLOR, colorPicker);
|
strokeTable->setCellWidget(row, COLUMN_COLOR, colorPicker);
|
||||||
connect(colorPicker, &ColorPicker::colorChanged, [this, colorPtr](QColor color) {
|
connect(colorPicker, &ColorPicker::colorChanged, [this, colorPtr](QColor color) {
|
||||||
*colorPtr = color;
|
*colorPtr = color;
|
||||||
this->strokeTable->update();
|
this->strokeTable->update();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto* metallicItem = new QTableWidgetItem;
|
QTableWidgetItem* metallicItem = new QTableWidgetItem;
|
||||||
metallicItem->setData(Qt::EditRole, material.metallicF());
|
metallicItem->setData(Qt::EditRole, material.metallicF());
|
||||||
strokeTable->setItem(row, COLUMN_METALLIC, metallicItem);
|
strokeTable->setItem(row, COLUMN_METALLIC, metallicItem);
|
||||||
|
|
||||||
auto* roughnessItem = new QTableWidgetItem;
|
QTableWidgetItem* roughnessItem = new QTableWidgetItem;
|
||||||
roughnessItem->setData(Qt::EditRole, material.roughnessF());
|
roughnessItem->setData(Qt::EditRole, material.roughnessF());
|
||||||
strokeTable->setItem(row, COLUMN_ROUGHNESS, roughnessItem);
|
strokeTable->setItem(row, COLUMN_ROUGHNESS, roughnessItem);
|
||||||
|
|
||||||
auto* removeButton = new QtMaterialRaisedButton("-", strokeTable);
|
QtMaterialRaisedButton* removeButton = new QtMaterialRaisedButton("-", strokeTable);
|
||||||
removeButton->setBackgroundColor(QtMaterialStyle::instance().themeColor("primary1"));
|
|
||||||
removeButton->setFixedSize(20, 20);
|
removeButton->setFixedSize(20, 20);
|
||||||
strokeTable->setCellWidget(row, COLUMN_OPERATIONS, removeButton);
|
strokeTable->setCellWidget(row, COLUMN_OPERATIONS, removeButton);
|
||||||
connect(removeButton, &QtMaterialRaisedButton::clicked, [this, row]() {
|
connect(removeButton, &QtMaterialRaisedButton::clicked, [this, row]() {
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
#include "EditorWidgetItem.h"
|
#include "EditorWidgetItem.h"
|
||||||
#include "EditorWidget.h"
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(parent)
|
EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
QImage x;
|
QImage x;
|
||||||
this->parent = parent;
|
|
||||||
displayLayer = nullptr;
|
displayLayer = nullptr;
|
||||||
displayElement = nullptr;
|
displayElement = nullptr;
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
@ -15,12 +12,9 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
this->filePath = filePath;
|
this->filePath = filePath;
|
||||||
layerInfoDisplayWidget = dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(0));
|
layerInfoDisplayWidget = dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(0));
|
||||||
elementInfoDisplayWidget = dynamic_cast<ElementPoolWidget *>(tabWidget->widget(1));
|
elementInfoDisplayWidget = dynamic_cast<ElementPoolWidget *>(tabWidget->widget(1));
|
||||||
editorSettingWidget = dynamic_cast<EditorSettingWidget*>(tabWidget->widget(2));
|
|
||||||
elementInfoDisplayWidget->enableEdit();
|
elementInfoDisplayWidget->enableEdit();
|
||||||
qDebug() << layerInfoDisplayWidget;
|
qDebug() << layerInfoDisplayWidget;
|
||||||
qDebug() << elementInfoDisplayWidget;
|
qDebug() << elementInfoDisplayWidget;
|
||||||
connect(editorSettingWidget, &EditorSettingWidget::backgroundColorChanged, this, &EditorWidgetItem::handleBackgroundColorChange);
|
|
||||||
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(previewWindow, &PreviewWindow::layerInfoChanged, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
||||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
||||||
|
@ -59,15 +53,6 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
treeWidget->refresh();
|
treeWidget->refresh();
|
||||||
treeWidget->addTopLevelItem(treeWidget->root->getQTreeItem());
|
treeWidget->addTopLevelItem(treeWidget->root->getQTreeItem());
|
||||||
}
|
}
|
||||||
this->backgroundColor = source.value("background-color").toVariant().value<QColor>();
|
|
||||||
this->projectName = source.value("project-name").toString();
|
|
||||||
qDebug() << this->backgroundColor;
|
|
||||||
qDebug() << this->projectName;
|
|
||||||
QTimer::singleShot(300, this, [this]() {
|
|
||||||
handleBackgroundColorChange(this->backgroundColor);
|
|
||||||
handleProjectNameChange(this->projectName);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorWidgetItem::~EditorWidgetItem()
|
EditorWidgetItem::~EditorWidgetItem()
|
||||||
|
@ -115,28 +100,9 @@ void EditorWidgetItem::saveImpl(QString filePath) const
|
||||||
json.insert("height", 1080);
|
json.insert("height", 1080);
|
||||||
json.insert("root-layer", source1.value("root-layer"));
|
json.insert("root-layer", source1.value("root-layer"));
|
||||||
json.insert("elements", source2.value("elements"));
|
json.insert("elements", source2.value("elements"));
|
||||||
json.insert("project-name", this->projectName);
|
|
||||||
json.insert("background-color", QJsonValue::fromVariant(QVariant::fromValue(this->backgroundColor)));
|
|
||||||
QJsonDocument doc(json);
|
QJsonDocument doc(json);
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
file.write(doc.toJson());
|
file.write(doc.toJson());
|
||||||
file.close();
|
file.close();
|
||||||
}
|
|
||||||
|
|
||||||
void EditorWidgetItem::handleBackgroundColorChange(QColor color)
|
|
||||||
{
|
|
||||||
this->backgroundColor = color;
|
|
||||||
previewWindow->setBackgroundColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorWidgetItem::handleProjectNameChange(QString name)
|
|
||||||
{
|
|
||||||
this->projectName = name;
|
|
||||||
auto parent = dynamic_cast<EditorWidget*>(this->parent);
|
|
||||||
qDebug() << name << " " << parent<<" "<<this;
|
|
||||||
if (parent != nullptr)
|
|
||||||
{
|
|
||||||
parent->renameTab(this, name);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -6,7 +6,6 @@
|
||||||
#include "LayerManager.h"
|
#include "LayerManager.h"
|
||||||
#include "LayerTreeWidget.h"
|
#include "LayerTreeWidget.h"
|
||||||
#include "PreviewWindow.h"
|
#include "PreviewWindow.h"
|
||||||
#include "EditorSettingWidget.h"
|
|
||||||
#include "ui_EditorWidgetItem.h"
|
#include "ui_EditorWidgetItem.h"
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
@ -27,17 +26,11 @@ class EditorWidgetItem : public QWidget
|
||||||
QTabWidget *tabWidget;
|
QTabWidget *tabWidget;
|
||||||
InfoDisplayWidget* layerInfoDisplayWidget;
|
InfoDisplayWidget* layerInfoDisplayWidget;
|
||||||
ElementPoolWidget* elementInfoDisplayWidget;
|
ElementPoolWidget* elementInfoDisplayWidget;
|
||||||
EditorSettingWidget* editorSettingWidget;
|
|
||||||
// QT DATA PART
|
// QT DATA PART
|
||||||
LayerWrapper *displayLayer;
|
LayerWrapper *displayLayer;
|
||||||
GraphicElement *displayElement;
|
GraphicElement *displayElement;
|
||||||
QWidget* parent;
|
|
||||||
void saveImpl(QString filePath)const;
|
|
||||||
public:
|
|
||||||
// PROJECT INFO
|
|
||||||
QString filePath;
|
QString filePath;
|
||||||
QString projectName;
|
void saveImpl(QString filePath)const;
|
||||||
QColor backgroundColor;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EditorWidgetItem(QString filePath, QWidget *parent = nullptr);
|
EditorWidgetItem(QString filePath, QWidget *parent = nullptr);
|
||||||
|
@ -45,8 +38,6 @@ public:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
void save() const;
|
void save() const;
|
||||||
void saveAs(QString filePath)const;
|
void saveAs(QString filePath)const;
|
||||||
void handleBackgroundColorChange(QColor color);
|
|
||||||
void handleProjectNameChange(QString name);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onLayerChange(LayerWrapper *layer);
|
void onLayerChange(LayerWrapper *layer);
|
||||||
|
|
|
@ -48,11 +48,11 @@ PixelPath GroupElement::getPaintObject() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: apply styles and send back
|
//TODO: apply styles and send back
|
||||||
PixelPath SimpleElement::getPaintObject(const LayerStyleContainer& styles) const {
|
PixelPath SimpleElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>* styles) const {
|
||||||
return this->getPaintObject();
|
return this->getPaintObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
PixelPath GroupElement::getPaintObject(const LayerStyleContainer& styles) const {
|
PixelPath GroupElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>* styles) const {
|
||||||
return getPaintObject();
|
return getPaintObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ QJsonObject GroupElement::toJson() const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles)
|
void SimpleElement::paint(QPainter* painter, QTransform transform, const vector<std::shared_ptr<LayerStyle>> &styles)
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setTransform(transform);
|
painter->setTransform(transform);
|
||||||
|
@ -102,14 +102,14 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerSt
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double angle = atan(transform.m12() / transform.m11());
|
Renderer::ElementStyleStrokeDemo demo(2);
|
||||||
double maxScale;
|
std::shared_ptr<Renderer::ElementStyle> style;
|
||||||
if (fabs(cos(angle))>1e-5)
|
style = styles[0];
|
||||||
maxScale = std::max(fabs(transform.m11() / cos(angle)), fabs(transform.m22() / cos(angle)));
|
QVector2D scale(transform.m11(), transform.m22());
|
||||||
else
|
scale /= transform.m33();
|
||||||
maxScale = std::max(fabs(transform.m12() / sin(angle)), fabs(transform.m21() / sin(angle)));
|
double maxScale = std::max(scale.x(), scale.y());
|
||||||
double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
|
double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
|
||||||
auto [img, mov] = Renderer::ElementRenderer::instance()->drawElement(painterPath, styles, pixelRatio);
|
auto [img, mov] = Renderer::ElementRenderer::instance()->drawElement(painterPath, *style, pixelRatio);
|
||||||
transform.translate(mov.x(), mov.y());
|
transform.translate(mov.x(), mov.y());
|
||||||
painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio));
|
painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio));
|
||||||
painter->drawImage(0, 0, img);
|
painter->drawImage(0, 0, img);
|
||||||
|
@ -117,7 +117,7 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerSt
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles)
|
void GroupElement::paint(QPainter* painter, QTransform transform, const vector<std::shared_ptr<LayerStyle>> &styles)
|
||||||
{
|
{
|
||||||
sourceLayer->paint(painter, transform);
|
sourceLayer->paint(painter, transform);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ void GroupElement::paint(QPainter* painter, QTransform transform, const LayerSty
|
||||||
|
|
||||||
QPixmap SimpleElement::getPreview(QSize size)
|
QPixmap SimpleElement::getPreview(QSize size)
|
||||||
{
|
{
|
||||||
QPixmap result(size + QSize(5, 5));
|
QPixmap result(size + QSize(5,5));
|
||||||
QPainter painter(&result);
|
QPainter painter(&result);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
@ -143,7 +143,7 @@ QPixmap GroupElement::getPreview(QSize size)
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
sourceLayer->paint(&painter, QTransform(), true);
|
sourceLayer->paint(&painter, QTransform(), true);
|
||||||
painter.end();
|
painter.end();
|
||||||
QRect rect(cache.getBoundingRect().toRect());
|
QRect rect (cache.getBoundingRect().toRect());
|
||||||
rect.setTopLeft(rect.topLeft() - QPoint(5, 5));
|
rect.setTopLeft(rect.topLeft() - QPoint(5, 5));
|
||||||
rect.setBottomRight(rect.bottomRight() + QPoint(5, 5));
|
rect.setBottomRight(rect.bottomRight() + QPoint(5, 5));
|
||||||
result = result.copy(rect);
|
result = result.copy(rect);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "LayerWrapper.h"
|
#include "LayerWrapper.h"
|
||||||
#include "LayerStyle.h"
|
#include "LayerStyle.h"
|
||||||
|
#include <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
@ -26,8 +27,8 @@ public:
|
||||||
// TODO: ¸ÄΪBitmapPath
|
// TODO: ¸ÄΪBitmapPath
|
||||||
virtual QJsonObject toJson() const = 0;
|
virtual QJsonObject toJson() const = 0;
|
||||||
virtual PixelPath getPaintObject() const = 0;
|
virtual PixelPath getPaintObject() const = 0;
|
||||||
virtual PixelPath getPaintObject(const LayerStyleContainer& styles) const = 0;
|
virtual PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const = 0;
|
||||||
virtual void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) = 0;
|
virtual void paint(QPainter* painter, QTransform transform, const std::vector<std::shared_ptr<LayerStyle>> &styles) = 0;
|
||||||
virtual QPixmap getPreview(QSize size) = 0;
|
virtual QPixmap getPreview(QSize size) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,8 +47,8 @@ public:
|
||||||
SimpleElement(QString filePath);
|
SimpleElement(QString filePath);
|
||||||
~SimpleElement() = default;
|
~SimpleElement() = default;
|
||||||
PixelPath getPaintObject() const override;
|
PixelPath getPaintObject() const override;
|
||||||
PixelPath getPaintObject(const LayerStyleContainer& styles) const override;
|
PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const override;
|
||||||
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
void paint(QPainter* painter, QTransform transform, const std::vector<std::shared_ptr<LayerStyle>> &styles) override;
|
||||||
QPixmap getPreview(QSize size) override;
|
QPixmap getPreview(QSize size) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,9 +63,9 @@ public:
|
||||||
GroupElement(FolderLayerWrapper* mSourceLayer);
|
GroupElement(FolderLayerWrapper* mSourceLayer);
|
||||||
~GroupElement() = default;
|
~GroupElement() = default;
|
||||||
PixelPath getPaintObject() const override;
|
PixelPath getPaintObject() const override;
|
||||||
PixelPath getPaintObject(const LayerStyleContainer& styles) const override;
|
PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const override;
|
||||||
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
||||||
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
void paint(QPainter* painter, QTransform transform, const std::vector<std::shared_ptr<LayerStyle>> &styles) override;
|
||||||
QPixmap getPreview(QSize size) override;
|
QPixmap getPreview(QSize size) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,29 +9,31 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#define _USE_JOIN_VIEW_INPUT_RANGE
|
|
||||||
#include <QJsonArray>
|
const std::vector<std::pair<QString, std::function<std::unique_ptr<LayerStyle>()>>> LayerStyle::types = {
|
||||||
#include <ranges>
|
{
|
||||||
|
QStringLiteral("描边"),
|
||||||
|
[]() { return std::make_unique<StrokeElementLayerStyle>(); }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
QStringLiteral("填充"),
|
||||||
|
[]() { return std::make_unique<FillElementLayerStyle>(); }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
std::vector<Renderer::BaseStyle> StrokeElementLayerStyle::toBaseStyles() const
|
std::vector<Renderer::BaseStyle> StrokeElementLayerStyle::toBaseStyles() const
|
||||||
{
|
{
|
||||||
std::vector<Renderer::BaseStyle> baseStyles;
|
std::vector<Renderer::BaseStyle> baseStyles;
|
||||||
if (enableEachSideIndependent)
|
if (enableEachSideIndependent)
|
||||||
{
|
{
|
||||||
if (!radialStroke(strokePair.first)->materialMap.empty())
|
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
||||||
{
|
strokePair.first));
|
||||||
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
||||||
strokePair.first));
|
strokePair.second));
|
||||||
}
|
|
||||||
if (!radialStroke(strokePair.second)->materialMap.empty())
|
|
||||||
{
|
|
||||||
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
|
||||||
strokePair.second));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!radialStroke(strokePair.first)->materialMap.empty())
|
else
|
||||||
{
|
{
|
||||||
const auto material = std::shared_ptr(std::move(strokePair.first->clone()));
|
auto material = std::shared_ptr<MaterialStyle>(std::move(strokePair.first->clone()));
|
||||||
std::dynamic_pointer_cast<MaterialStyleStroke>(material)->strokeType = Renderer::StrokeType::kBothSides;
|
std::dynamic_pointer_cast<MaterialStyleStroke>(material)->strokeType = Renderer::StrokeType::kBothSides;
|
||||||
|
|
||||||
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(), material));
|
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(), material));
|
||||||
|
@ -39,23 +41,50 @@ std::vector<Renderer::BaseStyle> StrokeElementLayerStyle::toBaseStyles() const
|
||||||
return baseStyles;
|
return baseStyles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString StrokeElementLayerStyle::getStyleName() const
|
||||||
|
{
|
||||||
|
return QStringLiteral("描边");
|
||||||
|
}
|
||||||
|
|
||||||
QWidget* StrokeElementLayerStyle::getInputWidget()
|
QWidget* StrokeElementLayerStyle::getInputWidget()
|
||||||
{
|
{
|
||||||
auto* w = new QWidget;
|
if (this->strokePair.first == nullptr)
|
||||||
auto* materialList = new QListView;
|
{
|
||||||
|
auto materialMap = std::map<float, Renderer::Material>();
|
||||||
|
this->strokePair.first = std::shared_ptr<Renderer::MaterialStyleStroke>(new Renderer::MaterialStyleStroke(
|
||||||
|
15,
|
||||||
|
Renderer::StrokeType::kLeftSide, Renderer::StrokeEndType::kFlat,
|
||||||
|
std::shared_ptr<Renderer::MaterialStroke>(new Renderer::StrokeRadialGradient(
|
||||||
|
materialMap, false
|
||||||
|
))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if (this->strokePair.second == nullptr)
|
||||||
|
{
|
||||||
|
auto materialMap = std::map<float, Renderer::Material>();
|
||||||
|
this->strokePair.second = std::shared_ptr<Renderer::MaterialStyleStroke>(new Renderer::MaterialStyleStroke(
|
||||||
|
15,
|
||||||
|
Renderer::StrokeType::kRightSide, Renderer::StrokeEndType::kFlat,
|
||||||
|
std::shared_ptr<Renderer::MaterialStroke>(new Renderer::StrokeRadialGradient(
|
||||||
|
materialMap, false
|
||||||
|
))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
QWidget* w = new QWidget;
|
||||||
|
QListView* materialList = new QListView;
|
||||||
|
|
||||||
auto* layout = new QVBoxLayout(w);
|
QVBoxLayout* layout = new QVBoxLayout(w);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
|
|
||||||
auto* leftStrokeView = new StrokeStyleWidget(this->strokePair.first, w);
|
StrokeStyleWidget* leftStrokeView = new StrokeStyleWidget(this->strokePair.first, w);
|
||||||
layout->addWidget(leftStrokeView);
|
layout->addWidget(leftStrokeView);
|
||||||
|
|
||||||
auto* checkEachSideIndependent = new QtMaterialCheckBox(w);
|
QtMaterialCheckBox* checkEachSideIndependent = new QtMaterialCheckBox(w);
|
||||||
checkEachSideIndependent->setText(QStringLiteral("ÓÒ²à¶ÀÁ¢Ãè±ß"));
|
checkEachSideIndependent->setText(QStringLiteral("启用两侧独立描边"));
|
||||||
checkEachSideIndependent->setChecked(enableEachSideIndependent);
|
checkEachSideIndependent->setChecked(enableEachSideIndependent);
|
||||||
layout->addWidget(checkEachSideIndependent);
|
layout->addWidget(checkEachSideIndependent);
|
||||||
|
|
||||||
auto* rightStrokeView = new StrokeStyleWidget(this->strokePair.second, w);
|
StrokeStyleWidget* rightStrokeView = new StrokeStyleWidget(this->strokePair.second, w);
|
||||||
layout->addWidget(rightStrokeView);
|
layout->addWidget(rightStrokeView);
|
||||||
rightStrokeView->setDisabled(!this->enableEachSideIndependent);
|
rightStrokeView->setDisabled(!this->enableEachSideIndependent);
|
||||||
|
|
||||||
|
@ -68,180 +97,39 @@ QWidget* StrokeElementLayerStyle::getInputWidget()
|
||||||
|
|
||||||
QWidget* StrokeElementLayerStyle::getListDisplayWidget() const
|
QWidget* StrokeElementLayerStyle::getListDisplayWidget() const
|
||||||
{
|
{
|
||||||
auto* w = new QWidget;
|
QWidget* w = new QWidget;
|
||||||
auto* name = new QLabel(w);
|
QLabel* name = new QLabel(w);
|
||||||
name->setText(QStringLiteral("Ãè±ß"));
|
name->setText(QStringLiteral("Ãè±ß"));
|
||||||
auto* layout = new QHBoxLayout(w);
|
QHBoxLayout* layout = new QHBoxLayout(w);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->addWidget(name);
|
layout->addWidget(name);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStyleContainer::computeNewHash()
|
|
||||||
{
|
|
||||||
hash = 0;
|
|
||||||
for (auto& f : styles
|
|
||||||
| std::views::values
|
|
||||||
| std::views::transform(&LayerStyle::toBaseStyles)
|
|
||||||
| std::views::join
|
|
||||||
| std::views::transform(&Renderer::BaseStyle::material)
|
|
||||||
| std::views::transform(&MaterialStyle::encoded)
|
|
||||||
| std::views::join)
|
|
||||||
{
|
|
||||||
const unsigned int u = *reinterpret_cast<unsigned int*>(&f);
|
|
||||||
hash ^= u + 0x9e3779b9 + (hash << 6) + (hash >> 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LayerStyleContainer LayerStyleContainer::fromJson(const QJsonArray& jsonArray)
|
|
||||||
{
|
|
||||||
LayerStyleContainer container;
|
|
||||||
for (const auto& style : jsonArray)
|
|
||||||
{
|
|
||||||
container.useStyle(LayerStyle::fromJson(style.toObject()));
|
|
||||||
}
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
LayerStyleContainer::LayerStyleContainer() : hash(0)
|
|
||||||
{
|
|
||||||
unusedStyles = { {
|
|
||||||
StrokeElementLayerStyle::displayName(),
|
|
||||||
[] { return std::make_unique<StrokeElementLayerStyle>(); }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
FillElementLayerStyle::displayName(),
|
|
||||||
[] { return std::make_unique<FillElementLayerStyle>(); }
|
|
||||||
} };
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Renderer::BaseStyle> LayerStyleContainer::toBaseStyles() const
|
|
||||||
{
|
|
||||||
std::vector<Renderer::BaseStyle> result;
|
|
||||||
for (const auto& style : styles | std::views::values)
|
|
||||||
{
|
|
||||||
auto baseStyles = style->toBaseStyles();
|
|
||||||
result.insert(result.end(),
|
|
||||||
std::make_move_iterator(baseStyles.begin()),
|
|
||||||
std::make_move_iterator(baseStyles.end()));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonArray LayerStyleContainer::toJson() const
|
|
||||||
{
|
|
||||||
QJsonArray json;
|
|
||||||
for (const auto& style : styles | std::views::values)
|
|
||||||
{
|
|
||||||
json.append(style->toJson());
|
|
||||||
}
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList LayerStyleContainer::unusedStyleNames() const
|
|
||||||
{
|
|
||||||
QStringList result;
|
|
||||||
for(const auto& name : unusedStyles | std::views::keys)
|
|
||||||
{
|
|
||||||
result << name;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<LayerStyle> LayerStyleContainer::makeUnusedStyle(const QString& styleName) const
|
|
||||||
{
|
|
||||||
return unusedStyles.at(styleName)();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LayerStyleContainer::empty() const
|
|
||||||
{
|
|
||||||
return styles.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LayerStyleContainer::full() const
|
|
||||||
{
|
|
||||||
return unusedStyles.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<QString, std::shared_ptr<LayerStyle>>::iterator LayerStyleContainer::begin()
|
|
||||||
{
|
|
||||||
return styles.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<QString, std::shared_ptr<LayerStyle>>::iterator LayerStyleContainer::end()
|
|
||||||
{
|
|
||||||
return styles.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LayerStyleContainer::useStyle(const std::shared_ptr<LayerStyle>& style)
|
|
||||||
{
|
|
||||||
auto styleNode = unusedStyles.extract(style->getDisplayName());
|
|
||||||
if (styleNode.empty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
styles[styleNode.key()] = style;
|
|
||||||
usedStyles.insert(std::move(styleNode));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LayerStyleContainer::dropStyle(const QString& styleName)
|
|
||||||
{
|
|
||||||
auto styleNode = usedStyles.extract(styleName);
|
|
||||||
if (styleNode.empty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
styles.erase(styleName);
|
|
||||||
unusedStyles.insert(std::move(styleNode));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline size_t LayerStyleContainer::getHash() const
|
|
||||||
{
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
StrokeElementLayerStyle::StrokeElementLayerStyle()
|
|
||||||
{
|
|
||||||
const auto materialMap = std::map<float, Renderer::Material>();
|
|
||||||
this->strokePair.first = std::make_shared<MaterialStyleStroke>(
|
|
||||||
7,
|
|
||||||
Renderer::StrokeType::kLeftSide, Renderer::StrokeEndType::kFlat,
|
|
||||||
std::make_shared<Renderer::StrokeRadialGradient>(materialMap, false)
|
|
||||||
);
|
|
||||||
|
|
||||||
this->strokePair.second = std::make_shared<MaterialStyleStroke>(
|
|
||||||
7,
|
|
||||||
Renderer::StrokeType::kRightSide, Renderer::StrokeEndType::kFlat,
|
|
||||||
std::make_shared<Renderer::StrokeRadialGradient>(materialMap, false)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
StrokeElementLayerStyle::StrokeElementLayerStyle(PMaterialStyleStroke left, PMaterialStyleStroke right)
|
StrokeElementLayerStyle::StrokeElementLayerStyle(PMaterialStyleStroke left, PMaterialStyleStroke right)
|
||||||
{
|
{
|
||||||
this->strokePair.first = left;
|
this->strokePair.first = left;
|
||||||
this->strokePair.second = right ? right : std::static_pointer_cast<MaterialStyleStroke>(
|
this->strokePair.second = right ? right : std::dynamic_pointer_cast<MaterialStyleStroke>(
|
||||||
std::shared_ptr(std::move(left->clone()))
|
std::shared_ptr<Renderer::MaterialStyle>(std::move(left->clone()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
StrokeElementLayerStyle::StrokeElementLayerStyle(const StrokeElementLayerStyle& other)
|
StrokeElementLayerStyle::StrokeElementLayerStyle(const StrokeElementLayerStyle& other)
|
||||||
{
|
{
|
||||||
strokePair.first = std::static_pointer_cast<MaterialStyleStroke>(
|
strokePair.first = std::dynamic_pointer_cast<MaterialStyleStroke>(
|
||||||
std::shared_ptr(std::move(other.strokePair.first->clone()))
|
std::shared_ptr<Renderer::MaterialStyle>(std::move(other.strokePair.first->clone()))
|
||||||
);
|
);
|
||||||
strokePair.second = std::static_pointer_cast<MaterialStyleStroke>(
|
strokePair.second = std::dynamic_pointer_cast<MaterialStyleStroke>(
|
||||||
std::shared_ptr(std::move(other.strokePair.second->clone()))
|
std::shared_ptr<Renderer::MaterialStyle>(std::move(other.strokePair.second->clone()))
|
||||||
);
|
);
|
||||||
enableEachSideIndependent = other.enableEachSideIndependent;
|
enableEachSideIndependent = other.enableEachSideIndependent;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject StrokeElementLayerStyle::toJson() const
|
QJsonObject StrokeElementLayerStyle::toJson() const
|
||||||
{
|
{
|
||||||
|
// todo: 修改打开逻辑
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
json["type"] = typeName();
|
json["type"] = getTypeName();
|
||||||
json["enableEachSideIndependent"] = enableEachSideIndependent;
|
json["enableEachSideIndependent"] = enableEachSideIndependent;
|
||||||
json["left"] = EncodeUtil::toBase64<GLfloat>(strokePair.first->encoded());
|
json["left"] = EncodeUtil::toBase64<GLfloat>(strokePair.first->encoded());
|
||||||
json["right"] = EncodeUtil::toBase64<GLfloat>(strokePair.second->encoded());
|
json["right"] = EncodeUtil::toBase64<GLfloat>(strokePair.second->encoded());
|
||||||
|
@ -255,24 +143,28 @@ std::unique_ptr<LayerStyle> StrokeElementLayerStyle::clone() const
|
||||||
|
|
||||||
std::vector<Renderer::BaseStyle> FillElementLayerStyle::toBaseStyles() const
|
std::vector<Renderer::BaseStyle> FillElementLayerStyle::toBaseStyles() const
|
||||||
{
|
{
|
||||||
// TODO: implement
|
|
||||||
return std::vector<Renderer::BaseStyle>();
|
return std::vector<Renderer::BaseStyle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString FillElementLayerStyle::getStyleName() const
|
||||||
|
{
|
||||||
|
return QStringLiteral("填充");
|
||||||
|
}
|
||||||
|
|
||||||
QWidget* FillElementLayerStyle::getInputWidget()
|
QWidget* FillElementLayerStyle::getInputWidget()
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
auto* name = new QLineEdit;
|
QLineEdit* name = new QLineEdit;
|
||||||
name->setText(QStringLiteral("Ìî³ä"));
|
name->setText(QStringLiteral("Ìî³ä"));
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* FillElementLayerStyle::getListDisplayWidget() const
|
QWidget* FillElementLayerStyle::getListDisplayWidget() const
|
||||||
{
|
{
|
||||||
auto* w = new QWidget;
|
QWidget* w = new QWidget;
|
||||||
auto* name = new QLabel(w);
|
QLabel* name = new QLabel(w);
|
||||||
name->setText(QStringLiteral("Ìî³ä"));
|
name->setText(QStringLiteral("Ìî³ä"));
|
||||||
auto* layout = new QHBoxLayout(w);
|
QHBoxLayout* layout = new QHBoxLayout(w);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->addWidget(name);
|
layout->addWidget(name);
|
||||||
return w;
|
return w;
|
||||||
|
@ -300,20 +192,20 @@ std::unique_ptr<LayerStyle> FillElementLayerStyle::clone() const
|
||||||
std::unique_ptr<LayerStyle> LayerStyle::fromJson(const QJsonObject& json)
|
std::unique_ptr<LayerStyle> LayerStyle::fromJson(const QJsonObject& json)
|
||||||
{
|
{
|
||||||
QString type = json["type"].toString();
|
QString type = json["type"].toString();
|
||||||
if (type == StrokeElementLayerStyle::typeName())
|
if (type == StrokeElementLayerStyle::getTypeName())
|
||||||
{
|
{
|
||||||
auto ptr = std::make_unique<StrokeElementLayerStyle>(
|
auto ptr = std::make_unique<StrokeElementLayerStyle>(
|
||||||
std::static_pointer_cast<MaterialStyleStroke>(
|
std::dynamic_pointer_cast<MaterialStyleStroke>(
|
||||||
std::shared_ptr(std::move(MaterialStyle::decoded(EncodeUtil::fromBase64<GLfloat>(json["left"].toString()))))
|
std::shared_ptr<Renderer::MaterialStyle>(std::move(Renderer::MaterialStyle::decoded(EncodeUtil::fromBase64<GLfloat>(json["left"].toString()))))
|
||||||
),
|
),
|
||||||
std::static_pointer_cast<MaterialStyleStroke>(
|
std::dynamic_pointer_cast<MaterialStyleStroke>(
|
||||||
std::shared_ptr(std::move(MaterialStyle::decoded(EncodeUtil::fromBase64<GLfloat>(json["right"].toString()))))
|
std::shared_ptr<Renderer::MaterialStyle>(std::move(Renderer::MaterialStyle::decoded(EncodeUtil::fromBase64<GLfloat>(json["right"].toString()))))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
ptr->enableEachSideIndependent = json["enableEachSideIndependent"].toBool();
|
ptr->enableEachSideIndependent = json["enableEachSideIndependent"].toBool();
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
else if (type == FillElementLayerStyle::typeName())
|
else if (type == FillElementLayerStyle::getTypeName())
|
||||||
{
|
{
|
||||||
return std::make_unique<FillElementLayerStyle>();
|
return std::make_unique<FillElementLayerStyle>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <map>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <set>
|
#include <QWidget>
|
||||||
#include <map>
|
#include <QObject>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
|
||||||
#include "../Renderer/Painting/ElementStyle.h"
|
#include "../Renderer/Painting/ElementStyle.h"
|
||||||
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
||||||
#include "../Renderer/Painting/MaterialStyleFill.h"
|
#include "../Renderer/Painting/MaterialStyleFill.h"
|
||||||
|
@ -13,90 +13,64 @@
|
||||||
using Renderer::MaterialStyle;
|
using Renderer::MaterialStyle;
|
||||||
using Renderer::MaterialStyleStroke;
|
using Renderer::MaterialStyleStroke;
|
||||||
|
|
||||||
#define STYLE_NAME(display_name, type_name) \
|
#define STYLE_TYPENAME(name) static QString getTypeName() { return name; }
|
||||||
static QString displayName() { return QStringLiteral(display_name); } \
|
|
||||||
QString getDisplayName() const override { return QStringLiteral(display_name); } \
|
|
||||||
static QString typeName() { return type_name; }
|
|
||||||
#define radialStroke(stroke) std::static_pointer_cast<Renderer::StrokeRadialGradient>(stroke->materialStroke)
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在进行Style的添加时,首先创建空对象,然后直接调用getInputWidget()方法
|
||||||
|
* 在进行Style的修改时,直接调用getInputWidget()方法
|
||||||
|
*
|
||||||
|
* 对于LayerStyle的实现类,应该同时实现ElementStyle,并将相同种类的(如描边或填充)的style整合成一个类,
|
||||||
|
* 对于相同的类,一个图层应该只拥有一个
|
||||||
|
*/
|
||||||
class LayerStyle : public Renderer::ElementStyle
|
class LayerStyle : public Renderer::ElementStyle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
const static std::vector<std::pair<QString, std::function<std::unique_ptr<LayerStyle>()>>> types;
|
||||||
static std::unique_ptr<LayerStyle> fromJson(const QJsonObject& json);
|
static std::unique_ptr<LayerStyle> fromJson(const QJsonObject& json);
|
||||||
|
|
||||||
virtual QString getDisplayName() const = 0;
|
virtual QString getStyleName() const = 0;
|
||||||
virtual QWidget* getInputWidget() = 0;
|
virtual QWidget* getInputWidget() = 0;
|
||||||
virtual QWidget* getListDisplayWidget() const = 0;
|
virtual QWidget* getListDisplayWidget() const = 0;
|
||||||
virtual ~LayerStyle() = default;
|
virtual ~LayerStyle() {};
|
||||||
virtual QJsonObject toJson() const = 0;
|
virtual QJsonObject toJson() const = 0;
|
||||||
virtual std::unique_ptr<LayerStyle> clone() const = 0;
|
virtual std::unique_ptr<LayerStyle> clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LayerStyleContainer : public Renderer::ElementStyle
|
|
||||||
{
|
|
||||||
using DisplayNameWithSupplier = std::map<QString, std::function<std::unique_ptr<LayerStyle>()>>;
|
|
||||||
private:
|
|
||||||
DisplayNameWithSupplier unusedStyles;
|
|
||||||
DisplayNameWithSupplier usedStyles;
|
|
||||||
std::map<QString, std::shared_ptr<LayerStyle>> styles;
|
|
||||||
size_t hash;
|
|
||||||
public:
|
|
||||||
static LayerStyleContainer fromJson(const QJsonArray& jsonArray);
|
|
||||||
|
|
||||||
LayerStyleContainer();
|
|
||||||
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
|
||||||
QJsonArray toJson() const;
|
|
||||||
|
|
||||||
bool empty() const;
|
|
||||||
bool full() const;
|
|
||||||
std::map<QString, std::shared_ptr<LayerStyle>>::iterator begin();
|
|
||||||
std::map<QString, std::shared_ptr<LayerStyle>>::iterator end();
|
|
||||||
|
|
||||||
QStringList unusedStyleNames() const;
|
|
||||||
std::unique_ptr<LayerStyle> makeUnusedStyle(const QString& styleName) const;
|
|
||||||
bool useStyle(const std::shared_ptr<LayerStyle>& style);
|
|
||||||
bool dropStyle(const QString& styleName);
|
|
||||||
size_t getHash() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 需要在每次更改后手动调用
|
|
||||||
*/
|
|
||||||
void computeNewHash();
|
|
||||||
};
|
|
||||||
|
|
||||||
class StrokeElementLayerStyle : public LayerStyle
|
class StrokeElementLayerStyle : public LayerStyle
|
||||||
{
|
{
|
||||||
using PMaterialStyleStroke = std::shared_ptr<MaterialStyleStroke>;
|
using PMaterialStyleStroke = std::shared_ptr<MaterialStyleStroke>;
|
||||||
|
private:
|
||||||
|
std::pair<PMaterialStyleStroke, PMaterialStyleStroke> strokePair;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
STYLE_NAME("描边","stroke")
|
STYLE_TYPENAME("stroke")
|
||||||
|
|
||||||
StrokeElementLayerStyle();
|
StrokeElementLayerStyle() = default;
|
||||||
StrokeElementLayerStyle(PMaterialStyleStroke left, PMaterialStyleStroke right = nullptr);
|
StrokeElementLayerStyle(PMaterialStyleStroke left, PMaterialStyleStroke right = nullptr);
|
||||||
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
||||||
~StrokeElementLayerStyle() override = default;
|
~StrokeElementLayerStyle() = default;
|
||||||
|
|
||||||
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
||||||
|
QString getStyleName() const override;
|
||||||
QWidget* getInputWidget() override;
|
QWidget* getInputWidget() override;
|
||||||
QWidget* getListDisplayWidget() const override;
|
QWidget* getListDisplayWidget() const override;
|
||||||
QJsonObject toJson() const override;
|
QJsonObject toJson() const override;
|
||||||
std::unique_ptr<LayerStyle> clone() const override;
|
std::unique_ptr<LayerStyle> clone() const override;
|
||||||
|
|
||||||
std::pair<PMaterialStyleStroke, PMaterialStyleStroke> strokePair;
|
|
||||||
bool enableEachSideIndependent = false;
|
bool enableEachSideIndependent = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FillElementLayerStyle : public LayerStyle
|
class FillElementLayerStyle : public LayerStyle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
STYLE_NAME("填充","fill")
|
STYLE_TYPENAME("fill")
|
||||||
|
|
||||||
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
||||||
|
QString getStyleName() const override;
|
||||||
QWidget* getInputWidget() override;
|
QWidget* getInputWidget() override;
|
||||||
QWidget* getListDisplayWidget() const override;
|
QWidget* getListDisplayWidget() const override;
|
||||||
FillElementLayerStyle() = default;
|
FillElementLayerStyle() = default;
|
||||||
FillElementLayerStyle(const FillElementLayerStyle& other);
|
FillElementLayerStyle(const FillElementLayerStyle& other);
|
||||||
~FillElementLayerStyle() override = default;
|
~FillElementLayerStyle() = default;
|
||||||
std::vector<std::shared_ptr<Renderer::MaterialStyleFill>> materialStyles;
|
std::vector<std::shared_ptr<Renderer::MaterialStyleFill>> materialStyles;
|
||||||
QJsonObject toJson() const override;
|
QJsonObject toJson() const override;
|
||||||
std::unique_ptr<LayerStyle> clone() const override;
|
std::unique_ptr<LayerStyle> clone() const override;
|
||||||
|
|
|
@ -80,7 +80,10 @@ LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementMana
|
||||||
int elementIndex = json.value("element").toInt();
|
int elementIndex = json.value("element").toInt();
|
||||||
wrappedElement = elementManager->getElementById(elementIndex);
|
wrappedElement = elementManager->getElementById(elementIndex);
|
||||||
QJsonArray stylesArray = json.value("styles").toArray();
|
QJsonArray stylesArray = json.value("styles").toArray();
|
||||||
styles = LayerStyleContainer::fromJson(stylesArray);
|
for (const auto& style : stylesArray)
|
||||||
|
{
|
||||||
|
styles.push_back(LayerStyle::fromJson(style.toObject()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerWrapper::SimpleProperty::apply(PixelPath&cache)
|
void LayerWrapper::SimpleProperty::apply(PixelPath&cache)
|
||||||
|
@ -132,7 +135,7 @@ void LeafLayerWrapper::refresh(LayerWrapper* layer)
|
||||||
cache.clear();
|
cache.clear();
|
||||||
if (wrappedElement != nullptr)
|
if (wrappedElement != nullptr)
|
||||||
{
|
{
|
||||||
cache.addPath(wrappedElement->getPaintObject(this->styles));
|
cache.addPath(wrappedElement->getPaintObject(&(this->styles)));
|
||||||
}
|
}
|
||||||
LayerWrapper::refresh();
|
LayerWrapper::refresh();
|
||||||
}
|
}
|
||||||
|
@ -242,7 +245,10 @@ QJsonObject LeafLayerWrapper::toJson() const
|
||||||
QJsonObject json = LayerWrapper::toJson();
|
QJsonObject json = LayerWrapper::toJson();
|
||||||
json.insert("element", wrappedElement->index);
|
json.insert("element", wrappedElement->index);
|
||||||
json.insert("is-folder", false);
|
json.insert("is-folder", false);
|
||||||
json.insert("styles", styles.toJson());
|
QJsonArray stylesJson;
|
||||||
|
for (auto& style : styles)
|
||||||
|
stylesJson.push_back(style->toJson());
|
||||||
|
json.insert("styles", stylesJson);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,8 @@ class LeafLayerWrapper : public LayerWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GraphicElement *wrappedElement;
|
GraphicElement *wrappedElement;
|
||||||
LayerStyleContainer styles;
|
//const vector<Renderer::ElementStyleStrokeDemo> styles;
|
||||||
|
vector<std::shared_ptr<LayerStyle>> styles;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~LeafLayerWrapper() = default;
|
~LeafLayerWrapper() = default;
|
||||||
|
|
|
@ -13,7 +13,6 @@ PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
|
||||||
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
layerManager = nullptr;
|
layerManager = nullptr;
|
||||||
currentLayer = nullptr;
|
currentLayer = nullptr;
|
||||||
backgroundColor = QColor(255, 255, 255, 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize)
|
void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize)
|
||||||
|
@ -45,7 +44,7 @@ void PreviewWindow::initializeGL()
|
||||||
|
|
||||||
void PreviewWindow::paintGL()
|
void PreviewWindow::paintGL()
|
||||||
{
|
{
|
||||||
glClearColor(backgroundColor.redF(), backgroundColor.greenF(), backgroundColor.blueF(), backgroundColor.alphaF());
|
glClearColor(1.0, 1.0, 1.0, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
painter->begin(this);
|
painter->begin(this);
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
@ -113,10 +112,4 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event)
|
||||||
void PreviewWindow::mouseReleaseEvent(QMouseEvent* event)
|
void PreviewWindow::mouseReleaseEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
emit layerInfoChanged();
|
emit layerInfoChanged();
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewWindow::setBackgroundColor(QColor color)
|
|
||||||
{
|
|
||||||
this->backgroundColor = color;
|
|
||||||
this->repaint();
|
|
||||||
}
|
}
|
|
@ -23,7 +23,6 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
QRectF viewportRect;
|
QRectF viewportRect;
|
||||||
LayerWrapper* currentLayer;
|
LayerWrapper* currentLayer;
|
||||||
QPointF m_lastPos;
|
QPointF m_lastPos;
|
||||||
QColor backgroundColor;
|
|
||||||
void mousePressEvent(QMouseEvent* event) override;
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
void mouseMoveEvent(QMouseEvent* event) override;
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
@ -36,7 +35,6 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
void resizeGL(int w, int h) override;
|
void resizeGL(int w, int h) override;
|
||||||
Renderer::ElementRenderer* const getRenderer()const;
|
Renderer::ElementRenderer* const getRenderer()const;
|
||||||
void setBackgroundColor(QColor color);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void currentLayerChanged(LayerWrapper*);
|
void currentLayerChanged(LayerWrapper*);
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
#include "EditorSettingWidget.h"
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QColorDialog>
|
|
||||||
#include <QInputDialog>
|
|
||||||
|
|
||||||
EditorSettingWidget::EditorSettingWidget(QWidget* parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
|
||||||
ui.setupUi(this);
|
|
||||||
connect(ui.backgroundColorButton, &QPushButton::clicked, this, [this]() {
|
|
||||||
QColor color = QColorDialog::getColor(Qt::white, this, QString::fromLocal8Bit("选择背景颜色"));
|
|
||||||
if (color.isValid())
|
|
||||||
{
|
|
||||||
emit backgroundColorChanged(color);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
connect(ui.renameButton, &QPushButton::clicked, this, [this]() {
|
|
||||||
QString name = QInputDialog::getText(this, QString::fromLocal8Bit("重命名"), QString::fromLocal8Bit("请输入新的项目名称"));
|
|
||||||
emit projectNameChanged(name);
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include <qwidget.h>
|
|
||||||
#include "ui_EditorSettingWidget.h"
|
|
||||||
|
|
||||||
class EditorSettingWidget :
|
|
||||||
public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::EditorSettingWidget ui;
|
|
||||||
|
|
||||||
public:
|
|
||||||
EditorSettingWidget(QWidget* parent = nullptr);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void backgroundColorChanged(QColor);
|
|
||||||
void projectNameChanged(QString);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
#include <qtmaterialraisedbutton.h>
|
#include <qtmaterialraisedbutton.h>
|
||||||
#include <qtmaterialflatbutton.h>
|
#include <qtmaterialflatbutton.h>
|
||||||
|
|
||||||
|
@ -80,40 +81,39 @@ void InfoDisplayWidget::generateLayerForm()
|
||||||
layout->addRow("scale-X:", scaleX);
|
layout->addRow("scale-X:", scaleX);
|
||||||
layout->addRow("scale-Y:", scaleY);
|
layout->addRow("scale-Y:", scaleY);
|
||||||
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
|
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
|
||||||
|
|
||||||
|
LeafLayerWrapper* leafP = dynamic_cast<LeafLayerWrapper*>(this->displayLayer);
|
||||||
|
if (leafP) {
|
||||||
|
QListWidget* styleList = new QListWidget(this);
|
||||||
|
|
||||||
if (auto* leafP = dynamic_cast<LeafLayerWrapper*>(this->displayLayer); leafP) {
|
QListWidgetItem* header = new QListWidgetItem;
|
||||||
auto* styleList = new QListWidget(this);
|
QWidget* headerWidget = new QWidget(styleList);
|
||||||
|
QHBoxLayout* headerLayout = new QHBoxLayout;
|
||||||
|
|
||||||
auto* header = new QListWidgetItem;
|
QLabel* headerLabel = new QLabel(headerWidget);
|
||||||
auto* headerWidget = new QWidget(styleList);
|
|
||||||
auto* headerLayout = new QHBoxLayout;
|
|
||||||
|
|
||||||
auto* headerLabel = new QLabel(headerWidget);
|
|
||||||
headerLabel->setText("样式列表");
|
headerLabel->setText("样式列表");
|
||||||
headerLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
headerLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||||
|
|
||||||
//QtMaterialRaisedButton* addStyleButton = new QtMaterialRaisedButton("+", headerWidget);
|
//QtMaterialRaisedButton* addStyleButton = new QtMaterialRaisedButton("+", headerWidget);
|
||||||
auto* addStyleButton = new QPushButton("+", headerWidget);
|
QPushButton* addStyleButton = new QPushButton("+", headerWidget);
|
||||||
addStyleButton->setFixedSize(QSize(20, 20));
|
addStyleButton->setFixedSize(QSize(20, 20));
|
||||||
if (leafP->styles.full())
|
if (leafP->styles.size() >= LayerStyle::types.size())
|
||||||
{
|
{
|
||||||
addStyleButton->setDisabled(true);
|
addStyleButton->setDisabled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
connect(addStyleButton, &QPushButton::clicked, [&, leafP] {
|
connect(addStyleButton, &QPushButton::clicked, [&, leafP]() {
|
||||||
auto* dialog = new LayerStyleDialog(leafP->styles);
|
LayerStyleDialog* dialog = new LayerStyleDialog(nullptr, nullptr, &(leafP->styles));
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
if (dialog->layerStyle)
|
if (dialog->layerStyle)
|
||||||
{
|
{
|
||||||
leafP->styles.useStyle(dialog->layerStyle);
|
leafP->styles.push_back(dialog->layerStyle);
|
||||||
leafP->styles.computeNewHash();
|
emit requireRefreshPreview();
|
||||||
|
emit requireSelfRefresh();
|
||||||
emit requireRefreshPreview();
|
emit requireRefreshElementWidget();
|
||||||
emit requireSelfRefresh();
|
}
|
||||||
emit requireRefreshElementWidget();
|
dialog->deleteLater();
|
||||||
}
|
|
||||||
dialog->deleteLater();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,35 +179,32 @@ void InfoDisplayWidget::generateLayerForm()
|
||||||
{
|
{
|
||||||
leafP->styles.push_back(std::shared_ptr<LayerStyle>(new StrokeElementLayerStyle()));
|
leafP->styles.push_back(std::shared_ptr<LayerStyle>(new StrokeElementLayerStyle()));
|
||||||
}*/
|
}*/
|
||||||
auto* styles = &leafP->styles;
|
std::vector<std::shared_ptr<LayerStyle>>* styles = &(leafP->styles);
|
||||||
for (auto styleIterator = styles->begin(); styleIterator != styles->end(); ++styleIterator)
|
for (auto styleIterator = styles->begin(); styleIterator != styles->end(); styleIterator++)
|
||||||
{
|
{
|
||||||
auto* item = new QListWidgetItem;
|
QListWidgetItem* item = new QListWidgetItem;
|
||||||
auto* w = new QWidget(this);
|
QWidget* w = new QWidget;
|
||||||
item->setSizeHint(QSize(50, 40));
|
item->setSizeHint(QSize(50, 40));
|
||||||
auto* layout = new QHBoxLayout(w);
|
QHBoxLayout* layout = new QHBoxLayout;
|
||||||
layout->setAlignment(Qt::AlignmentFlag::AlignRight);
|
layout->setAlignment(Qt::AlignmentFlag::AlignRight);
|
||||||
//QtMaterialFlatButton* detailButton = new QtMaterialFlatButton(w);
|
//QtMaterialFlatButton* detailButton = new QtMaterialFlatButton(w);
|
||||||
//QtMaterialFlatButton* removeButton = new QtMaterialFlatButton(w);
|
//QtMaterialFlatButton* removeButton = new QtMaterialFlatButton(w);
|
||||||
auto* detailButton = new QPushButton(w);
|
QPushButton* detailButton = new QPushButton(w);
|
||||||
auto* removeButton = new QPushButton(w);
|
QPushButton* removeButton = new QPushButton(w);
|
||||||
detailButton->setText("...");
|
detailButton->setText("...");
|
||||||
detailButton->setFixedSize(QSize(20, 20));
|
detailButton->setFixedSize(QSize(20, 20));
|
||||||
removeButton->setText("×");
|
removeButton->setText("×");
|
||||||
removeButton->setFixedSize(QSize(20, 20));
|
removeButton->setFixedSize(QSize(20, 20));
|
||||||
|
|
||||||
connect(detailButton, &QPushButton::clicked, this,
|
connect(detailButton, &QPushButton::clicked, this,
|
||||||
[this, styles, styleIterator]
|
[this, styleIterator]()
|
||||||
{
|
{
|
||||||
auto* dialog =
|
LayerStyleDialog* dialog = new LayerStyleDialog(nullptr, *styleIterator);
|
||||||
new LayerStyleDialog(*styles, styleIterator->second);
|
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
|
|
||||||
if (dialog->layerStyle)
|
if (dialog->layerStyle)
|
||||||
{
|
{
|
||||||
styleIterator->second = dialog->layerStyle;
|
(*styleIterator) = dialog->layerStyle;
|
||||||
styles->computeNewHash();
|
|
||||||
|
|
||||||
emit requireRefreshPreview();
|
emit requireRefreshPreview();
|
||||||
emit requireSelfRefresh();
|
emit requireSelfRefresh();
|
||||||
emit requireRefreshElementWidget();
|
emit requireRefreshElementWidget();
|
||||||
|
@ -216,17 +213,15 @@ void InfoDisplayWidget::generateLayerForm()
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(removeButton, &QPushButton::clicked, this,
|
connect(removeButton, &QPushButton::clicked, this,
|
||||||
[this, styleIterator, styles]
|
[this, styleIterator, styles]()
|
||||||
{
|
{
|
||||||
styles->dropStyle(styleIterator->first);
|
styles->erase(styleIterator);
|
||||||
styles->computeNewHash();
|
|
||||||
|
|
||||||
emit requireRefreshPreview();
|
emit requireRefreshPreview();
|
||||||
emit requireSelfRefresh();
|
emit requireSelfRefresh();
|
||||||
emit requireRefreshElementWidget();
|
emit requireRefreshElementWidget();
|
||||||
});
|
});
|
||||||
|
|
||||||
QWidget* styleDisplayWidget = styleIterator->second->getListDisplayWidget();
|
QWidget* styleDisplayWidget = (*styleIterator)->getListDisplayWidget();
|
||||||
styleDisplayWidget->setParent(w);
|
styleDisplayWidget->setParent(w);
|
||||||
styleDisplayWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
styleDisplayWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||||
|
|
||||||
|
|
|
@ -273,8 +273,7 @@ GLuint Renderer::Model::loadPainting(std::string path)
|
||||||
}
|
}
|
||||||
else if (path == "1.json")
|
else if (path == "1.json")
|
||||||
{
|
{
|
||||||
painting.backgroundColor = QColor(196, 81, 35);
|
float widths[] = { 0.43, 0.43 * 0.25 / 0.15, 0.43 * 0.25 / 0.15 };
|
||||||
float widths[] = { 0.22, 0.22 * 0.25 / 0.15, 0.22 * 0.25 / 0.15 };
|
|
||||||
QPainterPath painterPaths[6];
|
QPainterPath painterPaths[6];
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
if (!SvgFileLoader().loadSvgFile(QString(std::format("../svg/{}.svg", i + 1).c_str()), painterPaths[i]))
|
if (!SvgFileLoader().loadSvgFile(QString(std::format("../svg/{}.svg", i + 1).c_str()), painterPaths[i]))
|
||||||
|
|
|
@ -9,7 +9,7 @@ using namespace Renderer;
|
||||||
|
|
||||||
constexpr int kMaxLineCount = 20;
|
constexpr int kMaxLineCount = 20;
|
||||||
|
|
||||||
Painting::Painting(QColor backgroundColor) : backgroundColor(backgroundColor)
|
Painting::Painting()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,21 +171,18 @@ void Painting::generateBuffers(QOpenGLFunctions_4_5_Core* glFunc)
|
||||||
//std::cout << std::format("{} {} {} {}\n", contourBuffer->bvhOffset, stylePool[i.first->style], contourBuffer->pointsOffset, contourBuffer->linesOffset);
|
//std::cout << std::format("{} {} {} {}\n", contourBuffer->bvhOffset, stylePool[i.first->style], contourBuffer->pointsOffset, contourBuffer->linesOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
glFunc->glCreateBuffers(6, buffers.data());
|
glFunc->glCreateBuffers(5, buffers.data());
|
||||||
GLuint& bvhSSBO = buffers[0];
|
GLuint& bvhSSBO = buffers[0];
|
||||||
GLuint& bvhBoundSSBO = buffers[1];
|
GLuint& bvhBoundSSBO = buffers[1];
|
||||||
GLuint& elementOffsetSSBO = buffers[2];
|
GLuint& elementOffsetSSBO = buffers[2];
|
||||||
GLuint& elementIndexSSBO = buffers[3];
|
GLuint& elementIndexSSBO = buffers[3];
|
||||||
GLuint& elementDataSSBO = buffers[4];
|
GLuint& elementDataSSBO = buffers[4];
|
||||||
GLuint& backgroundColorUBO = buffers[5];
|
|
||||||
|
|
||||||
glFunc->glNamedBufferData(buffers[0], bvhChildren.size() * sizeof(bvhChildren[0]), bvhChildren.data(), GL_STATIC_READ);
|
glFunc->glNamedBufferData(buffers[0], bvhChildren.size() * sizeof(bvhChildren[0]), bvhChildren.data(), GL_STATIC_READ);
|
||||||
glFunc->glNamedBufferData(buffers[1], bvhBounds.size() * sizeof(bvhBounds[0]), bvhBounds.data(), GL_STATIC_READ);
|
glFunc->glNamedBufferData(buffers[1], bvhBounds.size() * sizeof(bvhBounds[0]), bvhBounds.data(), GL_STATIC_READ);
|
||||||
glFunc->glNamedBufferData(buffers[2], elementOffsets.size() * sizeof(elementOffsets[0]), elementOffsets.data(), GL_STATIC_READ);
|
glFunc->glNamedBufferData(buffers[2], elementOffsets.size() * sizeof(elementOffsets[0]), elementOffsets.data(), GL_STATIC_READ);
|
||||||
glFunc->glNamedBufferData(buffers[3], elementIndex.size() * sizeof(elementIndex[0]), elementIndex.data(), GL_STATIC_READ);
|
glFunc->glNamedBufferData(buffers[3], elementIndex.size() * sizeof(elementIndex[0]), elementIndex.data(), GL_STATIC_READ);
|
||||||
glFunc->glNamedBufferData(buffers[4], elementData.size() * sizeof(elementData[0]), elementData.data(), GL_STATIC_READ);
|
glFunc->glNamedBufferData(buffers[4], elementData.size() * sizeof(elementData[0]), elementData.data(), GL_STATIC_READ);
|
||||||
glm::vec3 color(backgroundColor.redF(), backgroundColor.greenF(), backgroundColor.blueF());
|
|
||||||
glFunc->glNamedBufferData(buffers[5], sizeof(glm::vec3), &color, GL_STATIC_READ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint Renderer::Painting::getElementCount()
|
GLuint Renderer::Painting::getElementCount()
|
||||||
|
|
|
@ -64,10 +64,9 @@ namespace Renderer
|
||||||
std::vector<GLuint> elementIndex;
|
std::vector<GLuint> elementIndex;
|
||||||
std::vector<GLfloat> elementData;
|
std::vector<GLfloat> elementData;
|
||||||
int paintingId = 0;
|
int paintingId = 0;
|
||||||
std::array<GLuint, 6> buffers;
|
std::array<GLuint, 5> buffers;
|
||||||
QColor backgroundColor;
|
|
||||||
|
|
||||||
Painting(QColor backgroundColor = Qt::white);
|
Painting();
|
||||||
void addElement(const Element& element, const ElementTransform& transform);
|
void addElement(const Element& element, const ElementTransform& transform);
|
||||||
void addElement(std::shared_ptr<Element> element, QVector4D bound, float rotation, int zIndex);
|
void addElement(std::shared_ptr<Element> element, QVector4D bound, float rotation, int zIndex);
|
||||||
void generateBuffers(QOpenGLFunctions_4_5_Core* glFunc);
|
void generateBuffers(QOpenGLFunctions_4_5_Core* glFunc);
|
||||||
|
|
|
@ -126,7 +126,6 @@ std::uint16_t Renderer::VirtualTextureManager::createVirtualTexture(Painting pai
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
glMain->BindBufferBase(GL_SHADER_STORAGE_BUFFER, i, painting.buffers[i]);
|
glMain->BindBufferBase(GL_SHADER_STORAGE_BUFFER, i, painting.buffers[i]);
|
||||||
glMain->BindBufferBase(GL_UNIFORM_BUFFER, 1, painting.buffers[5]);
|
|
||||||
|
|
||||||
for (auto level = levels - 1; level < levels; ++level)
|
for (auto level = levels - 1; level < levels; ++level)
|
||||||
{
|
{
|
||||||
|
@ -144,7 +143,7 @@ std::uint16_t Renderer::VirtualTextureManager::createVirtualTexture(Painting pai
|
||||||
GL_TRUE);
|
GL_TRUE);
|
||||||
|
|
||||||
program.bind();
|
program.bind();
|
||||||
glMain->Uniform2i(0 /*pixelOffset*/, static_cast<GLsizei>(pageSize) * i, static_cast<GLsizei>(pageSize) * j);
|
glMain->Uniform2i(gl->GetUniformLocation(program.programId(), "pixelOffset"), static_cast<GLsizei>(pageSize) * i, static_cast<GLsizei>(pageSize) * j);
|
||||||
glMain->BindImageTexture(0, baseColor, level, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8);
|
glMain->BindImageTexture(0, baseColor, level, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8);
|
||||||
glMain->BindImageTexture(1, metallicRoughness, level, GL_FALSE, 0, GL_READ_WRITE, GL_RG8);
|
glMain->BindImageTexture(1, metallicRoughness, level, GL_FALSE, 0, GL_READ_WRITE, GL_RG8);
|
||||||
glMain->DispatchCompute(pageSize / 8, pageSize / 8, 1);
|
glMain->DispatchCompute(pageSize / 8, pageSize / 8, 1);
|
||||||
|
@ -191,7 +190,6 @@ void Renderer::VirtualTextureManager::pageCommitmentById(const glm::u16vec2& pag
|
||||||
program.bind();
|
program.bind();
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
gl->BindBufferBase(GL_SHADER_STORAGE_BUFFER, i, painting.buffers[i]);
|
gl->BindBufferBase(GL_SHADER_STORAGE_BUFFER, i, painting.buffers[i]);
|
||||||
glMain->BindBufferBase(GL_UNIFORM_BUFFER, 1, painting.buffers[5]);
|
|
||||||
gl->Uniform2i(gl->GetUniformLocation(program.programId(), "pixelOffset"), static_cast<GLsizei>(pageSize) * page.x, static_cast<GLsizei>(pageSize) * page.y);
|
gl->Uniform2i(gl->GetUniformLocation(program.programId(), "pixelOffset"), static_cast<GLsizei>(pageSize) * page.x, static_cast<GLsizei>(pageSize) * page.y);
|
||||||
gl->BindImageTexture(0, painting.baseColor, level, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8);
|
gl->BindImageTexture(0, painting.baseColor, level, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8);
|
||||||
gl->BindImageTexture(1, painting.metallicRoughness, level, GL_FALSE, 0, GL_READ_WRITE, GL_RG8);
|
gl->BindImageTexture(1, painting.metallicRoughness, level, GL_FALSE, 0, GL_READ_WRITE, GL_RG8);
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Renderer
|
||||||
{
|
{
|
||||||
GLuint baseColor;
|
GLuint baseColor;
|
||||||
GLuint metallicRoughness;
|
GLuint metallicRoughness;
|
||||||
std::array<GLuint, 6> buffers;
|
std::array<GLuint, 5> buffers;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VirtualTextureManager
|
class VirtualTextureManager
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include "consoleapi2.h"
|
#include "consoleapi2.h"
|
||||||
#include <lib/qtmaterialstyle.h>
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
@ -51,9 +50,6 @@ int main(int argc, char* argv[])
|
||||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
Q_INIT_RESOURCE(resources);
|
Q_INIT_RESOURCE(resources);
|
||||||
QtMaterialTheme theme;
|
|
||||||
theme.setColor("primary1", QColor(0, 90, 158));
|
|
||||||
QtMaterialStyle::instance().setTheme(&theme);
|
|
||||||
//FramelessHelper::Core::setApplicationOSThemeAware();
|
//FramelessHelper::Core::setApplicationOSThemeAware();
|
||||||
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
|
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
|
||||||
//FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
//FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||||
|
|
Loading…
Reference in New Issue