]> git.sesse.net Git - nageru/commitdiff
Various tweaks to the UI layout.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 27 Oct 2015 18:18:01 +0000 (19:18 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 27 Oct 2015 18:18:01 +0000 (19:18 +0100)
main.cpp
mainwindow.cpp
mainwindow.h

index 6e95d18de6103415cad06f45c53036c70dd6069e..b39208fab53630eda018d94201d19ce94d366596 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -33,7 +33,7 @@ int main(int argc, char *argv[])
        global_share_widget = new QGLWidget();
 
        MainWindow mainWindow;
-       mainWindow.resize(QSize(1500, 670));
+       mainWindow.resize(QSize(1500, 606));
        mainWindow.show();
 
        int rc = app.exec();
index 816ad7c3d1e0ae249f7a7fd053843ea4e2ef4afd..3ccc89303dd946dc1ff5a1ed1bde37582f048cd8 100644 (file)
@@ -85,38 +85,42 @@ void MainWindow::resizeEvent(QResizeEvent* event)
 {
        QMainWindow::resizeEvent(event);
 
-       int width = event->size().width();
-       int height = event->size().height();
+       // Ask for a relayout, but only after the event loop is done doing relayout
+       // on everything else.
+       QMetaObject::invokeMethod(this, "relayout", Qt::QueuedConnection);
+}
+
+void MainWindow::relayout()
+{
+       int width = size().width();
+       int height = size().height();
 
        // 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();  // FIXME: label_preview changes height.
-       double me_proportion = me_height / height;
+       double me_width = ui->me_preview->width();
+       double me_height = me_width * 9.0 / 16.0 + ui->label_preview->height();
 
        // TODO: Scale the widths when we need to do this.
-       if (me_proportion > 0.8) {
-               me_proportion = 0.8;
+       if (me_height / double(height) > 0.8) {
+               me_height = height * 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, std::max<int>(1, lrintf(1000 * (1.0 - me_proportion - preview_proportion))));
-       ui->vertical_layout->setStretch(2, lrintf(1000 * preview_proportion));
+       ui->vertical_layout->setStretch(0, lrintf(me_height));
+       ui->vertical_layout->setStretch(1, std::max<int>(1, lrintf(height - me_height - preview_height)));
+       ui->vertical_layout->setStretch(2, lrintf(preview_height));
 
        // 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)));
+       double preview_width = preview_height * 16.0 / 9.0;  // FIXME: spacing?
+
+       ui->preview_displays->setStretch(0, lrintf(preview_width));
+       ui->preview_displays->setStretch(1, lrintf(preview_width));
+       ui->preview_displays->setStretch(2, lrintf(preview_width));
+       ui->preview_displays->setStretch(3, lrintf(preview_width));
+       ui->preview_displays->setStretch(4, lrintf(width - 4.0 * preview_width));
 }
 
 void MainWindow::set_transition_names(vector<string> transition_names)
index 919f8e732a952734cd03a6905b43a0e7b9965abc..b0e26897b2dbbf937828d785a21d57370a84f982 100644 (file)
@@ -23,6 +23,7 @@ public slots:
        void transition_clicked(int transition_number);
        void channel_clicked(int channel_number);
        void set_transition_names(std::vector<std::string> transition_names);
+       void relayout();
 
 private:
        Ui::MainWindow *ui;