]> git.sesse.net Git - nageru/commitdiff
Better handling of the aspect ratio stuff. Still some weirdness, though.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 26 Oct 2015 00:17:19 +0000 (01:17 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 26 Oct 2015 00:17:19 +0000 (01:17 +0100)
mainwindow.cpp
mainwindow.h
ui_mainwindow.ui

index 0289dbf1ac60d457a1961539535393920a176323..25d7a09645b02affc062186f61eeaf4298e7c9c5 100644 (file)
@@ -17,8 +17,8 @@ using namespace std;
 Q_DECLARE_METATYPE(std::vector<std::string>);
 
 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<std::string>)));
 }
 
+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<string> transition_names)
 {
        if (transition_names.size() < 1) {
index daf48b31794b49ea7a618920fcb0c67ab9bde7d4..919f8e732a952734cd03a6905b43a0e7b9965abc 100644 (file)
@@ -5,6 +5,10 @@
 #include <vector>
 #include <string>
 
+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<std::string> transition_names);
 
 private:
+       Ui::MainWindow *ui;
        QPushButton *transition_btn1, *transition_btn2, *transition_btn3;
 };
 
index f2a5a61bc4ae88efef2d0378db3915d17e4a46f4..90663b09abd77fb9ea90a6cc256c26e212b92a86 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>948</width>
-    <height>597</height>
+    <width>902</width>
+    <height>590</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -25,7 +25,7 @@
    </property>
    <layout class="QGridLayout" name="gridLayout">
     <item row="0" column="0">
-     <layout class="QVBoxLayout" name="verticalLayout" stretch="2,0,1">
+     <layout class="QVBoxLayout" name="vertical_layout" stretch="0,0,0">
       <item>
        <layout class="QHBoxLayout" name="me_displays" stretch="0,0,0">
         <item>
@@ -34,7 +34,7 @@
            <number>0</number>
           </property>
           <item>
-           <widget class="GLWidget" name="me_preview">
+           <widget class="GLWidget" name="me_preview" native="true">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
               <horstretch>1</horstretch>
@@ -44,7 +44,7 @@
            </widget>
           </item>
           <item>
-           <widget class="QLabel" name="label">
+           <widget class="QLabel" name="label_preview">
             <property name="text">
              <string>Preview</string>
             </property>
            <number>0</number>
           </property>
           <item>
-           <widget class="GLWidget" name="me_live">
+           <widget class="GLWidget" name="me_live" native="true">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
               <horstretch>1</horstretch>
            </widget>
           </item>
           <item>
-           <widget class="QLabel" name="label_2">
+           <widget class="QLabel" name="label_live">
             <property name="text">
              <string>Live</string>
             </property>
         </property>
         <property name="sizeHint" stdset="0">
          <size>
-          <width>0</width>
-          <height>0</height>
+          <width>20</width>
+          <height>40</height>
          </size>
         </property>
        </spacer>
       </item>
       <item>
-       <layout class="QHBoxLayout" name="horizontalLayout_5">
+       <layout class="QHBoxLayout" name="preview_displays">
         <property name="topMargin">
          <number>0</number>
         </property>
         <item>
-         <widget class="GLWidget" name="preview1">
+         <widget class="GLWidget" name="preview1" native="true">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
             <horstretch>1</horstretch>
          </widget>
         </item>
         <item>
-         <widget class="GLWidget" name="preview2">
+         <widget class="GLWidget" name="preview2" native="true">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
             <horstretch>1</horstretch>
          </widget>
         </item>
         <item>
-         <widget class="GLWidget" name="preview3">
+         <widget class="GLWidget" name="preview3" native="true">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
             <horstretch>1</horstretch>
          </widget>
         </item>
         <item>
-         <widget class="QGLWidget" name="preview4">
+         <widget class="QGLWidget" name="preview4" native="true">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
             <horstretch>1</horstretch>
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>948</width>
+     <width>902</width>
      <height>19</height>
     </rect>
    </property>
  <customwidgets>
   <customwidget>
    <class>GLWidget</class>
-   <extends>QGLWidget</extends>
+   <extends>QWidget</extends>
    <header>glwidget.h</header>
   </customwidget>
+  <customwidget>
+   <class>QGLWidget</class>
+   <extends>QWidget</extends>
+   <header>qglwidget.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>