]> git.sesse.net Git - nageru/blob - nageru/correlation_meter.h
Make it possible to set number of channels imperatively instead of using a callback.
[nageru] / nageru / correlation_meter.h
1 #ifndef CORRELATION_METER_H
2 #define CORRELATION_METER_H
3
4 #include <mutex>
5
6 #include <QPixmap>
7 #include <QString>
8 #include <QWidget>
9
10 class QObject;
11 class QPaintEvent;
12 class QResizeEvent;
13
14 class CorrelationMeter : public QWidget
15 {
16         Q_OBJECT
17
18 public:
19         CorrelationMeter(QWidget *parent);
20
21         void set_correlation(float correlation) {
22                 std::lock_guard<std::mutex> lock(correlation_mutex);
23                 this->correlation = correlation;
24                 QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
25         }
26
27 private:
28         void resizeEvent(QResizeEvent *event) override;
29         void paintEvent(QPaintEvent *event) override;
30
31         std::mutex correlation_mutex;
32         float correlation = 0.0f;
33
34         QPixmap on_pixmap, off_pixmap;
35 };
36
37 #endif