Display layout improvements

This commit is contained in:
GPayne
2022-01-02 19:09:24 -07:00
parent fdf56ef994
commit 3a61bd601b
4 changed files with 48 additions and 14 deletions

View File

@@ -48,6 +48,7 @@ private:
QPushButton* _toggleNumMonitorsButton = nullptr;
MonitorBox* _monBox = nullptr;
QVBoxLayout* _layout = nullptr;
QHBoxLayout* _layoutMonBox = nullptr;
QHBoxLayout* _layoutMonButton = nullptr;
QHBoxLayout* _layoutWindows = nullptr;
std::vector<QVBoxLayout*> _winCtrlLayouts;

View File

@@ -28,6 +28,7 @@ public:
void setDimensions(const QRectF& dimensions);
void setWindowScaleFactor(float scaleFactor);
void setWindowChangeCallback(std::function<void(unsigned int, const QRectF&)> cb);
void cleanupLayouts();
QVBoxLayout* initializeLayout(QWidget* parentWidget/*, QHBoxLayout* layout*/);
QRectF& dimensions();
QLineEdit* lineEditSizeWidth();
@@ -52,7 +53,7 @@ private:
{50.0, 50.0, 800.0, 600.0},
{900.0, 400.0, 640.0, 480.0}
};
int _lineEditWidthFixed = 80;
int _lineEditWidthFixed = 50;
float _marginFractionOfWidgetSize = 0.025;
int _index = 0;
@@ -80,6 +81,8 @@ private:
QLabel* _labelOffset = nullptr;
QLabel* _labelComma = nullptr;
QHBoxLayout* _layoutOffset = nullptr;
QHBoxLayout* _layoutCheckboxesFull1 = nullptr;
QVBoxLayout* _layoutCheckboxesFull2 = nullptr;
QHBoxLayout* _layoutCBoxFullscreen = nullptr;
QHBoxLayout* _layoutCBoxVsync = nullptr;
QHBoxLayout* _layoutCBoxWebGui = nullptr;

View File

@@ -25,6 +25,7 @@ Display::Display()
Display::~Display() {
delete _toggleNumMonitorsButton;
delete _monBox;
delete _layoutMonBox;
delete _layoutMonButton;
delete _layoutWindows;
delete _layout;
@@ -32,7 +33,12 @@ Display::~Display() {
void Display::initializeLayout() {
_layout = new QVBoxLayout(this);
_layout->addWidget(_monBox);
_layoutMonBox = new QHBoxLayout(this);
_layoutMonBox->addStretch(1);
//_layout->addWidget(_monBox);
_layoutMonBox->addWidget(_monBox);
_layoutMonBox->addStretch(1);
_layout->addLayout(_layoutMonBox);
_monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
_monBox->setFixedSize(400, 400);
_layoutMonButton = new QHBoxLayout(this);
@@ -60,6 +66,10 @@ void Display::initializeLayout() {
QRect defaultMonitorResolution(_monitorResolution[0], _monitorResolution[1], 0, 0);
_monBox->setResolution(defaultMonitorResolution);
for (WindowControl* w : _windowControl) {
w->cleanupLayouts();
}
}
void Display::toggleWindows() {
@@ -70,6 +80,7 @@ void Display::toggleWindows() {
else if (_nWindowsDisplayed == 2) {
_toggleNumMonitorsButton->setText("Add 2nd window");
hideSecondWindow();
int minWidth = minimumWidth();
}
}

View File

@@ -56,13 +56,13 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou
_layoutSize = new QHBoxLayout(parentWidget);
_layoutSize->addStretch(1);
_layoutSize->addWidget(_labelSize);
_labelSize->setFixedWidth(60);
//_labelSize->setFixedWidth(50);
_labelSize->setText("Size:");
_layoutSize->addWidget(_size_x);
_layoutSize->addWidget(_labelDelim);
_layoutSize->addWidget(_size_y);
_layoutSize->addStretch(1);
_labelDelim->setText(" x ");
_labelDelim->setText("x");
_layoutWindowCtrl->addLayout(_layoutSize);
//Window offset
@@ -73,41 +73,58 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou
_layoutOffset = new QHBoxLayout(parentWidget);
_layoutOffset->addStretch(1);
_layoutOffset->addWidget(_labelOffset);
_labelOffset->setFixedWidth(60);
//_labelOffset->setFixedWidth(50);
_labelOffset->setText("Offset:");
_layoutOffset->addWidget(_offset_x);
_layoutOffset->addWidget(_labelComma);
_layoutOffset->addWidget(_offset_y);
_layoutOffset->addStretch(1);
_labelComma->setText(" , ");
_labelComma->setText(",");
_layoutWindowCtrl->addLayout(_layoutOffset);
//Window options
_layoutCheckboxesFull1 = new QHBoxLayout(parentWidget);
_layoutCheckboxesFull2 = new QVBoxLayout(parentWidget);
_layoutCheckboxesFull1->addStretch(1);
_layoutCBoxFullscreen = new QHBoxLayout(parentWidget);
_layoutCBoxFullscreen->addStretch(1);
//_layoutCBoxFullscreen->addStretch(1);
_layoutCBoxFullscreen->addWidget(_checkBoxFullscreen);
_layoutCBoxFullscreen->addStretch(1);
_layoutWindowCtrl->addLayout(_layoutCBoxFullscreen);
_layoutCheckboxesFull2->addLayout(_layoutCBoxFullscreen);
_layoutCBoxVsync= new QHBoxLayout(parentWidget);
_layoutCBoxVsync->addStretch(1);
//_layoutCBoxVsync->addStretch(1);
_layoutCBoxVsync->addWidget(_checkBoxVsync);
_layoutCBoxVsync->addStretch(1);
_layoutWindowCtrl->addLayout(_layoutCBoxVsync);
_layoutCheckboxesFull2->addLayout(_layoutCBoxVsync);
_layoutCBoxWebGui= new QHBoxLayout(parentWidget);
_layoutCBoxWebGui->addStretch(1);
//_layoutCBoxWebGui->addStretch(1);
_layoutCBoxWebGui->addWidget(_checkBoxWebGui);
_layoutCBoxWebGui->addStretch(1);
_layoutWindowCtrl->addLayout(_layoutCBoxWebGui);
_layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui);
_layoutCBoxSpoutOutput= new QHBoxLayout(parentWidget);
_layoutCBoxSpoutOutput->addStretch(1);
//_layoutCBoxSpoutOutput->addStretch(1);
_layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput);
_layoutCBoxSpoutOutput->addStretch(1);
_layoutWindowCtrl->addLayout(_layoutCBoxSpoutOutput);
_layoutCheckboxesFull2->addLayout(_layoutCBoxSpoutOutput);
_layoutCheckboxesFull1->addLayout(_layoutCheckboxesFull2);
_layoutCheckboxesFull1->addStretch(1);
_layoutWindowCtrl->addLayout(_layoutCheckboxesFull1);
_layoutFullWindow->addLayout(_layoutWindowCtrl);
return _layoutFullWindow;
}
void WindowControl::cleanupLayouts() {
int labelSize1 = _labelSize->width();
int labelSize2 = _labelOffset->width();
std::cout << "label1 = " << std::to_string(labelSize1) << std::endl;
std::cout << "label2 = " << std::to_string(labelSize2) << std::endl;
int labelWidthStandard = std::max(labelSize1, labelSize2);
_labelSize->setFixedWidth(labelWidthStandard);
_labelOffset->setFixedWidth(labelWidthStandard);
}
void WindowControl::onSizeXChanged(const QString& newText) {
std::string x = newText.toStdString();
if (!x.empty()) {
@@ -220,6 +237,8 @@ WindowControl::~WindowControl()
delete _layoutCBoxVsync;
delete _layoutCBoxWebGui;
delete _layoutCBoxSpoutOutput;
delete _layoutCheckboxesFull2;
delete _layoutCheckboxesFull1;
delete _layoutWindowCtrl;
}