[style/stroke] 完成所有设置控件
parent
1e3bef78f4
commit
7079b335cb
|
@ -1,7 +1,6 @@
|
||||||
#include "StrokeStyleWidget.h"
|
#include "StrokeStyleWidget.h"
|
||||||
#include "ColorPicker.h"
|
#include "ColorPicker.h"
|
||||||
#include <qtmaterialraisedbutton.h>
|
#include <qtmaterialraisedbutton.h>
|
||||||
#include <qtmaterialtextfield.h>
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#define radialStroke(stroke) std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(stroke->materialStroke)
|
#define radialStroke(stroke) std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(stroke->materialStroke)
|
||||||
|
@ -18,21 +17,19 @@ StrokeStyleWidget::StrokeStyleWidget(
|
||||||
QWidget* parent
|
QWidget* parent
|
||||||
) : QWidget(parent), stroke(stroke)
|
) : QWidget(parent), stroke(stroke)
|
||||||
{
|
{
|
||||||
this->viewLayout = new QVBoxLayout(this);
|
QVBoxLayout* viewLayout = new QVBoxLayout(this);
|
||||||
this->setLayout(viewLayout);
|
this->setLayout(viewLayout);
|
||||||
|
|
||||||
QtMaterialTextField* widthField = new QtMaterialTextField(this);
|
initStrokeSettings();
|
||||||
widthField->setLabel(QStringLiteral("±¾²àÃè±ß¿í¶È"));
|
QWidget* strokeProperties = new QWidget(this);
|
||||||
widthField->setText(QString::number(stroke->halfWidth));
|
QHBoxLayout* strokePropertiesLayout = new QHBoxLayout(strokeProperties);
|
||||||
QDoubleValidator* widthValidator = new QDoubleValidator(0.1, std::numeric_limits<float>::max(), 3, widthField);
|
strokePropertiesLayout->setMargin(0);
|
||||||
widthValidator->setNotation(QDoubleValidator::StandardNotation);
|
|
||||||
widthField->setValidator(widthValidator);
|
strokeProperties->setLayout(strokePropertiesLayout);
|
||||||
connect(widthField, &QtMaterialTextField::textChanged, [this, widthField](const QString& changed) {
|
strokePropertiesLayout->addWidget(enableGradual);
|
||||||
if (widthField->hasAcceptableInput())
|
strokePropertiesLayout->addWidget(endTypeBox);
|
||||||
{
|
|
||||||
this->stroke->halfWidth = changed.toFloat();
|
viewLayout->addWidget(strokeProperties);
|
||||||
}
|
|
||||||
});
|
|
||||||
viewLayout->addWidget(widthField);
|
viewLayout->addWidget(widthField);
|
||||||
|
|
||||||
initTable(std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(stroke->materialStroke));
|
initTable(std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(stroke->materialStroke));
|
||||||
|
@ -40,6 +37,54 @@ StrokeStyleWidget::StrokeStyleWidget(
|
||||||
this->adjustSize();
|
this->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StrokeStyleWidget::initStrokeSettings()
|
||||||
|
{
|
||||||
|
this->enableGradual = new QtMaterialCheckBox(this);
|
||||||
|
enableGradual->setText(QStringLiteral("启用渐变"));
|
||||||
|
enableGradual->setChecked(radialStroke(stroke)->gradual);
|
||||||
|
connect(enableGradual, &QtMaterialCheckBox::toggled, [this](bool checked) {
|
||||||
|
radialStroke(this->stroke)->gradual = checked;
|
||||||
|
});
|
||||||
|
|
||||||
|
#define endTypeBoxLabel(start, end) QStringLiteral(start##" -> "##end)
|
||||||
|
this->endTypeBox = new QComboBox(this);
|
||||||
|
endTypeBox->addItem(endTypeBoxLabel("圆头", "圆头")); // kRound
|
||||||
|
endTypeBox->addItem(endTypeBoxLabel("平头", "圆头")); // kFlatRound
|
||||||
|
endTypeBox->addItem(endTypeBoxLabel("圆头", "平头")); // kRoundFlat
|
||||||
|
endTypeBox->addItem(endTypeBoxLabel("平头", "平头")); // kFlat
|
||||||
|
endTypeBox->setCurrentIndex(static_cast<int>(this->stroke->endType));
|
||||||
|
connect(endTypeBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
this->stroke->endType = Renderer::StrokeEndType::kRound;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
this->stroke->endType = Renderer::StrokeEndType::kFlatRound;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
this->stroke->endType = Renderer::StrokeEndType::kRoundFlat;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
this->stroke->endType = Renderer::StrokeEndType::kFlat;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this->widthField = new QtMaterialTextField(this);
|
||||||
|
widthField->setLabel(QStringLiteral("本侧描边宽度"));
|
||||||
|
widthField->setText(QString::number(stroke->halfWidth));
|
||||||
|
QDoubleValidator* widthValidator = new QDoubleValidator(0.1, std::numeric_limits<float>::max(), 3, widthField);
|
||||||
|
widthValidator->setNotation(QDoubleValidator::StandardNotation);
|
||||||
|
widthField->setValidator(widthValidator);
|
||||||
|
connect(widthField, &QtMaterialTextField::textChanged, [this](const QString& changed) {
|
||||||
|
if (this->widthField->hasAcceptableInput())
|
||||||
|
{
|
||||||
|
this->stroke->halfWidth = changed.toFloat();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void StrokeStyleWidget::initTable(std::shared_ptr<Renderer::StrokeRadialGradient> materialStroke)
|
void StrokeStyleWidget::initTable(std::shared_ptr<Renderer::StrokeRadialGradient> materialStroke)
|
||||||
{
|
{
|
||||||
this->strokeTable = new QTableWidget(this);
|
this->strokeTable = new QTableWidget(this);
|
||||||
|
|
|
@ -3,15 +3,21 @@
|
||||||
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <qtmaterialtextfield.h>
|
||||||
|
#include <qtmaterialcheckbox.h>
|
||||||
class StrokeStyleWidget : public QWidget
|
class StrokeStyleWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QString currentItemValue;
|
QString currentItemValue;
|
||||||
|
|
||||||
QVBoxLayout* viewLayout;
|
QtMaterialCheckBox* enableGradual;
|
||||||
|
QComboBox* endTypeBox;
|
||||||
|
QtMaterialTextField* widthField;
|
||||||
QTableWidget* strokeTable;
|
QTableWidget* strokeTable;
|
||||||
|
|
||||||
|
void initStrokeSettings();
|
||||||
void initTable(std::shared_ptr<Renderer::StrokeRadialGradient> materialStroke);
|
void initTable(std::shared_ptr<Renderer::StrokeRadialGradient> materialStroke);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "LayerStyle.h"
|
#include "LayerStyle.h"
|
||||||
#include "./EditorWidgetComponent/StrokeStyleWidget.h"
|
#include "./EditorWidgetComponent/StrokeStyleWidget.h"
|
||||||
#include <qtmaterialcheckbox.h>
|
#include <qtmaterialcheckbox.h>
|
||||||
#include <qtmaterialtextfield.h>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
Loading…
Reference in New Issue