]> git.sesse.net Git - nageru/blobdiff - nonlinear_fader.cpp
Don't try to set up MIDI mapper highlights before the UI exists.
[nageru] / nonlinear_fader.cpp
index b548c29493206bc6f5a3569ffc657f55f4178550..4892c6770517b5a8d465fcf9949a808e8332da47 100644 (file)
@@ -1,15 +1,18 @@
+#include "nonlinear_fader.h"
+
 #include <assert.h>
 #include <math.h>
-#include <stdio.h>
-#include <vector>
-#include <utility>
-
-#include <QResizeEvent>
 #include <QPainter>
+#include <QPoint>
+#include <QRect>
 #include <QStyle>
-#include <QStyleOptionSlider>
+#include <QStyleOption>
+#include <memory>
+#include <utility>
+#include <vector>
 
-#include "nonlinear_fader.h"
+class QPaintEvent;
+class QWidget;
 
 using namespace std;
 
@@ -17,8 +20,11 @@ namespace {
 
 vector<pair<double, double>> fader_control_points = {
        // The main area is from +6 to -12 dB (18 dB), and we use half the slider range for it.
+       // Adjust slightly so that the MIDI controller value of 106 becomes exactly 0.0 dB
+       // (cf. map_controller_to_float()); otherwise, we'd miss ever so slightly, which is
+       // really frustrating.
        { 6.0, 1.0 },
-       { -12.0, 0.5 },
+       { -12.0, 1.0 - (1.0 - 106.5/127.0) * 3.0 },  // About 0.492.
 
        // -12 to -21 is half the range (9 dB). Halve.
        { -21.0, 0.325 },