parent
21aeb0832b
commit
0aa69195b3
|
@ -18,6 +18,11 @@ inline Renderer::Material newMaterial()
|
|||
return {ColorHelper::instance().getPrimary1()};
|
||||
}
|
||||
|
||||
inline bool isClosedStroke(const std::shared_ptr<MaterialStyleStroke>& stroke)
|
||||
{
|
||||
return stroke->endType == Renderer::StrokeEndType::kClosed;
|
||||
}
|
||||
|
||||
StrokeStyleWidget::StrokeStyleWidget(
|
||||
const std::shared_ptr<MaterialStyleStroke>& stroke,
|
||||
QWidget* parent
|
||||
|
@ -39,7 +44,10 @@ StrokeStyleWidget::StrokeStyleWidget(
|
|||
|
||||
strokeProperties->setLayout(strokePropertiesLayout);
|
||||
strokePropertiesLayout->addWidget(enableGradual);
|
||||
strokePropertiesLayout->addWidget(endTypeBox);
|
||||
if (!isClosedStroke(stroke))
|
||||
{
|
||||
strokePropertiesLayout->addWidget(endTypeBox);
|
||||
}
|
||||
|
||||
viewLayout->addWidget(strokeProperties);
|
||||
viewLayout->addWidget(widthField);
|
||||
|
@ -61,17 +69,24 @@ void StrokeStyleWidget::initStrokeSettings()
|
|||
connect(enableGradual, &QtMaterialCheckBox::toggled, [this](bool checked) {
|
||||
radialStroke(this->stroke)->gradual = checked;
|
||||
});
|
||||
|
||||
this->endTypeBox = new QComboBox(this);
|
||||
for (const auto& displayName : MaterialStyleStroke::strokeEndTypeNames | std::views::keys)
|
||||
|
||||
if (!isClosedStroke(stroke))
|
||||
{
|
||||
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);
|
||||
widthField->setLabel(QStringLiteral("±¾²àÃè±ß¿í¶È"));
|
||||
|
|
|
@ -78,7 +78,7 @@ QWidget* StrokeElementLayerStyle::getListDisplayWidget() const
|
|||
void LayerStyleContainer::computeNewHash()
|
||||
{
|
||||
hash = 0;
|
||||
for (auto& f : styles
|
||||
for (auto& f : styles
|
||||
| std::views::values
|
||||
| std::views::transform(&LayerStyle::toBaseStyles)
|
||||
| std::views::join
|
||||
|
@ -248,18 +248,18 @@ std::unique_ptr<StrokeElementLayerStyle> StrokeElementLayerStyle::fromJson(const
|
|||
return ptr;
|
||||
}
|
||||
|
||||
StrokeElementLayerStyle::StrokeElementLayerStyle()
|
||||
StrokeElementLayerStyle::StrokeElementLayerStyle(bool isClosed)
|
||||
{
|
||||
const auto materialMap = std::map<float, Renderer::Material>();
|
||||
this->strokePair.first = std::make_shared<MaterialStyleStroke>(
|
||||
7,
|
||||
Renderer::StrokeType::kLeftSide, Renderer::StrokeEndType::kFlat,
|
||||
Renderer::StrokeType::kLeftSide, isClosed ? Renderer::StrokeEndType::kClosed : Renderer::StrokeEndType::kFlat,
|
||||
std::make_shared<Renderer::StrokeRadialGradient>(materialMap, false)
|
||||
);
|
||||
|
||||
this->strokePair.second = std::make_shared<MaterialStyleStroke>(
|
||||
7,
|
||||
Renderer::StrokeType::kRightSide, Renderer::StrokeEndType::kFlat,
|
||||
Renderer::StrokeType::kRightSide, isClosed ? Renderer::StrokeEndType::kClosed : Renderer::StrokeEndType::kFlat,
|
||||
std::make_shared<Renderer::StrokeRadialGradient>(materialMap, false)
|
||||
);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
STYLE_NAME("Ãè±ß", "stroke")
|
||||
static std::unique_ptr<StrokeElementLayerStyle> fromJson(const QJsonObject& json);
|
||||
|
||||
StrokeElementLayerStyle();
|
||||
StrokeElementLayerStyle(bool isClosed);
|
||||
StrokeElementLayerStyle(const PMaterialStyleStroke& left, const PMaterialStyleStroke& right = nullptr);
|
||||
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
||||
~StrokeElementLayerStyle() override = default;
|
||||
|
@ -88,17 +88,23 @@ public:
|
|||
class LayerStyleContainer : public Renderer::ElementStyle
|
||||
{
|
||||
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(),
|
||||
[] { 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 usedStyles;
|
||||
|
|
Loading…
Reference in New Issue