令drawElement时会应用style
parent
b429761d81
commit
e97e6d5281
|
@ -45,7 +45,6 @@ PixelPath GroupElement::getPaintObject() const
|
|||
//TODO: apply styles and send back
|
||||
PixelPath SimpleElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>* styles) const {
|
||||
PixelPath result;
|
||||
//Renderer::ElementStyleStrokeDemo demo(2);
|
||||
std::shared_ptr<Renderer::ElementStyle> style;
|
||||
if ((*styles).empty())
|
||||
{
|
||||
|
@ -99,7 +98,7 @@ QJsonObject GraphicElement::toJson() const
|
|||
return result;
|
||||
}
|
||||
|
||||
void SimpleElement::paint(QPainter* painter, QTransform transform, vector<std::shared_ptr<LayerStyle>> styles)
|
||||
void SimpleElement::paint(QPainter* painter, QTransform transform, const vector<std::shared_ptr<LayerStyle>> &styles)
|
||||
{
|
||||
painter->save();
|
||||
painter->setTransform(transform);
|
||||
|
@ -109,16 +108,30 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, vector<std::s
|
|||
}
|
||||
else
|
||||
{
|
||||
// TODO:Ó¦ÓÃstyle
|
||||
Renderer::ElementStyleStrokeDemo demo(2);
|
||||
auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0);
|
||||
std::shared_ptr<Renderer::ElementStyle> style;
|
||||
if (styles.empty())
|
||||
{
|
||||
style = std::make_shared<Renderer::ElementStyleStrokeDemo>(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
style = styles[0];
|
||||
/*qDebug() << std::dynamic_pointer_cast<Renderer::StrokePlain>(
|
||||
std::dynamic_pointer_cast<StrokeElementLayerStyle>(style)->materialStyles[0]->materialStroke
|
||||
)->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);
|
||||
painter->drawImage(mov, img);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void GroupElement::paint(QPainter* painter, QTransform transform, vector<std::shared_ptr<LayerStyle>> styles)
|
||||
void GroupElement::paint(QPainter* painter, QTransform transform, const vector<std::shared_ptr<LayerStyle>> &styles)
|
||||
{
|
||||
sourceLayer->paint(painter, transform);
|
||||
}
|
|
@ -28,7 +28,7 @@ public:
|
|||
virtual QJsonObject toJson() const;
|
||||
virtual PixelPath getPaintObject() const = 0;
|
||||
virtual PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const = 0;
|
||||
virtual void paint(QPainter* painter, QTransform transform, std::vector<std::shared_ptr<LayerStyle>> styles) = 0;
|
||||
virtual void paint(QPainter* painter, QTransform transform, const std::vector<std::shared_ptr<LayerStyle>> &styles) = 0;
|
||||
};
|
||||
|
||||
class SimpleElement : public GraphicElement
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
~SimpleElement() = default;
|
||||
PixelPath getPaintObject() const override;
|
||||
PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const override;
|
||||
void paint(QPainter* painter, QTransform transform, std::vector<std::shared_ptr<LayerStyle>> styles) override;
|
||||
void paint(QPainter* painter, QTransform transform, const std::vector<std::shared_ptr<LayerStyle>> &styles) override;
|
||||
};
|
||||
|
||||
class GroupElement : public GraphicElement
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
PixelPath getPaintObject() const override;
|
||||
PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const override;
|
||||
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
||||
void paint(QPainter* painter, QTransform transform, std::vector<std::shared_ptr<LayerStyle>> styles) override;
|
||||
void paint(QPainter* painter, QTransform transform, const std::vector<std::shared_ptr<LayerStyle>> &styles) override;
|
||||
};
|
||||
|
||||
//******************************** BitmapPath ********************************//
|
||||
|
|
Loading…
Reference in New Issue