]> git.sesse.net Git - nageru/commitdiff
Various VU meter layout tweaks.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 29 Oct 2015 20:26:38 +0000 (21:26 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 29 Oct 2015 20:26:38 +0000 (21:26 +0100)
ui_mainwindow.ui
vumeter.cpp

index 3f0a21165421923865632debf293227dbb7f5976..2e2f05244b5891e824da5d157a16de8b48233067 100644 (file)
          </layout>
         </item>
         <item>
-         <layout class="QVBoxLayout" name="verticalLayout_4">
+         <layout class="QVBoxLayout" name="verticalLayout_4" stretch="1,0">
           <property name="leftMargin">
            <number>0</number>
           </property>
           <item>
-           <widget class="VUMeter" name="vu_meter" native="true">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-              <horstretch>0</horstretch>
-              <verstretch>1</verstretch>
-             </sizepolicy>
+           <layout class="QHBoxLayout" name="horizontalLayout">
+            <property name="bottomMargin">
+             <number>0</number>
             </property>
+            <item>
+             <widget class="VUMeter" name="vu_meter" native="true">
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+                <horstretch>0</horstretch>
+                <verstretch>1</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="minimumSize">
+               <size>
+                <width>16</width>
+                <height>0</height>
+               </size>
+              </property>
+              <property name="sizeIncrement">
+               <size>
+                <width>1</width>
+                <height>0</height>
+               </size>
+              </property>
+              <property name="baseSize">
+               <size>
+                <width>0</width>
+                <height>0</height>
+               </size>
+              </property>
+              <property name="palette">
+               <palette>
+                <active>
+                 <colorrole role="Base">
+                  <brush brushstyle="SolidPattern">
+                   <color alpha="255">
+                    <red>255</red>
+                    <green>255</green>
+                    <blue>255</blue>
+                   </color>
+                  </brush>
+                 </colorrole>
+                 <colorrole role="Window">
+                  <brush brushstyle="SolidPattern">
+                   <color alpha="255">
+                    <red>5</red>
+                    <green>239</green>
+                    <blue>111</blue>
+                   </color>
+                  </brush>
+                 </colorrole>
+                </active>
+                <inactive>
+                 <colorrole role="Base">
+                  <brush brushstyle="SolidPattern">
+                   <color alpha="255">
+                    <red>255</red>
+                    <green>255</green>
+                    <blue>255</blue>
+                   </color>
+                  </brush>
+                 </colorrole>
+                 <colorrole role="Window">
+                  <brush brushstyle="SolidPattern">
+                   <color alpha="255">
+                    <red>5</red>
+                    <green>239</green>
+                    <blue>111</blue>
+                   </color>
+                  </brush>
+                 </colorrole>
+                </inactive>
+                <disabled>
+                 <colorrole role="Base">
+                  <brush brushstyle="SolidPattern">
+                   <color alpha="255">
+                    <red>5</red>
+                    <green>239</green>
+                    <blue>111</blue>
+                   </color>
+                  </brush>
+                 </colorrole>
+                 <colorrole role="Window">
+                  <brush brushstyle="SolidPattern">
+                   <color alpha="255">
+                    <red>5</red>
+                    <green>239</green>
+                    <blue>111</blue>
+                   </color>
+                  </brush>
+                 </colorrole>
+                </disabled>
+               </palette>
+              </property>
+              <property name="autoFillBackground">
+               <bool>true</bool>
+              </property>
+              <zorder>peak_display</zorder>
+              <zorder>peak_display</zorder>
+             </widget>
+            </item>
+           </layout>
+          </item>
+          <item>
+           <widget class="QLabel" name="peak_display">
             <property name="minimumSize">
              <size>
-              <width>20</width>
+              <width>30</width>
               <height>0</height>
              </size>
             </property>
-            <zorder>peak_display</zorder>
-            <zorder>peak_display</zorder>
-           </widget>
-          </item>
-          <item>
-           <widget class="QLabel" name="peak_display">
             <property name="text">
              <string>-0.0</string>
             </property>
+            <property name="alignment">
+             <set>Qt::AlignCenter</set>
+            </property>
            </widget>
           </item>
          </layout>
index e56268ad46f0d6cddde59ba5d15b8134d9f411e7..0049edfc6f029fbf539c9b57115614a4efbd086c 100644 (file)
@@ -8,8 +8,8 @@ namespace {
 
 int lufs_to_pos(float level_lu, int height)
 {
-       const float min_level = 18.0f;    // y=0 is top of screen, so “min” is the loudest level.
-       const float max_level = -36.0f;
+       const float min_level = 9.0f;    // y=0 is top of screen, so “min” is the loudest level.
+       const float max_level = -18.0f;
        int y = lrintf(height * (level_lu - min_level) / (max_level - min_level));
        y = std::max(y, 0);
        y = std::min(y, height - 1);
@@ -32,9 +32,18 @@ void VUMeter::paintEvent(QPaintEvent *event)
 
        painter.fillRect(0, 0, width(), height(), Qt::black);
 
-       int min_y = lufs_to_pos(1.0f, height());
-       int max_y = lufs_to_pos(-1.0f, height());
-       painter.fillRect(0, min_y, width(), max_y - min_y, Qt::green);
+       // Draw some reference bars.
+       for (int level = -18; level < 9; ++level) {
+               int min_y = lufs_to_pos(level, height()) - 1;
+               int max_y = lufs_to_pos(level + 1.0f, height()) + 1;
+
+               // Recommended range is 0 LU +/- 1 LU.
+               if (level == -1 || level == 0) {
+                       painter.fillRect(1, min_y, width() - 2, max_y - min_y, Qt::green);
+               } else {
+                       painter.fillRect(1, min_y, width() - 2, max_y - min_y, Qt::darkGray);
+               }
+       }
 
        float level_lufs;
        {
@@ -44,6 +53,5 @@ void VUMeter::paintEvent(QPaintEvent *event)
 
        float level_lu = level_lufs + 23.0f;
        int y = lufs_to_pos(level_lu, height());
-       painter.setPen(Qt::white);
-       painter.drawLine(0, y, width(), y);
+       painter.fillRect(0, y, width(), 2, Qt::white);
 }