窗口缩放
parent
ab402955cd
commit
28ea0dd394
|
@ -11,9 +11,9 @@ LayerWrapper *LayerManager::getRoot() const
|
||||||
{
|
{
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
void LayerManager::paint(QPainter *painter) const
|
void LayerManager::paint(QPainter *painter, QSize size) const
|
||||||
{
|
{
|
||||||
auto p = root->getCache().getPixmap();
|
auto p = root->getCache().resizedPixel(size);
|
||||||
painter->drawPixmap(0, 0, p);
|
painter->drawPixmap(0, 0, p);
|
||||||
}
|
}
|
||||||
bool LayerManager::singleSelectedCheck() const
|
bool LayerManager::singleSelectedCheck() const
|
||||||
|
|
|
@ -30,8 +30,8 @@ class LayerManager
|
||||||
void removeLayer(LayerWrapper *layer);
|
void removeLayer(LayerWrapper *layer);
|
||||||
LayerWrapper *getRoot() const;
|
LayerWrapper *getRoot() const;
|
||||||
LayerManager() = default;
|
LayerManager() = default;
|
||||||
LayerManager(QJsonObject source, ElementManager *elementManager);
|
LayerManager(QJsonObject source, ElementManager* elementManager);
|
||||||
void paint(QPainter *painter) const;
|
void paint(QPainter *painter, QSize size) const;
|
||||||
bool rename(QString newName) const;
|
bool rename(QString newName) const;
|
||||||
bool combine() const;
|
bool combine() const;
|
||||||
// bool seperate() const;
|
// bool seperate() const;
|
||||||
|
|
|
@ -74,3 +74,15 @@ PixelPath PixelPath::trans(QTransform& mat)const
|
||||||
result.boundingRect = mat.mapRect(boundingRect);
|
result.boundingRect = mat.mapRect(boundingRect);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPixmap PixelPath::resizedPixel(QSize size)const
|
||||||
|
{
|
||||||
|
QPixmap result(size);
|
||||||
|
result.fill(Qt::transparent);
|
||||||
|
QPainter painter(&result);
|
||||||
|
|
||||||
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
|
painter.drawPixmap(0, 0, pixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -12,8 +12,8 @@ private:
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
int w,h;
|
int w,h;
|
||||||
public:
|
public:
|
||||||
PixelPath(int w=2400, int h= 2400);
|
PixelPath(int w=1920, int h= 1080);
|
||||||
PixelPath(QPainterPath painterPath,int w = 2400, int h = 2400);
|
PixelPath(QPainterPath painterPath,int w = 1920, int h = 1080);
|
||||||
~PixelPath() = default;
|
~PixelPath() = default;
|
||||||
QRectF getBoundingRect() const;
|
QRectF getBoundingRect() const;
|
||||||
QPixmap getPixmap() const;
|
QPixmap getPixmap() const;
|
||||||
|
@ -22,4 +22,5 @@ public:
|
||||||
void addImage(const QImage& image,const QPointF& pos);
|
void addImage(const QImage& image,const QPointF& pos);
|
||||||
void clear();
|
void clear();
|
||||||
PixelPath trans(QTransform& mat)const;
|
PixelPath trans(QTransform& mat)const;
|
||||||
|
QPixmap resizedPixel(QSize size)const;
|
||||||
};
|
};
|
|
@ -14,7 +14,7 @@ PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
|
||||||
|
|
||||||
void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize)
|
void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize)
|
||||||
{
|
{
|
||||||
this->setFixedSize(windowSize);
|
this->logicalSize = windowSize;
|
||||||
this->layerManager = layerManager;
|
this->layerManager = layerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ void PreviewWindow::paintGL()
|
||||||
painter->begin(this);
|
painter->begin(this);
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
layerManager->paint(painter);
|
layerManager->paint(painter,this->size());
|
||||||
painter->end();
|
painter->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
QPainter *painter;
|
QPainter *painter;
|
||||||
LayerManager *layerManager;
|
LayerManager *layerManager;
|
||||||
Renderer::ElementRenderer* renderer;
|
Renderer::ElementRenderer* renderer;
|
||||||
|
QSize logicalSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PreviewWindow(QWidget *parent = nullptr);
|
PreviewWindow(QWidget *parent = nullptr);
|
||||||
|
|
Loading…
Reference in New Issue