feat: add viewport rounded corners
This commit is contained in:
@@ -16,6 +16,9 @@ EnzoUI::EnzoUI()
|
|||||||
constexpr float scale = 0.8;
|
constexpr float scale = 0.8;
|
||||||
resize(1920*scale, 1080*scale);
|
resize(1920*scale, 1080*scale);
|
||||||
|
|
||||||
|
// TODO: unify stylsheet
|
||||||
|
setStyleSheet("background-color:#1d2021;");
|
||||||
|
|
||||||
Viewport* viewport = new Viewport();
|
Viewport* viewport = new Viewport();
|
||||||
Network* network = new Network(this);
|
Network* network = new Network(this);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Network::Network(QWidget* parent)
|
|||||||
{
|
{
|
||||||
|
|
||||||
mainLayout_ = new QVBoxLayout(parent);
|
mainLayout_ = new QVBoxLayout(parent);
|
||||||
mainLayout_->setContentsMargins(0,0,0,0);
|
// mainLayout_->setContentsMargins(0,0,0,0);
|
||||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
|
|
||||||
@@ -73,7 +73,8 @@ Network::Network(QWidget* parent)
|
|||||||
void Network::resizeEvent(QResizeEvent *event)
|
void Network::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addRoundedRect(this->rect(), 15, 15);
|
constexpr float radius = 10;
|
||||||
|
path.addRoundedRect(mainLayout_->contentsRect(), radius, radius);
|
||||||
QRegion region = QRegion(path.toFillPolygon().toPolygon());
|
QRegion region = QRegion(path.toFillPolygon().toPolygon());
|
||||||
this->setMask(region);
|
this->setMask(region);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <qpushbutton.h>
|
#include <qpushbutton.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QPainterPath>
|
||||||
|
|
||||||
Viewport::Viewport(QWidget *parent, Qt::WindowFlags f)
|
Viewport::Viewport(QWidget *parent, Qt::WindowFlags f)
|
||||||
: QWidget(parent, f)
|
: QWidget(parent, f)
|
||||||
@@ -22,3 +23,11 @@ Viewport::Viewport(QWidget *parent, Qt::WindowFlags f)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Viewport::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
constexpr float radius = 10;
|
||||||
|
path.addRoundedRect(mainLayout_->contentsRect(), radius, radius);
|
||||||
|
QRegion region = QRegion(path.toFillPolygon().toPolygon());
|
||||||
|
this->setMask(region);
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
QVBoxLayout* mainLayout_;
|
QVBoxLayout* mainLayout_;
|
||||||
MyGLWidget* openGLWidget_;
|
MyGLWidget* openGLWidget_;
|
||||||
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user