修改了LayerStyle
将clonePtr重命名为了clone 将StrokeElementLayerStyle的存储style方式改为了通过pair存储两侧dev-LayerStyle
parent
28df3d47c5
commit
1b926b2054
|
@ -18,7 +18,7 @@ LayerStyleDialog::LayerStyleDialog(
|
||||||
|
|
||||||
if (existedStyle)
|
if (existedStyle)
|
||||||
{
|
{
|
||||||
this->modifyingStyle = existedStyle->clonePtr();
|
this->modifyingStyle = existedStyle->clone();
|
||||||
|
|
||||||
this->styleContainer = nullptr;
|
this->styleContainer = nullptr;
|
||||||
this->styleWidget = modifyingStyle->getInputWidget();
|
this->styleWidget = modifyingStyle->getInputWidget();
|
||||||
|
|
|
@ -54,9 +54,12 @@ PixelPath SimpleElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
style = (*styles)[0];
|
style = (*styles)[0];
|
||||||
qDebug() << std::dynamic_pointer_cast<Renderer::StrokePlain>(
|
/*qDebug() << std::dynamic_pointer_cast<Renderer::StrokePlain>(
|
||||||
std::dynamic_pointer_cast<StrokeElementLayerStyle>(style)->materialStyles[0]->materialStroke
|
std::dynamic_pointer_cast<StrokeElementLayerStyle>(style)->materialStyles[0]->materialStroke
|
||||||
)->material.color.name();
|
)->material.color.name();*/
|
||||||
|
/*qDebug() << std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(
|
||||||
|
std::dynamic_pointer_cast<StrokeElementLayerStyle>(style)->materialStyles[0]->materialStroke
|
||||||
|
)->materialMap[1.0].color;*/
|
||||||
}
|
}
|
||||||
auto [img, mov] = renderer->drawElement(painterPath, *style, 1.0);
|
auto [img, mov] = renderer->drawElement(painterPath, *style, 1.0);
|
||||||
//qDebug() << img << " ------";
|
//qDebug() << img << " ------";
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
#include "LayerStyle.h"
|
#include "LayerStyle.h"
|
||||||
|
#include "./EditorWidgetComponent/StrokeStyleListView.h"
|
||||||
|
#include <qtmaterialcheckbox.h>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
const std::vector<std::pair<QString, std::function<std::unique_ptr<LayerStyle>()>>> LayerStyle::types = {
|
const std::vector<std::pair<QString, std::function<std::unique_ptr<LayerStyle>()>>> LayerStyle::types = {
|
||||||
{
|
{
|
||||||
|
@ -20,10 +23,24 @@ const std::vector<std::pair<QString, std::function<std::unique_ptr<LayerStyle>()
|
||||||
std::vector<Renderer::BaseStyle> StrokeElementLayerStyle::toBaseStyles() const
|
std::vector<Renderer::BaseStyle> StrokeElementLayerStyle::toBaseStyles() const
|
||||||
{
|
{
|
||||||
std::vector<Renderer::BaseStyle> baseStyles;
|
std::vector<Renderer::BaseStyle> baseStyles;
|
||||||
for (auto materialStyle : materialStyles)
|
/*for (auto materialStyle : materialStyles)
|
||||||
{
|
{
|
||||||
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
||||||
materialStyle));
|
materialStyle));
|
||||||
|
}*/
|
||||||
|
if (enableEachSideIndependent)
|
||||||
|
{
|
||||||
|
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
||||||
|
strokePair.first));
|
||||||
|
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
||||||
|
strokePair.second));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strokePair.first->strokeType = Renderer::StrokeType::kBothSides;
|
||||||
|
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
||||||
|
strokePair.first));
|
||||||
|
strokePair.first->strokeType = Renderer::StrokeType::kLeftSide;
|
||||||
}
|
}
|
||||||
return baseStyles;
|
return baseStyles;
|
||||||
}
|
}
|
||||||
|
@ -35,34 +52,61 @@ QString StrokeElementLayerStyle::getStyleName() const
|
||||||
|
|
||||||
QWidget* StrokeElementLayerStyle::getInputWidget()
|
QWidget* StrokeElementLayerStyle::getInputWidget()
|
||||||
{
|
{
|
||||||
// TODO
|
if (this->strokePair.first == nullptr)
|
||||||
if (this->materialStyles.empty())
|
|
||||||
{
|
{
|
||||||
/*auto materialMap = std::map<float, Renderer::Material>();
|
auto materialMap = std::map<float, Renderer::Material>();
|
||||||
materialMap[1.0] = Renderer::Material{ QColor(0,255,255), 1.0f, 1.0f };
|
materialMap[0.3] = Renderer::Material{ QColor(0,255,255), 0.f, .8f };
|
||||||
this->materialStyles.push_back(std::shared_ptr<Renderer::MaterialStyleStroke>(new Renderer::MaterialStyleStroke(
|
materialMap[1.0] = Renderer::Material{ QColor(80,25,255), 0.f, .8f };
|
||||||
0,
|
this->strokePair.first = std::shared_ptr<Renderer::MaterialStyleStroke>(new Renderer::MaterialStyleStroke(
|
||||||
Renderer::StrokeType::kBothSides, Renderer::StrokeEndType::kFlat,
|
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>();
|
||||||
|
materialMap[0.3] = Renderer::Material{ QColor(0,255,255), 0.f, .8f };
|
||||||
|
materialMap[1.0] = Renderer::Material{ QColor(80,25,255), 0.f, .8f };
|
||||||
|
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(
|
std::shared_ptr<Renderer::MaterialStroke>(new Renderer::StrokeRadialGradient(
|
||||||
materialMap, false
|
materialMap, false
|
||||||
))
|
))
|
||||||
)));*/
|
));
|
||||||
this->materialStyles.push_back(std::make_shared<Renderer::MaterialStyleStroke>(
|
|
||||||
0,
|
|
||||||
Renderer::StrokeType::kBothSides, Renderer::StrokeEndType::kFlat,
|
|
||||||
std::make_shared<Renderer::StrokePlain>(QColor::fromRgb(50, 50, 50), 0, 0.8)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
QWidget* w = new QWidget;
|
QWidget* w = new QWidget;
|
||||||
|
QListView* materialList = new QListView;
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout(w);
|
QVBoxLayout* layout = new QVBoxLayout(w);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
QLineEdit* r = new QLineEdit(w), * g = new QLineEdit(w), * b = new QLineEdit(w);
|
|
||||||
layout->addWidget(r);
|
StrokeStyleListView* leftStrokeView = new StrokeStyleListView(
|
||||||
layout->addWidget(g);
|
std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(this->strokePair.first->materialStroke), w
|
||||||
layout->addWidget(b);
|
);
|
||||||
|
layout->addWidget(leftStrokeView);
|
||||||
|
|
||||||
|
QtMaterialCheckBox* checkEachSideIndependent = new QtMaterialCheckBox(w);
|
||||||
|
checkEachSideIndependent->setText(QStringLiteral("ÆôÓÃÁ½²à¶ÀÁ¢Ãè±ß"));
|
||||||
|
checkEachSideIndependent->setChecked(enableEachSideIndependent);
|
||||||
|
layout->addWidget(checkEachSideIndependent);
|
||||||
|
|
||||||
|
StrokeStyleListView* rightStrokeView = new StrokeStyleListView(
|
||||||
|
std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(this->strokePair.second->materialStroke), w
|
||||||
|
);
|
||||||
|
layout->addWidget(rightStrokeView);
|
||||||
|
rightStrokeView->setDisabled(!this->enableEachSideIndependent);
|
||||||
|
|
||||||
|
QObject::connect(checkEachSideIndependent, &QtMaterialCheckBox::toggled, [this, rightStrokeView](bool toggled) {
|
||||||
|
this->enableEachSideIndependent = toggled;
|
||||||
|
rightStrokeView->setDisabled(!toggled);
|
||||||
|
});
|
||||||
//auto stroke = std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(this->materialStyles[0]->materialStroke);
|
//auto stroke = std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(this->materialStyles[0]->materialStroke);
|
||||||
//QColor* color = &(stroke->materialMap[1.0].color);
|
//QColor* color = &(stroke->materialMap[1.0].color);
|
||||||
auto stroke = std::dynamic_pointer_cast<Renderer::StrokePlain>(this->materialStyles[0]->materialStroke);
|
/*auto stroke = std::dynamic_pointer_cast<Renderer::StrokePlain>(this->materialStyles[0]->materialStroke);
|
||||||
QColor* color = &(stroke->material.color);
|
QColor* color = &(stroke->material.color);
|
||||||
r->setText(QString::number(color->red()));
|
r->setText(QString::number(color->red()));
|
||||||
g->setText(QString::number(color->green()));
|
g->setText(QString::number(color->green()));
|
||||||
|
@ -84,7 +128,7 @@ QWidget* StrokeElementLayerStyle::getInputWidget()
|
||||||
{
|
{
|
||||||
color->setBlue(content.toInt());
|
color->setBlue(content.toInt());
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,16 +145,16 @@ QWidget* StrokeElementLayerStyle::getListDisplayWidget() const
|
||||||
|
|
||||||
StrokeElementLayerStyle::StrokeElementLayerStyle(const StrokeElementLayerStyle& other)
|
StrokeElementLayerStyle::StrokeElementLayerStyle(const StrokeElementLayerStyle& other)
|
||||||
{
|
{
|
||||||
materialStyles = std::vector<std::shared_ptr<Renderer::MaterialStyleStroke>>(other.materialStyles.size());
|
strokePair.first = std::dynamic_pointer_cast<MaterialStyleStroke>(
|
||||||
for (size_t i = 0; i < other.materialStyles.size(); i++)
|
std::shared_ptr<Renderer::MaterialStyle>(std::move(other.strokePair.first->clone()))
|
||||||
{
|
);
|
||||||
materialStyles[i] = std::dynamic_pointer_cast<Renderer::MaterialStyleStroke>(
|
strokePair.second = std::dynamic_pointer_cast<MaterialStyleStroke>(
|
||||||
std::shared_ptr<Renderer::MaterialStyle>(std::move(other.materialStyles[i]->clone()))
|
std::shared_ptr<Renderer::MaterialStyle>(std::move(other.strokePair.second->clone()))
|
||||||
);
|
);
|
||||||
}
|
enableEachSideIndependent = other.enableEachSideIndependent;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<LayerStyle> StrokeElementLayerStyle::clonePtr() const
|
std::unique_ptr<LayerStyle> StrokeElementLayerStyle::clone() const
|
||||||
{
|
{
|
||||||
return std::make_unique<StrokeElementLayerStyle>(StrokeElementLayerStyle(*this));
|
return std::make_unique<StrokeElementLayerStyle>(StrokeElementLayerStyle(*this));
|
||||||
}
|
}
|
||||||
|
@ -153,7 +197,7 @@ FillElementLayerStyle::FillElementLayerStyle(const FillElementLayerStyle& other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<LayerStyle> FillElementLayerStyle::clonePtr() const
|
std::unique_ptr<LayerStyle> FillElementLayerStyle::clone() const
|
||||||
{
|
{
|
||||||
return std::make_unique<FillElementLayerStyle>(FillElementLayerStyle(*this));
|
return std::make_unique<FillElementLayerStyle>(FillElementLayerStyle(*this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
||||||
#include "../Renderer/Painting/MaterialStyleFill.h"
|
#include "../Renderer/Painting/MaterialStyleFill.h"
|
||||||
|
|
||||||
|
using Renderer::MaterialStyleStroke;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在进行Style的添加时,首先创建空对象,然后直接调用getInputWidget()方法
|
* 在进行Style的添加时,首先创建空对象,然后直接调用getInputWidget()方法
|
||||||
* 在进行Style的修改时,直接调用getInputWidget()方法
|
* 在进行Style的修改时,直接调用getInputWidget()方法
|
||||||
|
@ -24,11 +26,14 @@ public:
|
||||||
virtual QWidget* getInputWidget() = 0;
|
virtual QWidget* getInputWidget() = 0;
|
||||||
virtual QWidget* getListDisplayWidget() const = 0;
|
virtual QWidget* getListDisplayWidget() const = 0;
|
||||||
virtual ~LayerStyle() {};
|
virtual ~LayerStyle() {};
|
||||||
virtual std::unique_ptr<LayerStyle> clonePtr() const = 0;
|
virtual std::unique_ptr<LayerStyle> clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StrokeElementLayerStyle : public LayerStyle
|
class StrokeElementLayerStyle : public LayerStyle
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
std::pair<std::shared_ptr<MaterialStyleStroke>, std::shared_ptr<MaterialStyleStroke>> strokePair;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
||||||
QString getStyleName() const override;
|
QString getStyleName() const override;
|
||||||
|
@ -37,8 +42,9 @@ public:
|
||||||
StrokeElementLayerStyle() = default;
|
StrokeElementLayerStyle() = default;
|
||||||
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
||||||
~StrokeElementLayerStyle() = default;
|
~StrokeElementLayerStyle() = default;
|
||||||
std::vector<std::shared_ptr<Renderer::MaterialStyleStroke>> materialStyles;
|
std::unique_ptr<LayerStyle> clone() const override;
|
||||||
std::unique_ptr<LayerStyle> clonePtr() const override;
|
|
||||||
|
bool enableEachSideIndependent = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FillElementLayerStyle : public LayerStyle
|
class FillElementLayerStyle : public LayerStyle
|
||||||
|
@ -52,5 +58,5 @@ public:
|
||||||
FillElementLayerStyle(const FillElementLayerStyle& other);
|
FillElementLayerStyle(const FillElementLayerStyle& other);
|
||||||
~FillElementLayerStyle() = default;
|
~FillElementLayerStyle() = default;
|
||||||
std::vector<std::shared_ptr<Renderer::MaterialStyleFill>> materialStyles;
|
std::vector<std::shared_ptr<Renderer::MaterialStyleFill>> materialStyles;
|
||||||
std::unique_ptr<LayerStyle> clonePtr() const override;
|
std::unique_ptr<LayerStyle> clone() const override;
|
||||||
};
|
};
|
Loading…
Reference in New Issue