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.
16 class CompressionReductionMeter : public QWidget
21 CompressionReductionMeter(QWidget *parent);
23 void set_reduction_db(float level_db) {
24 std::lock_guard<std::mutex> lock(level_mutex);
25 this->level_db = level_db;
26 QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
30 void resizeEvent(QResizeEvent *event) override;
31 void paintEvent(QPaintEvent *event) override;
32 void recalculate_pixmaps();
33 void draw_scale(QPainter *painter, int x_pos);
34 double db_to_pos(double db) const;
35 int meter_height() const;
37 std::mutex level_mutex;
38 float level_db = 0.0f;
40 static constexpr float min_level = 0.0f; // Must match control_points (in the .cpp file).
41 static constexpr float max_level = 6.0f; // Same.
42 static constexpr int meter_width = 20;
44 // Size of the text box. The meter will be shrunk to make room for the text box
45 // (half the height) on both sides.
46 static constexpr int text_box_width = 15;
47 static constexpr int text_box_height = 10;
49 QPixmap on_pixmap, off_pixmap;