Thumbwheel.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_THUMBWHEEL_H
17 #define SV_THUMBWHEEL_H
18 
19 #include <QWidget>
20 #include <QImage>
21 
22 #include <map>
23 
24 #include "WheelCounter.h"
25 
26 class RangeMapper;
27 class QMenu;
28 
29 class Thumbwheel : public QWidget
30 {
31  Q_OBJECT
32 
33 public:
34  Thumbwheel(Qt::Orientation orientation, QWidget *parent = 0);
35  virtual ~Thumbwheel();
36 
37  int getMinimumValue() const;
38  int getMaximumValue() const;
39  int getDefaultValue() const;
40  float getSpeed() const;
41  bool getTracking() const;
42  bool getShowScale() const;
43  int getValue() const;
44 
45  void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete
46  const RangeMapper *getRangeMapper() const { return m_rangeMapper; }
47  double getMappedValue() const;
48 
49  void setShowToolTip(bool show);
50  void setProvideContextMenu(bool provide);
51 
52  QSize sizeHint() const override;
53 
54 signals:
55  void valueChanged(int);
56 
57  void mouseEntered();
58  void mouseLeft();
59 
60 public slots:
61  void setMinimumValue(int min);
62  void setMaximumValue(int max);
63  void setDefaultValue(int deft);
64  void setSpeed(float speed);
65  void setTracking(bool tracking);
66  void setShowScale(bool show);
67  void setValue(int value);
68  void setMappedValue(double mappedValue);
69  void scroll(bool up);
70  void resetToDefault();
71  void edit();
72 
73 protected slots:
74  void updateMappedValue(int value);
75  void updateTitle();
76  void contextMenuRequested(const QPoint &);
77 
78 protected:
79  void mousePressEvent(QMouseEvent *e) override;
80  void mouseDoubleClickEvent(QMouseEvent *e) override;
81  void mouseMoveEvent(QMouseEvent *e) override;
82  void mouseReleaseEvent(QMouseEvent *e) override;
83  void wheelEvent(QWheelEvent *e) override;
84  void paintEvent(QPaintEvent *e) override;
85  void enterEvent(QEvent *) override;
86  void leaveEvent(QEvent *) override;
87 
88  int m_min;
89  int m_max;
90  int m_default;
91  int m_value;
92  double m_mappedValue;
94  float m_rotation;
95  Qt::Orientation m_orientation;
96  float m_speed;
97  bool m_tracking;
99  bool m_clicked;
101  QPoint m_clickPos;
105  QString m_title;
107  RangeMapper *m_rangeMapper;
108  QImage m_cache;
110 };
111 
112 #endif
void setDefaultValue(int deft)
Definition: Thumbwheel.cpp:162
int getMinimumValue() const
Definition: Thumbwheel.cpp:136
void paintEvent(QPaintEvent *e) override
Definition: Thumbwheel.cpp:501
bool m_provideContextMenu
Definition: Thumbwheel.h:104
void contextMenuRequested(const QPoint &)
Definition: Thumbwheel.cpp:68
void setRangeMapper(RangeMapper *mapper)
Definition: Thumbwheel.cpp:91
float m_speed
Definition: Thumbwheel.h:96
bool m_atDefault
Definition: Thumbwheel.h:100
bool getTracking() const
Definition: Thumbwheel.cpp:329
QPoint m_clickPos
Definition: Thumbwheel.h:101
float getSpeed() const
Definition: Thumbwheel.cpp:317
bool getShowScale() const
Definition: Thumbwheel.cpp:341
Thumbwheel(Qt::Orientation orientation, QWidget *parent=0)
Definition: Thumbwheel.cpp:34
bool m_showTooltip
Definition: Thumbwheel.h:103
double getMappedValue() const
Definition: Thumbwheel.cpp:248
bool m_clicked
Definition: Thumbwheel.h:99
void enterEvent(QEvent *) override
Definition: Thumbwheel.cpp:347
void setShowScale(bool show)
Definition: Thumbwheel.cpp:335
QString m_title
Definition: Thumbwheel.h:105
void mouseDoubleClickEvent(QMouseEvent *e) override
Definition: Thumbwheel.cpp:373
void setMappedValue(double mappedValue)
Definition: Thumbwheel.cpp:176
float m_rotation
Definition: Thumbwheel.h:94
Manage the little bit of tedious book-keeping associated with translating vertical wheel events into ...
Definition: WheelCounter.h:24
bool m_tracking
Definition: Thumbwheel.h:97
void mouseReleaseEvent(QMouseEvent *e) override
Definition: Thumbwheel.cpp:477
void setMinimumValue(int min)
Definition: Thumbwheel.cpp:122
QSize sizeHint() const override
Definition: Thumbwheel.cpp:642
RangeMapper * m_rangeMapper
Definition: Thumbwheel.h:107
int getValue() const
Definition: Thumbwheel.cpp:242
void setMaximumValue(int max)
Definition: Thumbwheel.cpp:142
WheelCounter m_wheelCounter
Definition: Thumbwheel.h:109
void setTracking(bool tracking)
Definition: Thumbwheel.cpp:323
float m_clickRotation
Definition: Thumbwheel.h:102
void updateMappedValue(int value)
Definition: Thumbwheel.cpp:258
void setValue(int value)
Definition: Thumbwheel.cpp:208
virtual ~Thumbwheel()
Definition: Thumbwheel.cpp:61
bool m_showScale
Definition: Thumbwheel.h:98
void scroll(bool up)
Definition: Thumbwheel.cpp:296
void mousePressEvent(QMouseEvent *e) override
Definition: Thumbwheel.cpp:359
QMenu * m_lastContextMenu
Definition: Thumbwheel.h:106
QImage m_cache
Definition: Thumbwheel.h:108
void mouseMoveEvent(QMouseEvent *e) override
Definition: Thumbwheel.cpp:452
void setSpeed(float speed)
Definition: Thumbwheel.cpp:311
void updateTitle()
Definition: Thumbwheel.cpp:272
const RangeMapper * getRangeMapper() const
Definition: Thumbwheel.h:46
Qt::Orientation m_orientation
Definition: Thumbwheel.h:95
bool m_noMappedUpdate
Definition: Thumbwheel.h:93
void leaveEvent(QEvent *) override
Definition: Thumbwheel.cpp:353
int getDefaultValue() const
Definition: Thumbwheel.cpp:202
void resetToDefault()
Definition: Thumbwheel.cpp:232
int m_default
Definition: Thumbwheel.h:90
void setProvideContextMenu(bool provide)
Definition: Thumbwheel.cpp:116
int getMaximumValue() const
Definition: Thumbwheel.cpp:156
int m_value
Definition: Thumbwheel.h:91
void wheelEvent(QWheelEvent *e) override
Definition: Thumbwheel.cpp:488
double m_mappedValue
Definition: Thumbwheel.h:92
void setShowToolTip(bool show)
Definition: Thumbwheel.cpp:107
void edit()
Definition: Thumbwheel.cpp:385
void mouseLeft()
void valueChanged(int)
void mouseEntered()