parent
21aeb0832b
commit
0aa69195b3
|
@ -18,6 +18,11 @@ inline Renderer::Material newMaterial()
|
||||||
return {ColorHelper::instance().getPrimary1()};
|
return {ColorHelper::instance().getPrimary1()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool isClosedStroke(const std::shared_ptr<MaterialStyleStroke>& stroke)
|
||||||
|
{
|
||||||
|
return stroke->endType == Renderer::StrokeEndType::kClosed;
|
||||||
|
}
|
||||||
|
|
||||||
StrokeStyleWidget::StrokeStyleWidget(
|
StrokeStyleWidget::StrokeStyleWidget(
|
||||||
const std::shared_ptr<MaterialStyleStroke>& stroke,
|
const std::shared_ptr<MaterialStyleStroke>& stroke,
|
||||||
QWidget* parent
|
QWidget* parent
|
||||||
|
@ -39,7 +44,10 @@ StrokeStyleWidget::StrokeStyleWidget(
|
||||||
|
|
||||||
strokeProperties->setLayout(strokePropertiesLayout);
|
strokeProperties->setLayout(strokePropertiesLayout);
|
||||||
strokePropertiesLayout->addWidget(enableGradual);
|
strokePropertiesLayout->addWidget(enableGradual);
|
||||||
strokePropertiesLayout->addWidget(endTypeBox);
|
if (!isClosedStroke(stroke))
|
||||||
|
{
|
||||||
|
strokePropertiesLayout->addWidget(endTypeBox);
|
||||||
|
}
|
||||||
|
|
||||||
viewLayout->addWidget(strokeProperties);
|
viewLayout->addWidget(strokeProperties);
|
||||||
viewLayout->addWidget(widthField);
|
viewLayout->addWidget(widthField);
|
||||||
|
@ -62,16 +70,23 @@ void StrokeStyleWidget::initStrokeSettings()
|
||||||
radialStroke(this->stroke)->gradual = checked;
|
radialStroke(this->stroke)->gradual = checked;
|
||||||
});
|
});
|
||||||
|
|
||||||
this->endTypeBox = new QComboBox(this);
|
if (!isClosedStroke(stroke))
|
||||||
for (const auto& displayName : MaterialStyleStroke::strokeEndTypeNames | std::views::keys)
|
|
||||||
{
|
{
|
||||||
endTypeBox->addItem(displayName);
|
this->endTypeBox = new QComboBox(this);
|
||||||
|
for (const auto& displayName : MaterialStyleStroke::strokeEndTypeNames | std::views::keys)
|
||||||
|
{
|
||||||
|
endTypeBox->addItem(displayName);
|
||||||
|
}
|
||||||
|
endTypeBox->setCurrentIndex(static_cast<int>(this->stroke->endType));
|
||||||
|
connect(endTypeBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
|
||||||
|
const auto& [displayName, endType] = MaterialStyleStroke::strokeEndTypeNames[index];
|
||||||
|
this->stroke->endType = endType;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->endTypeBox = nullptr;
|
||||||
}
|
}
|
||||||
endTypeBox->setCurrentIndex(static_cast<int>(this->stroke->endType));
|
|
||||||
connect(endTypeBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
|
|
||||||
const auto& [displayName, endType] = MaterialStyleStroke::strokeEndTypeNames[index];
|
|
||||||
this->stroke->endType = endType;
|
|
||||||
});
|
|
||||||
|
|
||||||
this->widthField = new QtMaterialTextField(this);
|
this->widthField = new QtMaterialTextField(this);
|
||||||
widthField->setLabel(QStringLiteral("±¾²àÃè±ß¿í¶È"));
|
widthField->setLabel(QStringLiteral("±¾²àÃè±ß¿í¶È"));
|
||||||
|
|
|
@ -248,18 +248,18 @@ std::unique_ptr<StrokeElementLayerStyle> StrokeElementLayerStyle::fromJson(const
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
StrokeElementLayerStyle::StrokeElementLayerStyle()
|
StrokeElementLayerStyle::StrokeElementLayerStyle(bool isClosed)
|
||||||
{
|
{
|
||||||
const auto materialMap = std::map<float, Renderer::Material>();
|
const auto materialMap = std::map<float, Renderer::Material>();
|
||||||
this->strokePair.first = std::make_shared<MaterialStyleStroke>(
|
this->strokePair.first = std::make_shared<MaterialStyleStroke>(
|
||||||
7,
|
7,
|
||||||
Renderer::StrokeType::kLeftSide, Renderer::StrokeEndType::kFlat,
|
Renderer::StrokeType::kLeftSide, isClosed ? Renderer::StrokeEndType::kClosed : Renderer::StrokeEndType::kFlat,
|
||||||
std::make_shared<Renderer::StrokeRadialGradient>(materialMap, false)
|
std::make_shared<Renderer::StrokeRadialGradient>(materialMap, false)
|
||||||
);
|
);
|
||||||
|
|
||||||
this->strokePair.second = std::make_shared<MaterialStyleStroke>(
|
this->strokePair.second = std::make_shared<MaterialStyleStroke>(
|
||||||
7,
|
7,
|
||||||
Renderer::StrokeType::kRightSide, Renderer::StrokeEndType::kFlat,
|
Renderer::StrokeType::kRightSide, isClosed ? Renderer::StrokeEndType::kClosed : Renderer::StrokeEndType::kFlat,
|
||||||
std::make_shared<Renderer::StrokeRadialGradient>(materialMap, false)
|
std::make_shared<Renderer::StrokeRadialGradient>(materialMap, false)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
STYLE_NAME("Ãè±ß", "stroke")
|
STYLE_NAME("Ãè±ß", "stroke")
|
||||||
static std::unique_ptr<StrokeElementLayerStyle> fromJson(const QJsonObject& json);
|
static std::unique_ptr<StrokeElementLayerStyle> fromJson(const QJsonObject& json);
|
||||||
|
|
||||||
StrokeElementLayerStyle();
|
StrokeElementLayerStyle(bool isClosed);
|
||||||
StrokeElementLayerStyle(const PMaterialStyleStroke& left, const PMaterialStyleStroke& right = nullptr);
|
StrokeElementLayerStyle(const PMaterialStyleStroke& left, const PMaterialStyleStroke& right = nullptr);
|
||||||
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
||||||
~StrokeElementLayerStyle() override = default;
|
~StrokeElementLayerStyle() override = default;
|
||||||
|
@ -88,17 +88,23 @@ public:
|
||||||
class LayerStyleContainer : public Renderer::ElementStyle
|
class LayerStyleContainer : public Renderer::ElementStyle
|
||||||
{
|
{
|
||||||
using DisplayNameWithSupplier = std::map<QString, std::function<std::unique_ptr<LayerStyle>()>>;
|
using DisplayNameWithSupplier = std::map<QString, std::function<std::unique_ptr<LayerStyle>()>>;
|
||||||
private:
|
|
||||||
|
|
||||||
inline const static DisplayNameWithSupplier commonStyles = { {
|
private:
|
||||||
|
inline const static DisplayNameWithSupplier commonStyles = { };
|
||||||
|
inline const static DisplayNameWithSupplier closedOnlyStyles = {
|
||||||
|
{
|
||||||
|
FillElementLayerStyle::displayName(),
|
||||||
|
[] { return std::make_unique<FillElementLayerStyle>(); }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
StrokeElementLayerStyle::displayName(),
|
||||||
|
[] { return std::make_unique<StrokeElementLayerStyle>(true); }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
inline const static DisplayNameWithSupplier unclosedOnlyStyles = { {
|
||||||
StrokeElementLayerStyle::displayName(),
|
StrokeElementLayerStyle::displayName(),
|
||||||
[] { return std::make_unique<StrokeElementLayerStyle>(); }
|
[] { return std::make_unique<StrokeElementLayerStyle>(false); }
|
||||||
} };
|
} };
|
||||||
inline const static DisplayNameWithSupplier closedOnlyStyles = { {
|
|
||||||
FillElementLayerStyle::displayName(),
|
|
||||||
[] { return std::make_unique<FillElementLayerStyle>(); }
|
|
||||||
} };
|
|
||||||
inline const static DisplayNameWithSupplier unclosedOnlyStyles = { };
|
|
||||||
|
|
||||||
DisplayNameWithSupplier unusedStyles;
|
DisplayNameWithSupplier unusedStyles;
|
||||||
DisplayNameWithSupplier usedStyles;
|
DisplayNameWithSupplier usedStyles;
|
||||||
|
|
Loading…
Reference in New Issue