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