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