qtcollider: QLevelIndicator: enhance drawing
[supercollider.git] / QtCollider / widgets / QcLevelIndicator.h
blobf5252f820f396c76fa5520e2cf6b20f2470761ed
1 /************************************************************************
3 * Copyright 2010 Jakob Leben (jakob.leben@gmail.com)
5 * This file is part of SuperCollider Qt GUI.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ************************************************************************/
22 #ifndef QC_LEVEL_INDICATOR_H
23 #define QC_LEVEL_INDICATOR_H
25 #include "../QcHelper.h"
26 #include "../style/style.hpp"
28 #include <QWidget>
29 #include <QTimer>
31 class QcLevelIndicator : public QWidget, QcHelper, QtCollider::Style::Client
33 Q_OBJECT
34 Q_PROPERTY( float value READ dummyFloat WRITE setValue );
35 Q_PROPERTY( float warning READ dummyFloat WRITE setWarning );
36 Q_PROPERTY( float critical READ dummyFloat WRITE setCritical );
37 Q_PROPERTY( float peak READ dummyFloat WRITE setPeak );
38 Q_PROPERTY( bool drawPeak READ dummyBool WRITE setDrawPeak );
39 Q_PROPERTY( int ticks READ dummyInt WRITE setTicks );
40 Q_PROPERTY( int majorTicks READ dummyInt WRITE setMajorTicks );
42 public:
43 QcLevelIndicator();
44 void setValue( float f ) { _value = f; update(); }
45 void setWarning( float f ) { _warning = f; update(); }
46 void setCritical( float f ) { _critical = f; update(); }
47 void setPeak( float f ) { _peak = f; update(); }
48 void setDrawPeak( bool b ) { _drawPeak = b; update(); }
49 void setTicks( int i ) { _ticks = qMax(i,0); update(); }
50 void setMajorTicks( int i ) { _majorTicks = qMax(i,0); update(); }
51 virtual QSize sizeHint() const { return QSize( 25, 150 ); }
52 private Q_SLOTS:
53 void clipTimeout();
54 private:
55 void paintEvent( QPaintEvent *e );
56 float _value;
57 float _warning;
58 float _critical;
59 float _peak;
60 bool _drawPeak;
61 int _ticks;
62 int _majorTicks;
63 bool _clipped;
64 QTimer *_clipTimer;
67 #endif