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