[stroke] 对GUI做出了一些改善

dev-LayerStyle
ArgonarioD 2023-03-17 20:55:41 +08:00
parent 096c3ac848
commit fb7caf407c
3 changed files with 21 additions and 11 deletions

View File

@ -2,8 +2,8 @@
#include "ColorPicker.h" #include "ColorPicker.h"
#include <qtmaterialraisedbutton.h> #include <qtmaterialraisedbutton.h>
#include <limits> #include <limits>
#include <lib/qtmaterialstyle.h>
#define radialStroke(stroke) std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(stroke->materialStroke)
constexpr int COLUMN_WIDTH = 0; constexpr int COLUMN_WIDTH = 0;
constexpr int COLUMN_COLOR = 1; constexpr int COLUMN_COLOR = 1;
constexpr int COLUMN_METALLIC = 2; constexpr int COLUMN_METALLIC = 2;
@ -38,7 +38,7 @@ StrokeStyleWidget::StrokeStyleWidget(
void StrokeStyleWidget::initStrokeSettings() void StrokeStyleWidget::initStrokeSettings()
{ {
this->enableGradual = new QtMaterialCheckBox(this); this->enableGradual = new QtMaterialCheckBox(this);
enableGradual->setText(QStringLiteral("启用渐变")); enableGradual->setText(QStringLiteral("½¥±ä"));
enableGradual->setChecked(radialStroke(stroke)->gradual); enableGradual->setChecked(radialStroke(stroke)->gradual);
connect(enableGradual, &QtMaterialCheckBox::toggled, [this](bool checked) { connect(enableGradual, &QtMaterialCheckBox::toggled, [this](bool checked) {
radialStroke(this->stroke)->gradual = checked; radialStroke(this->stroke)->gradual = checked;
@ -106,8 +106,11 @@ void StrokeStyleWidget::initTable(std::shared_ptr<Renderer::StrokeRadialGradient
} }
// ÐÂÔö°´Å¥ // ÐÂÔö°´Å¥
QtMaterialRaisedButton* addButton = new QtMaterialRaisedButton("+", strokeTable); QtMaterialRaisedButton* addButton = new QtMaterialRaisedButton("+", strokeTable);
addButton->setBackgroundColor(QtMaterialStyle::instance().themeColor("primary1"));
strokeTable->setSpan(row, 0, 1, 5); strokeTable->setSpan(row, 0, 1, 5);
strokeTable->setCellWidget(row, 0, addButton); strokeTable->setCellWidget(row, 0, addButton);
strokeTable->setMinimumHeight(strokeTable->rowHeight(row) * 5);
addButton->setFixedHeight(strokeTable->rowHeight(row));
connect(addButton, &QtMaterialRaisedButton::clicked, [this]() { connect(addButton, &QtMaterialRaisedButton::clicked, [this]() {
handlingRowInsert = true; handlingRowInsert = true;
auto materialMap = &(radialStroke(this->stroke)->materialMap); 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); strokeTable->setItem(row, COLUMN_ROUGHNESS, roughnessItem);
QtMaterialRaisedButton* removeButton = new QtMaterialRaisedButton("-", strokeTable); QtMaterialRaisedButton* removeButton = new QtMaterialRaisedButton("-", strokeTable);
removeButton->setBackgroundColor(QtMaterialStyle::instance().themeColor("primary1"));
removeButton->setFixedSize(20, 20); removeButton->setFixedSize(20, 20);
strokeTable->setCellWidget(row, COLUMN_OPERATIONS, removeButton); strokeTable->setCellWidget(row, COLUMN_OPERATIONS, removeButton);
connect(removeButton, &QtMaterialRaisedButton::clicked, [this, row]() { connect(removeButton, &QtMaterialRaisedButton::clicked, [this, row]() {

View File

@ -26,12 +26,18 @@ std::vector<Renderer::BaseStyle> StrokeElementLayerStyle::toBaseStyles() const
std::vector<Renderer::BaseStyle> baseStyles; std::vector<Renderer::BaseStyle> baseStyles;
if (enableEachSideIndependent) if (enableEachSideIndependent)
{ {
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(), if (radialStroke(strokePair.first)->materialMap.size())
strokePair.first)); {
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(), baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
strokePair.second)); strokePair.first));
}
if (radialStroke(strokePair.second)->materialMap.size())
{
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
strokePair.second));
}
} }
else else if (radialStroke(strokePair.first)->materialMap.size())
{ {
auto material = std::shared_ptr<MaterialStyle>(std::move(strokePair.first->clone())); auto material = std::shared_ptr<MaterialStyle>(std::move(strokePair.first->clone()));
std::dynamic_pointer_cast<MaterialStyleStroke>(material)->strokeType = Renderer::StrokeType::kBothSides; std::dynamic_pointer_cast<MaterialStyleStroke>(material)->strokeType = Renderer::StrokeType::kBothSides;
@ -78,9 +84,9 @@ QWidget* StrokeElementLayerStyle::getInputWidget()
StrokeStyleWidget* leftStrokeView = new StrokeStyleWidget(this->strokePair.first, w); StrokeStyleWidget* leftStrokeView = new StrokeStyleWidget(this->strokePair.first, w);
layout->addWidget(leftStrokeView); layout->addWidget(leftStrokeView);
QtMaterialCheckBox* checkEachSideIndependent = new QtMaterialCheckBox(w); QtMaterialCheckBox* checkEachSideIndependent = new QtMaterialCheckBox(w);
checkEachSideIndependent->setText(QStringLiteral("启用两侧独立描边")); checkEachSideIndependent->setText(QStringLiteral("ÓÒ²à¶ÀÁ¢Ãè±ß"));
checkEachSideIndependent->setChecked(enableEachSideIndependent); checkEachSideIndependent->setChecked(enableEachSideIndependent);
layout->addWidget(checkEachSideIndependent); layout->addWidget(checkEachSideIndependent);

View File

@ -14,6 +14,7 @@ using Renderer::MaterialStyle;
using Renderer::MaterialStyleStroke; using Renderer::MaterialStyleStroke;
#define STYLE_TYPENAME(name) static QString getTypeName() { return name; } #define STYLE_TYPENAME(name) static QString getTypeName() { return name; }
#define radialStroke(stroke) std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(stroke->materialStroke)
/** /**
* StylegetInputWidget() * StylegetInputWidget()
@ -39,8 +40,6 @@ public:
class StrokeElementLayerStyle : public LayerStyle class StrokeElementLayerStyle : public LayerStyle
{ {
using PMaterialStyleStroke = std::shared_ptr<MaterialStyleStroke>; using PMaterialStyleStroke = std::shared_ptr<MaterialStyleStroke>;
private:
std::pair<PMaterialStyleStroke, PMaterialStyleStroke> strokePair;
public: public:
STYLE_TYPENAME("stroke") STYLE_TYPENAME("stroke")
@ -56,6 +55,7 @@ public:
QWidget* getListDisplayWidget() const override; QWidget* getListDisplayWidget() const override;
QJsonObject toJson() const override; QJsonObject toJson() const override;
std::unique_ptr<LayerStyle> clone() const override; std::unique_ptr<LayerStyle> clone() const override;
std::pair<PMaterialStyleStroke, PMaterialStyleStroke> strokePair;
bool enableEachSideIndependent = false; bool enableEachSideIndependent = false;
}; };