修改了LayerStyle
将clonePtr重命名为了clone 将StrokeElementLayerStyle的存储style方式改为了通过pair存储两侧dev-LayerStyle
parent
28df3d47c5
commit
1b926b2054
|
@ -18,7 +18,7 @@ LayerStyleDialog::LayerStyleDialog(
|
|||
|
||||
if (existedStyle)
|
||||
{
|
||||
this->modifyingStyle = existedStyle->clonePtr();
|
||||
this->modifyingStyle = existedStyle->clone();
|
||||
|
||||
this->styleContainer = nullptr;
|
||||
this->styleWidget = modifyingStyle->getInputWidget();
|
||||
|
|
|
@ -47,16 +47,19 @@ PixelPath SimpleElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>
|
|||
PixelPath result;
|
||||
//Renderer::ElementStyleStrokeDemo demo(2);
|
||||
std::shared_ptr<Renderer::ElementStyle> style;
|
||||
if ((*styles).empty())
|
||||
if ((*styles).empty())
|
||||
{
|
||||
style = std::make_shared<Renderer::ElementStyleStrokeDemo>(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
)->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);
|
||||
//qDebug() << img << " ------";
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#include "LayerStyle.h"
|
||||
#include "./EditorWidgetComponent/StrokeStyleListView.h"
|
||||
#include <qtmaterialcheckbox.h>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
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> baseStyles;
|
||||
for (auto materialStyle : materialStyles)
|
||||
/*for (auto materialStyle : materialStyles)
|
||||
{
|
||||
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
||||
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;
|
||||
}
|
||||
|
@ -35,34 +52,61 @@ QString StrokeElementLayerStyle::getStyleName() const
|
|||
|
||||
QWidget* StrokeElementLayerStyle::getInputWidget()
|
||||
{
|
||||
// TODO
|
||||
if (this->materialStyles.empty())
|
||||
if (this->strokePair.first == nullptr)
|
||||
{
|
||||
/*auto materialMap = std::map<float, Renderer::Material>();
|
||||
materialMap[1.0] = Renderer::Material{ QColor(0,255,255), 1.0f, 1.0f };
|
||||
this->materialStyles.push_back(std::shared_ptr<Renderer::MaterialStyleStroke>(new Renderer::MaterialStyleStroke(
|
||||
0,
|
||||
Renderer::StrokeType::kBothSides, Renderer::StrokeEndType::kFlat,
|
||||
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.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>();
|
||||
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(
|
||||
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;
|
||||
QListView* materialList = new QListView;
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(w);
|
||||
layout->setMargin(0);
|
||||
QLineEdit* r = new QLineEdit(w), * g = new QLineEdit(w), * b = new QLineEdit(w);
|
||||
layout->addWidget(r);
|
||||
layout->addWidget(g);
|
||||
layout->addWidget(b);
|
||||
|
||||
StrokeStyleListView* leftStrokeView = new StrokeStyleListView(
|
||||
std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(this->strokePair.first->materialStroke), w
|
||||
);
|
||||
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);
|
||||
//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);
|
||||
r->setText(QString::number(color->red()));
|
||||
g->setText(QString::number(color->green()));
|
||||
|
@ -84,7 +128,7 @@ QWidget* StrokeElementLayerStyle::getInputWidget()
|
|||
{
|
||||
color->setBlue(content.toInt());
|
||||
}
|
||||
});
|
||||
});*/
|
||||
return w;
|
||||
}
|
||||
|
||||
|
@ -101,16 +145,16 @@ QWidget* StrokeElementLayerStyle::getListDisplayWidget() const
|
|||
|
||||
StrokeElementLayerStyle::StrokeElementLayerStyle(const StrokeElementLayerStyle& other)
|
||||
{
|
||||
materialStyles = std::vector<std::shared_ptr<Renderer::MaterialStyleStroke>>(other.materialStyles.size());
|
||||
for (size_t i = 0; i < other.materialStyles.size(); i++)
|
||||
{
|
||||
materialStyles[i] = std::dynamic_pointer_cast<Renderer::MaterialStyleStroke>(
|
||||
std::shared_ptr<Renderer::MaterialStyle>(std::move(other.materialStyles[i]->clone()))
|
||||
);
|
||||
}
|
||||
strokePair.first = std::dynamic_pointer_cast<MaterialStyleStroke>(
|
||||
std::shared_ptr<Renderer::MaterialStyle>(std::move(other.strokePair.first->clone()))
|
||||
);
|
||||
strokePair.second = std::dynamic_pointer_cast<MaterialStyleStroke>(
|
||||
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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
||||
#include "../Renderer/Painting/MaterialStyleFill.h"
|
||||
|
||||
using Renderer::MaterialStyleStroke;
|
||||
|
||||
/**
|
||||
* 在进行Style的添加时,首先创建空对象,然后直接调用getInputWidget()方法
|
||||
* 在进行Style的修改时,直接调用getInputWidget()方法
|
||||
|
@ -24,11 +26,14 @@ public:
|
|||
virtual QWidget* getInputWidget() = 0;
|
||||
virtual QWidget* getListDisplayWidget() const = 0;
|
||||
virtual ~LayerStyle() {};
|
||||
virtual std::unique_ptr<LayerStyle> clonePtr() const = 0;
|
||||
virtual std::unique_ptr<LayerStyle> clone() const = 0;
|
||||
};
|
||||
|
||||
class StrokeElementLayerStyle : public LayerStyle
|
||||
{
|
||||
private:
|
||||
std::pair<std::shared_ptr<MaterialStyleStroke>, std::shared_ptr<MaterialStyleStroke>> strokePair;
|
||||
|
||||
public:
|
||||
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
||||
QString getStyleName() const override;
|
||||
|
@ -37,8 +42,9 @@ public:
|
|||
StrokeElementLayerStyle() = default;
|
||||
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
||||
~StrokeElementLayerStyle() = default;
|
||||
std::vector<std::shared_ptr<Renderer::MaterialStyleStroke>> materialStyles;
|
||||
std::unique_ptr<LayerStyle> clonePtr() const override;
|
||||
std::unique_ptr<LayerStyle> clone() const override;
|
||||
|
||||
bool enableEachSideIndependent = false;
|
||||
};
|
||||
|
||||
class FillElementLayerStyle : public LayerStyle
|
||||
|
@ -52,5 +58,5 @@ public:
|
|||
FillElementLayerStyle(const FillElementLayerStyle& other);
|
||||
~FillElementLayerStyle() = default;
|
||||
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