添加属性修改触发重新渲染的接口
parent
cee219409e
commit
fcd6c01127
|
@ -8,9 +8,12 @@ EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
|
|||
previewWindow = ui.Preview;
|
||||
treeWidget = ui.LayerTree;
|
||||
tabWidget = ui.DisplayTab;
|
||||
qDebug() << tabWidget;
|
||||
layerInfoDisplayWidget = dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(0));
|
||||
elementInfoDisplayWidget = dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(1));
|
||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidget::onLayerChange);
|
||||
qDebug() << "123";
|
||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
||||
&EditorWidget::triggerRefreshPreview);
|
||||
// &EditorWidget::triggerRefreshPreview);
|
||||
// test
|
||||
QFile settingFile;
|
||||
settingFile.setFileName("../data.json");
|
||||
|
@ -46,3 +49,8 @@ void EditorWidget::onLayerChange(LayerWrapper *layer)
|
|||
dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(0))->setLayer(layer);
|
||||
this->update();
|
||||
}
|
||||
|
||||
void EditorWidget::triggerRefreshPreview()
|
||||
{
|
||||
previewWindow->update();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ class EditorWidget : public QWidget
|
|||
Ui::EditorWidgetClass ui;
|
||||
LayerTreeWidget *treeWidget;
|
||||
QTabWidget *tabWidget;
|
||||
InfoDisplayWidget *layerInfoDisplayWidget, *elementInfoDisplayWidget;
|
||||
// QT DATA PART
|
||||
LayerWrapper *displayLayer;
|
||||
GraphicElement *displayElement;
|
||||
|
@ -33,4 +34,5 @@ class EditorWidget : public QWidget
|
|||
|
||||
private slots:
|
||||
void onLayerChange(LayerWrapper *layer);
|
||||
void triggerRefreshPreview();
|
||||
};
|
||||
|
|
|
@ -36,24 +36,42 @@ void InfoDisplayWidget::generateLayerForm()
|
|||
QLineEdit *rotation = new QLineEdit(QString::number(this->displayLayer->property.rotation, 'f', 0), this);
|
||||
QLineEdit *offsetX = new QLineEdit(QString::number(this->displayLayer->property.offset.x()), this);
|
||||
QLineEdit *offsetY = new QLineEdit(QString::number(this->displayLayer->property.offset.y()), this);
|
||||
QLineEdit *scaleX = new QLineEdit(QString::number(this->displayLayer->property.scale.x()), this);
|
||||
QLineEdit *scaleY = new QLineEdit(QString::number(this->displayLayer->property.scale.y()), this);
|
||||
name->setDisabled(true);
|
||||
rotation->setValidator(new QIntValidator(-1000, 1000, this));
|
||||
connect(rotation, &QLineEdit::textChanged,
|
||||
[=](QString content) { this->displayLayer->property.rotation = content.toDouble(); });
|
||||
connect(rotation, &QLineEdit::textChanged, [=](QString content) {
|
||||
this->displayLayer->property.rotation = content.toDouble();
|
||||
emit requireRefreshPreview();
|
||||
});
|
||||
offsetX->setValidator(new QIntValidator(-1000, 1000, this));
|
||||
connect(offsetX, &QLineEdit::textChanged, [=](QString content) {
|
||||
this->displayLayer->property.offset = {content.toDouble(), this->displayLayer->property.offset.y()};
|
||||
emit requireRefreshPreview();
|
||||
});
|
||||
offsetY->setValidator(new QIntValidator(-1000, 1000, this));
|
||||
connect(offsetY, &QLineEdit::textChanged, [=](QString content) {
|
||||
this->displayLayer->property.offset = {this->displayLayer->property.offset.x(), content.toDouble()};
|
||||
;
|
||||
emit requireRefreshPreview();
|
||||
});
|
||||
scaleX->setValidator(new QDoubleValidator(0.01, 100, 4, this));
|
||||
connect(scaleX, &QLineEdit::textChanged, [=](QString content) {
|
||||
this->displayLayer->property.scale = {content.toDouble(), this->displayLayer->property.scale.y()};
|
||||
emit requireRefreshPreview();
|
||||
});
|
||||
scaleY->setValidator(new QDoubleValidator(0.01, 100, 4, this));
|
||||
connect(scaleY, &QLineEdit::textChanged, [=](QString content) {
|
||||
this->displayLayer->property.scale = {this->displayLayer->property.scale.x(), content.toDouble()};
|
||||
emit requireRefreshPreview();
|
||||
});
|
||||
|
||||
layout->addRow("layer name:", name);
|
||||
layout->addRow("rotation:", rotation);
|
||||
layout->addRow("offset-X:", offsetX);
|
||||
layout->addRow("offset-Y:", offsetY);
|
||||
layout->addRow("scale-X:", scaleX);
|
||||
layout->addRow("scale-Y:", scaleY);
|
||||
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
|
||||
}
|
||||
this->setLayout(layout);
|
||||
}
|
||||
|
|
|
@ -17,4 +17,7 @@ class InfoDisplayWidget : public QWidget
|
|||
void setElement(GraphicElement *element);
|
||||
void generateLayerForm();
|
||||
void generateElementForm();
|
||||
|
||||
signals:
|
||||
void requireRefreshPreview();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue