From 393ff668fccf38b76e2468ae83163f3788e03978 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 26 Oct 2015 01:17:19 +0100 Subject: [PATCH] Better handling of the aspect ratio stuff. Still some weirdness, though. --- mainwindow.cpp | 37 ++++++++++++++++++++++++++++++++++++- mainwindow.h | 6 ++++++ ui_mainwindow.ui | 37 +++++++++++++++++++++---------------- 3 files changed, 63 insertions(+), 17 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 0289dbf..25d7a09 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -17,8 +17,8 @@ using namespace std; Q_DECLARE_METATYPE(std::vector); MainWindow::MainWindow() + : ui(new Ui::MainWindow) { - Ui::MainWindow *ui = new Ui::MainWindow; ui->setupUi(this); ui->me_live->set_output(Mixer::OUTPUT_LIVE); @@ -80,6 +80,41 @@ MainWindow::MainWindow() this, SLOT(set_transition_names(std::vector))); } +void MainWindow::resizeEvent(QResizeEvent* event) +{ + QMainWindow::resizeEvent(event); + + // Allocate the height; the most important part is to keep the main displays + // at 16:9 if at all possible. + double me_width = (width() - ui->transition_btn2->width()) / 2.0; + double me_height = me_width * 9.0 / 16.0 + ui->label_preview->height(); + double me_proportion = me_height / height(); + + // TODO: Scale the widths when we need to do this. + if (me_proportion > 0.8) { + me_proportion = 0.8; + } + + // The previews will be constrained by the remaining height, and the width. + // FIXME: spacing= + double preview_height = std::min(height() - me_height, (width() / 4.0) * 9.0 / 16.0); + double preview_proportion = preview_height / height(); + + ui->vertical_layout->setStretch(0, lrintf(1000 * me_proportion)); + ui->vertical_layout->setStretch(1, lrintf(1000 * (1.0 - me_proportion - preview_proportion))); + ui->vertical_layout->setStretch(2, lrintf(1000 * preview_proportion)); + + // Set the widths for the previews. + double preview_width = preview_height * 16.0 / 9.0; + double preview_width_proportion = preview_width / width(); // FIXME: spacing? + + ui->preview_displays->setStretch(0, lrintf(1000 * preview_width_proportion)); + ui->preview_displays->setStretch(1, lrintf(1000 * preview_width_proportion)); + ui->preview_displays->setStretch(2, lrintf(1000 * preview_width_proportion)); + ui->preview_displays->setStretch(3, lrintf(1000 * preview_width_proportion)); + ui->preview_displays->setStretch(4, lrintf(1000 * (1.0 - 4.0 * preview_width_proportion))); +} + void MainWindow::set_transition_names(vector transition_names) { if (transition_names.size() < 1) { diff --git a/mainwindow.h b/mainwindow.h index daf48b3..919f8e7 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -5,6 +5,10 @@ #include #include +namespace Ui { +class MainWindow; +} // namespace Ui + class QPushButton; class MainWindow : public QMainWindow @@ -13,6 +17,7 @@ class MainWindow : public QMainWindow public: MainWindow(); + void resizeEvent(QResizeEvent* event) override; public slots: void transition_clicked(int transition_number); @@ -20,6 +25,7 @@ public slots: void set_transition_names(std::vector transition_names); private: + Ui::MainWindow *ui; QPushButton *transition_btn1, *transition_btn2, *transition_btn3; }; diff --git a/ui_mainwindow.ui b/ui_mainwindow.ui index f2a5a61..90663b0 100644 --- a/ui_mainwindow.ui +++ b/ui_mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 948 - 597 + 902 + 590 @@ -25,7 +25,7 @@ - + @@ -34,7 +34,7 @@ 0 - + 1 @@ -44,7 +44,7 @@ - + Preview @@ -104,7 +104,7 @@ 0 - + 1 @@ -126,7 +126,7 @@ - + Live @@ -146,19 +146,19 @@ - 0 - 0 + 20 + 40 - + 0 - + 1 @@ -168,7 +168,7 @@ - + 1 @@ -178,7 +178,7 @@ - + 1 @@ -188,7 +188,7 @@ - + 1 @@ -221,7 +221,7 @@ 0 0 - 948 + 902 19 @@ -243,9 +243,14 @@ GLWidget - QGLWidget + QWidget
glwidget.h
+ + QGLWidget + QWidget +
qglwidget.h
+
-- 2.39.2