Compare commits
No commits in common. "c81c7d69d4317a1f8663f16869b3b3e3ffef0582" and "e0813ba364d5b346f236ca5e390559ea5c96d1ca" have entirely different histories.
c81c7d69d4
...
e0813ba364
|
@ -54,19 +54,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QPushButton" name="resizeButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>设置画布尺寸</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -70,9 +70,9 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
<y>-17</y>
|
||||
<width>1024</width>
|
||||
<height>1024</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -83,14 +83,14 @@
|
|||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
<width>1024</width>
|
||||
<height>1024</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
<width>1024</width>
|
||||
<height>1024</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
|
@ -40,7 +40,6 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
//connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
||||
connect(editorSettingWidget, &EditorSettingWidget::canvasSizeChanged, previewWindow, &PreviewWindow::resize);
|
||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
||||
// &EditorWidgetItem::triggerRefreshPreview);
|
||||
// connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
|
||||
|
@ -73,7 +72,7 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
elementInfoDisplayWidget->setElementManager(elementManager);
|
||||
treeWidget->elementManager = elementManager;
|
||||
//qDebug() << layerManager->toJson();
|
||||
previewWindow->initialize(layerManager,QSize(jsonDoc.object().value("width").toInt(),jsonDoc.object().value("height").toInt()));
|
||||
previewWindow->initialize(layerManager,QSize(jsonDoc.object().value("width").toDouble(),jsonDoc.object().value("height").toDouble()));
|
||||
|
||||
|
||||
if (layerManager->getRoot() != nullptr)
|
||||
|
@ -152,8 +151,8 @@ void EditorWidgetItem::saveImpl(QString filePath) const
|
|||
QJsonObject source1 = layerManager->toJson();
|
||||
QJsonObject source2 = elementManager->toJson();
|
||||
QJsonObject json;
|
||||
json.insert("width", previewWindow->referSize.width());
|
||||
json.insert("height", previewWindow->referSize.height());
|
||||
json.insert("width", 1080);
|
||||
json.insert("height", 1080);
|
||||
json.insert("root-layer", source1.value("root-layer"));
|
||||
json.insert("elements", source2.value("elements"));
|
||||
json.insert("project-name", this->projectName);
|
||||
|
|
|
@ -18,32 +18,11 @@ PreviewWindow::PreviewWindow(QWidget* parent) : QOpenGLWidget(parent)
|
|||
backgroundColor = QColor(255, 255, 255, 255);
|
||||
}
|
||||
|
||||
void PreviewWindow::initialize(LayerManager* layerManager, QSize referSize, QSize windowSize)
|
||||
void PreviewWindow::initialize(LayerManager* layerManager, QSize windowSize)
|
||||
{
|
||||
this->logicalSize = windowSize;
|
||||
this->layerManager = layerManager;
|
||||
this->resize(referSize);
|
||||
}
|
||||
|
||||
void PreviewWindow::resize(QSize _referSize)
|
||||
{
|
||||
if (!_referSize.isValid())
|
||||
return;
|
||||
if (_referSize.width() == 0 || _referSize.height() == 0)
|
||||
return;
|
||||
this->referSize = _referSize;
|
||||
if (referSize.width() > referSize.height())
|
||||
{
|
||||
actualSize.setWidth(logicalSize.width());
|
||||
actualSize.setHeight(logicalSize.width() * referSize.height() / referSize.width());
|
||||
}
|
||||
else
|
||||
{
|
||||
actualSize.setHeight(logicalSize.height());
|
||||
actualSize.setWidth(logicalSize.height() * referSize.width() / referSize.height());
|
||||
}
|
||||
this->setFixedSize(actualSize);
|
||||
this->viewportRect = QRectF(QPointF(0, 0), actualSize);
|
||||
this->setFixedSize(windowSize);
|
||||
}
|
||||
|
||||
void PreviewWindow::show()
|
||||
|
@ -72,7 +51,7 @@ void PreviewWindow::paintGL()
|
|||
glClearColor(backgroundColor.redF(), backgroundColor.greenF(), backgroundColor.blueF(), backgroundColor.alphaF());
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
painter->begin(this);
|
||||
painter->setWindow(0, 0, actualSize.width() * devicePixelRatioF(), actualSize.height() * devicePixelRatioF());
|
||||
painter->setWindow(0, 0, logicalSize.width() * devicePixelRatioF(), logicalSize.height() * devicePixelRatioF());
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
layerManager->paint(painter, this->size(), currentLayer);
|
||||
|
@ -162,12 +141,12 @@ void PreviewWindow::wheelEvent(QWheelEvent* event)
|
|||
if (event->delta() > 0 && zoomStep < ZOOM_STEP_MAX)
|
||||
{
|
||||
zoomStep++;
|
||||
this->setFixedSize(actualSize * (1 + zoomStep * ZOOM_RATE));
|
||||
this->setFixedSize(logicalSize * (1 + zoomStep * ZOOM_RATE));
|
||||
}
|
||||
else if (event->delta() < 0 && zoomStep > ZOOM_STEP_MIN)
|
||||
{
|
||||
zoomStep--;
|
||||
this->setFixedSize(actualSize * (1 + zoomStep * ZOOM_RATE));
|
||||
this->setFixedSize(logicalSize * (1 + zoomStep * ZOOM_RATE));
|
||||
}
|
||||
this->repaint();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
|||
LayerManager *layerManager;
|
||||
Renderer::ElementRenderer* renderer;
|
||||
QSize logicalSize;
|
||||
QSize actualSize;
|
||||
QRectF viewportRect;
|
||||
LayerWrapper* currentLayer;
|
||||
QPointF m_lastPos;
|
||||
|
@ -39,10 +38,8 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
|||
void wheelEvent(QWheelEvent* event) override;
|
||||
|
||||
public:
|
||||
QSize referSize;
|
||||
PreviewWindow(QWidget *parent = nullptr);
|
||||
void initialize(LayerManager *layerManager,QSize referSize, QSize windowSize = QSize(720, 720));
|
||||
void resize(QSize _referSize);
|
||||
void initialize(LayerManager *layerManager, QSize windowSize = QSize(1920, 1080));
|
||||
void show();
|
||||
void initializeGL() override;
|
||||
void paintGL() override;
|
||||
|
|
|
@ -18,9 +18,4 @@ EditorSettingWidget::EditorSettingWidget(QWidget* parent)
|
|||
QString name = QInputDialog::getText(this, QString::fromLocal8Bit("重命名"), QString::fromLocal8Bit("请输入新的项目名称"));
|
||||
emit projectNameChanged(name);
|
||||
});
|
||||
connect(ui.resizeButton, &QPushButton::clicked, this, [this]() {
|
||||
int width = QInputDialog::getInt(this, QString::fromLocal8Bit("重设画布大小"), QString::fromLocal8Bit("请输入新的画布宽度"));
|
||||
int height = QInputDialog::getInt(this, QString::fromLocal8Bit("重设画布大小"), QString::fromLocal8Bit("请输入新的画布高度"));
|
||||
emit canvasSizeChanged(QSize(width, height));
|
||||
});
|
||||
}
|
|
@ -16,6 +16,6 @@ class EditorSettingWidget :
|
|||
signals:
|
||||
void backgroundColorChanged(QColor);
|
||||
void projectNameChanged(QString);
|
||||
void canvasSizeChanged(QSize);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue