1 #ifndef COMPRESSION_REDUCTION_METER_H
2 #define COMPRESSION_REDUCTION_METER_H
4 // A meter that goes downwards instead of upwards, and has a non-linear scale.
12 #include "piecewise_interpolator.h"
18 class CompressionReductionMeter : public QWidget
23 CompressionReductionMeter(QWidget *parent);
25 void set_reduction_db(float level_db) {
26 std::lock_guard<std::mutex> lock(level_mutex);
27 this->level_db = level_db;
28 QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
32 void resizeEvent(QResizeEvent *event) override;
33 void paintEvent(QPaintEvent *event) override;
34 void recalculate_pixmaps();
35 void draw_scale(QPainter *painter, int x_pos);
36 double db_to_pos(double db) const;
37 int meter_height() const;
39 std::mutex level_mutex;
40 float level_db = 0.0f;
42 static constexpr float min_level = 0.0f; // Must match control_points (in the .cpp file).
43 static constexpr float max_level = 6.0f; // Same.
44 static constexpr int meter_width = 20;
46 // Size of the text box. The meter will be shrunk to make room for the text box
47 // (half the height) on both sides.
48 static constexpr int text_box_width = 15;
49 static constexpr int text_box_height = 10;
51 QPixmap on_pixmap, off_pixmap;