annotate widgets/LevelPanWidget.h @ 923:2a9f1eb6e0ed tonioni

Try adding a combined simple level/pan widget
author Chris Cannam
date Tue, 24 Mar 2015 14:40:31 +0000
parents
children 20698aa6a517
rev   line source
Chris@923 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@923 2
Chris@923 3 /*
Chris@923 4 Sonic Visualiser
Chris@923 5 An audio file viewer and annotation editor.
Chris@923 6 Centre for Digital Music, Queen Mary, University of London.
Chris@923 7
Chris@923 8 This program is free software; you can redistribute it and/or
Chris@923 9 modify it under the terms of the GNU General Public License as
Chris@923 10 published by the Free Software Foundation; either version 2 of the
Chris@923 11 License, or (at your option) any later version. See the file
Chris@923 12 COPYING included with this distribution for more information.
Chris@923 13 */
Chris@923 14
Chris@923 15 #ifndef LEVEL_PAN_WIDGET_H
Chris@923 16 #define LEVEL_PAN_WIDGET_H
Chris@923 17
Chris@923 18 #include <QWidget>
Chris@923 19
Chris@923 20 /**
Chris@923 21 * A simple widget for coarse level and pan control.
Chris@923 22 *
Chris@923 23 * For this initial implementation at least, pan is in five steps only
Chris@923 24 * (hard left, mid-left, centre, mid-right, hard right) and level is
Chris@923 25 * in five plus mute.
Chris@923 26 */
Chris@923 27
Chris@923 28 class LevelPanWidget : public QWidget
Chris@923 29 {
Chris@923 30 Q_OBJECT
Chris@923 31
Chris@923 32 public:
Chris@923 33 LevelPanWidget(QWidget *parent = 0);
Chris@923 34 ~LevelPanWidget();
Chris@923 35
Chris@923 36 /// Return level as a gain value in the range [0,1]
Chris@923 37 float getLevel() const;
Chris@923 38
Chris@923 39 /// Return pan as a value in the range [-1,1]
Chris@923 40 float getPan() const;
Chris@923 41
Chris@923 42 /// Find out whether the widget is editable
Chris@923 43 bool isEditable() const;
Chris@923 44
Chris@923 45 public slots:
Chris@923 46 /// Set level in the range [0,1] -- will be rounded
Chris@923 47 void setLevel(float);
Chris@923 48
Chris@923 49 /// Set pan in the range [-1,1] -- will be rounded
Chris@923 50 void setPan(float);
Chris@923 51
Chris@923 52 /// Specify whether the widget is editable or read-only (default editable)
Chris@923 53 void setEditable(bool);
Chris@923 54
Chris@923 55 signals:
Chris@923 56 void levelChanged(float);
Chris@923 57 void panChanged(float);
Chris@923 58
Chris@923 59 protected:
Chris@923 60 virtual void mousePressEvent(QMouseEvent *ev);
Chris@923 61 virtual void mouseMoveEvent(QMouseEvent *ev);
Chris@923 62 virtual void mouseReleaseEvent(QMouseEvent *ev);
Chris@923 63 virtual void wheelEvent(QWheelEvent *ev);
Chris@923 64 virtual void paintEvent(QPaintEvent *ev);
Chris@923 65
Chris@923 66 void emitLevelChanged();
Chris@923 67 void emitPanChanged();
Chris@923 68
Chris@923 69 int m_level;
Chris@923 70 int m_pan;
Chris@923 71 bool m_editable;
Chris@923 72
Chris@923 73 QSizeF cellSize() const;
Chris@923 74 QPointF cellCentre(int level, int pan) const;
Chris@923 75 QSizeF cellLightSize() const;
Chris@923 76 QRectF cellLightRect(int level, int pan) const;
Chris@923 77 double thinLineWidth() const;
Chris@923 78 void toCell(QPointF loc, int &level, int &pan) const;
Chris@923 79 };
Chris@923 80
Chris@923 81 #endif