diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp index 7e014db..f924e9c 100644 --- a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp +++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp @@ -2,8 +2,8 @@ #include "ColorPicker.h" #include #include +#include -#define radialStroke(stroke) std::dynamic_pointer_cast(stroke->materialStroke) constexpr int COLUMN_WIDTH = 0; constexpr int COLUMN_COLOR = 1; constexpr int COLUMN_METALLIC = 2; @@ -38,7 +38,7 @@ StrokeStyleWidget::StrokeStyleWidget( void StrokeStyleWidget::initStrokeSettings() { this->enableGradual = new QtMaterialCheckBox(this); - enableGradual->setText(QStringLiteral("启用渐变")); + enableGradual->setText(QStringLiteral("渐变")); enableGradual->setChecked(radialStroke(stroke)->gradual); connect(enableGradual, &QtMaterialCheckBox::toggled, [this](bool checked) { radialStroke(this->stroke)->gradual = checked; @@ -106,8 +106,11 @@ void StrokeStyleWidget::initTable(std::shared_ptrsetBackgroundColor(QtMaterialStyle::instance().themeColor("primary1")); strokeTable->setSpan(row, 0, 1, 5); strokeTable->setCellWidget(row, 0, addButton); + strokeTable->setMinimumHeight(strokeTable->rowHeight(row) * 5); + addButton->setFixedHeight(strokeTable->rowHeight(row)); connect(addButton, &QtMaterialRaisedButton::clicked, [this]() { handlingRowInsert = true; auto materialMap = &(radialStroke(this->stroke)->materialMap); @@ -160,6 +163,7 @@ void StrokeStyleWidget::setTableRow(int row, float width, Renderer::Material& ma strokeTable->setItem(row, COLUMN_ROUGHNESS, roughnessItem); QtMaterialRaisedButton* removeButton = new QtMaterialRaisedButton("-", strokeTable); + removeButton->setBackgroundColor(QtMaterialStyle::instance().themeColor("primary1")); removeButton->setFixedSize(20, 20); strokeTable->setCellWidget(row, COLUMN_OPERATIONS, removeButton); connect(removeButton, &QtMaterialRaisedButton::clicked, [this, row]() { diff --git a/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp b/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp index 215ec15..4c9b6b1 100644 --- a/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp +++ b/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp @@ -26,12 +26,18 @@ std::vector StrokeElementLayerStyle::toBaseStyles() const std::vector baseStyles; if (enableEachSideIndependent) { - baseStyles.push_back(Renderer::BaseStyle(std::make_shared(), - strokePair.first)); - baseStyles.push_back(Renderer::BaseStyle(std::make_shared(), - strokePair.second)); + if (radialStroke(strokePair.first)->materialMap.size()) + { + baseStyles.push_back(Renderer::BaseStyle(std::make_shared(), + strokePair.first)); + } + if (radialStroke(strokePair.second)->materialMap.size()) + { + baseStyles.push_back(Renderer::BaseStyle(std::make_shared(), + strokePair.second)); + } } - else + else if (radialStroke(strokePair.first)->materialMap.size()) { auto material = std::shared_ptr(std::move(strokePair.first->clone())); std::dynamic_pointer_cast(material)->strokeType = Renderer::StrokeType::kBothSides; @@ -78,9 +84,9 @@ QWidget* StrokeElementLayerStyle::getInputWidget() StrokeStyleWidget* leftStrokeView = new StrokeStyleWidget(this->strokePair.first, w); layout->addWidget(leftStrokeView); - + QtMaterialCheckBox* checkEachSideIndependent = new QtMaterialCheckBox(w); - checkEachSideIndependent->setText(QStringLiteral("启用两侧独立描边")); + checkEachSideIndependent->setText(QStringLiteral("右侧独立描边")); checkEachSideIndependent->setChecked(enableEachSideIndependent); layout->addWidget(checkEachSideIndependent); diff --git a/ArchitectureColoredPainting/src/Editor/LayerStyle.h b/ArchitectureColoredPainting/src/Editor/LayerStyle.h index 636201d..8edd10c 100644 --- a/ArchitectureColoredPainting/src/Editor/LayerStyle.h +++ b/ArchitectureColoredPainting/src/Editor/LayerStyle.h @@ -14,6 +14,7 @@ using Renderer::MaterialStyle; using Renderer::MaterialStyleStroke; #define STYLE_TYPENAME(name) static QString getTypeName() { return name; } +#define radialStroke(stroke) std::dynamic_pointer_cast(stroke->materialStroke) /** * 在进行Style的添加时,首先创建空对象,然后直接调用getInputWidget()方法 @@ -39,8 +40,6 @@ public: class StrokeElementLayerStyle : public LayerStyle { using PMaterialStyleStroke = std::shared_ptr; -private: - std::pair strokePair; public: STYLE_TYPENAME("stroke") @@ -56,6 +55,7 @@ public: QWidget* getListDisplayWidget() const override; QJsonObject toJson() const override; std::unique_ptr clone() const override; + std::pair strokePair; bool enableEachSideIndependent = false; };