Fader.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version. See the file
12  COPYING included with this distribution for more information.
13 */
14 
15 #ifndef FADER_H
16 #define FADER_H
17 
28 #include <string>
29 #include <iostream>
30 
31 #include <QWidget>
32 #include <QPixmap>
33 #include <QMouseEvent>
34 #include <QWheelEvent>
35 #include <QPaintEvent>
36 
37 #include "base/Debug.h"
38 
39 class Fader : public QWidget
40 {
41  Q_OBJECT
42 
43 public:
44  Fader(QWidget *parent, bool withoutKnob = false);
45  ~Fader();
46 
47  void setValue(float newValue);
48  float getValue();
49 
50  void setPeakLeft(float);
51  float getPeakLeft() { return m_peakLeft; }
52 
53  void setPeakRight(float);
54  float getPeakRight() { return m_peakRight; }
55 
56 signals:
57  void valueChanged(float); // 0.0 -> 1.0
58 
59  void mouseEntered();
60  void mouseLeft();
61 
62 protected:
63  void mousePressEvent(QMouseEvent *ev) override;
64  void mouseDoubleClickEvent(QMouseEvent *ev) override;
65  void mouseMoveEvent(QMouseEvent *ev) override;
66  void mouseReleaseEvent(QMouseEvent *ev) override;
67  void wheelEvent( QWheelEvent *ev ) override;
68  void paintEvent(QPaintEvent *ev) override;
69  void enterEvent(QEvent *) override;
70  void leaveEvent(QEvent *) override;
71 
72  int getMaxX() const;
73 
75  float m_value;
76  float m_peakLeft;
77  float m_peakRight;
78 
82 
83  QPixmap m_back;
84  QPixmap m_leds;
85  QPixmap m_knob;
86  QPixmap m_clip;
87 };
88 
89 #endif
QPixmap m_knob
Definition: Fader.h:85
void paintEvent(QPaintEvent *ev) override
Definition: Fader.cpp:263
QPixmap m_back
Definition: Fader.h:83
float m_value
Definition: Fader.h:75
void setPeakLeft(float)
Definition: Fader.cpp:243
QPixmap m_clip
Definition: Fader.h:86
float getPeakRight()
Definition: Fader.h:54
void mousePressEvent(QMouseEvent *ev) override
Definition: Fader.cpp:156
bool m_mousePressed
Definition: Fader.h:79
QPixmap m_leds
Definition: Fader.h:84
float m_mousePressValue
Definition: Fader.h:81
float m_peakRight
Definition: Fader.h:77
float getPeakLeft()
Definition: Fader.h:51
void mouseLeft()
void setPeakRight(float)
Definition: Fader.cpp:253
bool m_withoutKnob
Definition: Fader.h:74
void leaveEvent(QEvent *) override
Definition: Fader.cpp:198
Horizontal audio fader and meter widget.
Definition: Fader.h:39
void enterEvent(QEvent *) override
Definition: Fader.cpp:192
void mouseReleaseEvent(QMouseEvent *ev) override
Definition: Fader.cpp:123
void setValue(float newValue)
Definition: Fader.cpp:204
void mouseEntered()
float getValue()
Definition: Fader.cpp:235
~Fader()
Definition: Fader.cpp:84
void mouseMoveEvent(QMouseEvent *ev) override
Definition: Fader.cpp:90
void valueChanged(float)
int m_mousePressX
Definition: Fader.h:80
Fader(QWidget *parent, bool withoutKnob=false)
Horizontal audio fader and meter widget.
Definition: Fader.cpp:45
float m_peakLeft
Definition: Fader.h:76
int getMaxX() const
Definition: Fader.cpp:299
void wheelEvent(QWheelEvent *ev) override
Definition: Fader.cpp:175
void mouseDoubleClickEvent(QMouseEvent *ev) override
Definition: Fader.cpp:132