annotate widgets/Fader.h @ 210:748985c7e2c1

* Fix incorrect meter-scaling value for 0dB; some tidying
author Chris Cannam
date Wed, 28 Feb 2007 11:20:14 +0000
parents 5b7472db612b
children 8c00a4d4fc69
rev   line source
Chris@58 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@59 4 Sonic Visualiser
Chris@59 5 An audio file viewer and annotation editor.
Chris@59 6 Centre for Digital Music, Queen Mary, University of London.
Chris@0 7
Chris@59 8 This program is free software; you can redistribute it and/or
Chris@59 9 modify it under the terms of the GNU General Public License as
Chris@59 10 published by the Free Software Foundation; either version 2 of the
Chris@59 11 License, or (at your option) any later version. See the file
Chris@59 12 COPYING included with this distribution for more information.
Chris@0 13 */
Chris@0 14
Chris@0 15 #ifndef FADER_H
Chris@0 16 #define FADER_H
Chris@0 17
Chris@0 18 /**
Chris@0 19 * Horizontal audio fader and meter widget.
Chris@0 20 * Based on the vertical fader and meter widget from:
Chris@0 21 *
Chris@0 22 * Hydrogen
Chris@0 23 * Copyright(c) 2002-2005 by Alex >Comix< Cominu [comix@users.sourceforge.net]
Chris@0 24 *
Chris@0 25 * http://www.hydrogen-music.org
Chris@0 26 *
Chris@0 27 * This program is free software; you can redistribute it and/or modify
Chris@0 28 * it under the terms of the GNU General Public License as published by
Chris@0 29 * the Free Software Foundation; either version 2 of the License, or
Chris@0 30 * (at your option) any later version.
Chris@0 31 *
Chris@0 32 * This program is distributed in the hope that it will be useful,
Chris@0 33 * but WITHOUT ANY WARRANTY, without even the implied warranty of
Chris@0 34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 35 * GNU General Public License for more details.
Chris@0 36 *
Chris@0 37 * You should have received a copy of the GNU General Public License
Chris@0 38 * along with this program; if not, write to the Free Software
Chris@0 39 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Chris@0 40 *
Chris@0 41 * $Id: Fader.h,v 1.14 2005/08/10 08:03:30 comix Exp $
Chris@0 42 */
Chris@0 43
Chris@0 44
Chris@0 45 #include <string>
Chris@0 46 #include <iostream>
Chris@0 47
Chris@0 48 #include <QWidget>
Chris@0 49 #include <QPixmap>
Chris@0 50 #include <QMouseEvent>
Chris@0 51 #include <QWheelEvent>
Chris@0 52 #include <QPaintEvent>
Chris@0 53
Chris@0 54 class Fader : public QWidget
Chris@0 55 {
Chris@0 56 Q_OBJECT
Chris@0 57
Chris@0 58 public:
Chris@0 59 Fader(QWidget *parent, bool withoutKnob = false);
Chris@0 60 ~Fader();
Chris@0 61
Chris@0 62 void setValue(float newValue);
Chris@0 63 float getValue();
Chris@0 64
Chris@0 65 void setPeakLeft(float);
Chris@0 66 float getPeakLeft() { return m_peakLeft; }
Chris@0 67
Chris@0 68 void setPeakRight(float);
Chris@0 69 float getPeakRight() { return m_peakRight; }
Chris@0 70
Chris@189 71 signals:
Chris@189 72 void valueChanged(float); // 0.0 -> 1.0
Chris@189 73
Chris@189 74 void mouseEntered();
Chris@189 75 void mouseLeft();
Chris@189 76
Chris@189 77 protected:
Chris@0 78 virtual void mousePressEvent(QMouseEvent *ev);
Chris@0 79 virtual void mouseDoubleClickEvent(QMouseEvent *ev);
Chris@0 80 virtual void mouseMoveEvent(QMouseEvent *ev);
Chris@132 81 virtual void mouseReleaseEvent(QMouseEvent *ev);
Chris@0 82 virtual void wheelEvent( QWheelEvent *ev );
Chris@0 83 virtual void paintEvent(QPaintEvent *ev);
Chris@189 84 virtual void enterEvent(QEvent *);
Chris@189 85 virtual void leaveEvent(QEvent *);
Chris@0 86
Chris@187 87 int getMaxX() const;
Chris@187 88
Chris@0 89 bool m_withoutKnob;
Chris@0 90 float m_value;
Chris@0 91 float m_peakLeft;
Chris@0 92 float m_peakRight;
Chris@0 93
Chris@187 94 bool m_mousePressed;
Chris@187 95 int m_mousePressX;
Chris@187 96 float m_mousePressValue;
Chris@187 97
Chris@0 98 QPixmap m_back;
Chris@0 99 QPixmap m_leds;
Chris@0 100 QPixmap m_knob;
Chris@0 101 QPixmap m_clip;
Chris@0 102 };
Chris@0 103
Chris@0 104 #endif