comparison widgets/Fader.h @ 0:2a4f26e85b4c

initial import
author Chris Cannam
date Tue, 10 Jan 2006 16:33:16 +0000
parents
children 37b110168acf
comparison
equal deleted inserted replaced
-1:000000000000 0:2a4f26e85b4c
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 A waveform viewer and audio annotation editor.
5 Chris Cannam, Queen Mary University of London, 2005
6
7 This is experimental software. Not for distribution.
8 */
9
10 #ifndef FADER_H
11 #define FADER_H
12
13 /**
14 * Horizontal audio fader and meter widget.
15 * Based on the vertical fader and meter widget from:
16 *
17 * Hydrogen
18 * Copyright(c) 2002-2005 by Alex >Comix< Cominu [comix@users.sourceforge.net]
19 *
20 * http://www.hydrogen-music.org
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY, without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 *
36 * $Id: Fader.h,v 1.14 2005/08/10 08:03:30 comix Exp $
37 */
38
39
40 #include <string>
41 #include <iostream>
42
43 #include <QWidget>
44 #include <QPixmap>
45 #include <QMouseEvent>
46 #include <QWheelEvent>
47 #include <QPaintEvent>
48
49 class Fader : public QWidget
50 {
51 Q_OBJECT
52
53 public:
54 Fader(QWidget *parent, bool withoutKnob = false);
55 ~Fader();
56
57 void setValue(float newValue);
58 float getValue();
59
60 void setPeakLeft(float);
61 float getPeakLeft() { return m_peakLeft; }
62
63 void setPeakRight(float);
64 float getPeakRight() { return m_peakRight; }
65
66 virtual void mousePressEvent(QMouseEvent *ev);
67 virtual void mouseDoubleClickEvent(QMouseEvent *ev);
68 virtual void mouseMoveEvent(QMouseEvent *ev);
69 virtual void wheelEvent( QWheelEvent *ev );
70 virtual void paintEvent(QPaintEvent *ev);
71
72 signals:
73 void valueChanged(float); // 0.0 -> 1.0
74
75 private:
76 bool m_withoutKnob;
77 float m_value;
78 float m_peakLeft;
79 float m_peakRight;
80
81 QPixmap m_back;
82 QPixmap m_leds;
83 QPixmap m_knob;
84 QPixmap m_clip;
85 };
86
87 #endif