annotate widgets/Thumbwheel.h @ 959:2633a1d73e39

Address #1214, layer import produces wrong layer type. We needed a more principled approach to making sure the format gets updated properly and the dialog elements are consistent (basically separating making the dialog elements consistent from subsequently updating the format). This change should provide that, though there may be gotchas still.
author Chris Cannam
date Tue, 12 May 2015 12:31:37 +0100
parents 4a578a360011
children 13f5f84fbfad
rev   line source
Chris@132 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@132 2
Chris@132 3 /*
Chris@132 4 Sonic Visualiser
Chris@132 5 An audio file viewer and annotation editor.
Chris@132 6 Centre for Digital Music, Queen Mary, University of London.
Chris@182 7 This file copyright 2006 QMUL.
Chris@132 8
Chris@132 9 This program is free software; you can redistribute it and/or
Chris@132 10 modify it under the terms of the GNU General Public License as
Chris@132 11 published by the Free Software Foundation; either version 2 of the
Chris@132 12 License, or (at your option) any later version. See the file
Chris@132 13 COPYING included with this distribution for more information.
Chris@132 14 */
Chris@132 15
Chris@132 16 #ifndef _THUMBWHEEL_H_
Chris@132 17 #define _THUMBWHEEL_H_
Chris@132 18
Chris@132 19 #include <QWidget>
Chris@382 20 #include <QImage>
Chris@382 21
Chris@382 22 #include <map>
Chris@132 23
Chris@187 24 class RangeMapper;
Chris@187 25
Chris@132 26 class Thumbwheel : public QWidget
Chris@132 27 {
Chris@132 28 Q_OBJECT
Chris@132 29
Chris@132 30 public:
Chris@133 31 Thumbwheel(Qt::Orientation orientation, QWidget *parent = 0);
Chris@132 32 virtual ~Thumbwheel();
Chris@132 33
Chris@133 34 int getMinimumValue() const;
Chris@133 35 int getMaximumValue() const;
Chris@133 36 int getDefaultValue() const;
Chris@132 37 float getSpeed() const;
Chris@132 38 bool getTracking() const;
Chris@132 39 bool getShowScale() const;
Chris@132 40 int getValue() const;
Chris@132 41
Chris@187 42 void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete
Chris@187 43 const RangeMapper *getRangeMapper() const { return m_rangeMapper; }
Chris@908 44 double getMappedValue() const;
Chris@187 45
Chris@187 46 void setShowToolTip(bool show);
Chris@187 47
Chris@132 48 QSize sizeHint() const;
Chris@132 49
Chris@132 50 signals:
Chris@132 51 void valueChanged(int);
Chris@132 52
Chris@189 53 void mouseEntered();
Chris@189 54 void mouseLeft();
Chris@189 55
Chris@133 56 public slots:
Chris@133 57 void setMinimumValue(int min);
Chris@133 58 void setMaximumValue(int max);
Chris@133 59 void setDefaultValue(int deft);
Chris@133 60 void setSpeed(float speed);
Chris@133 61 void setTracking(bool tracking);
Chris@133 62 void setShowScale(bool show);
Chris@133 63 void setValue(int value);
Chris@908 64 void setMappedValue(double mappedValue);
Chris@256 65 void scroll(bool up);
Chris@133 66 void resetToDefault();
Chris@133 67
Chris@187 68 protected slots:
Chris@187 69 void updateMappedValue(int value);
Chris@187 70
Chris@189 71 protected:
Chris@189 72 virtual void mousePressEvent(QMouseEvent *e);
Chris@189 73 virtual void mouseDoubleClickEvent(QMouseEvent *e);
Chris@189 74 virtual void mouseMoveEvent(QMouseEvent *e);
Chris@189 75 virtual void mouseReleaseEvent(QMouseEvent *e);
Chris@189 76 virtual void wheelEvent(QWheelEvent *e);
Chris@189 77 virtual void paintEvent(QPaintEvent *e);
Chris@189 78 virtual void enterEvent(QEvent *);
Chris@189 79 virtual void leaveEvent(QEvent *);
Chris@189 80
Chris@132 81 int m_min;
Chris@132 82 int m_max;
Chris@132 83 int m_default;
Chris@132 84 int m_value;
Chris@908 85 double m_mappedValue;
Chris@187 86 bool m_noMappedUpdate;
Chris@165 87 float m_rotation;
Chris@132 88 Qt::Orientation m_orientation;
Chris@132 89 float m_speed;
Chris@132 90 bool m_tracking;
Chris@132 91 bool m_showScale;
Chris@132 92 bool m_clicked;
Chris@133 93 bool m_atDefault;
Chris@132 94 QPoint m_clickPos;
Chris@165 95 float m_clickRotation;
Chris@187 96 bool m_showTooltip;
Chris@187 97 RangeMapper *m_rangeMapper;
Chris@382 98 QImage m_cache;
Chris@132 99 };
Chris@132 100
Chris@132 101 #endif