annotate widgets/Thumbwheel.h @ 1586:bbc3f537564c

Add context menu to Thumbwheel
author Chris Cannam
date Fri, 27 Mar 2020 11:04:56 +0000
parents a18e78b9c78b
children
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@1303 16 #ifndef SV_THUMBWHEEL_H
Chris@1303 17 #define SV_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@1303 24 #include "WheelCounter.h"
Chris@1303 25
Chris@187 26 class RangeMapper;
Chris@1586 27 class QMenu;
Chris@187 28
Chris@132 29 class Thumbwheel : public QWidget
Chris@132 30 {
Chris@132 31 Q_OBJECT
Chris@132 32
Chris@132 33 public:
Chris@133 34 Thumbwheel(Qt::Orientation orientation, QWidget *parent = 0);
Chris@132 35 virtual ~Thumbwheel();
Chris@132 36
Chris@133 37 int getMinimumValue() const;
Chris@133 38 int getMaximumValue() const;
Chris@133 39 int getDefaultValue() const;
Chris@132 40 float getSpeed() const;
Chris@132 41 bool getTracking() const;
Chris@132 42 bool getShowScale() const;
Chris@132 43 int getValue() const;
Chris@132 44
Chris@187 45 void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete
Chris@187 46 const RangeMapper *getRangeMapper() const { return m_rangeMapper; }
Chris@908 47 double getMappedValue() const;
Chris@187 48
Chris@187 49 void setShowToolTip(bool show);
Chris@1586 50 void setProvideContextMenu(bool provide);
Chris@187 51
Chris@1406 52 QSize sizeHint() const override;
Chris@132 53
Chris@132 54 signals:
Chris@132 55 void valueChanged(int);
Chris@132 56
Chris@189 57 void mouseEntered();
Chris@189 58 void mouseLeft();
Chris@189 59
Chris@133 60 public slots:
Chris@133 61 void setMinimumValue(int min);
Chris@133 62 void setMaximumValue(int max);
Chris@133 63 void setDefaultValue(int deft);
Chris@133 64 void setSpeed(float speed);
Chris@133 65 void setTracking(bool tracking);
Chris@133 66 void setShowScale(bool show);
Chris@133 67 void setValue(int value);
Chris@908 68 void setMappedValue(double mappedValue);
Chris@256 69 void scroll(bool up);
Chris@133 70 void resetToDefault();
Chris@1586 71 void edit();
Chris@133 72
Chris@187 73 protected slots:
Chris@187 74 void updateMappedValue(int value);
Chris@1586 75 void updateTitle();
Chris@1586 76 void contextMenuRequested(const QPoint &);
Chris@187 77
Chris@189 78 protected:
Chris@1406 79 void mousePressEvent(QMouseEvent *e) override;
Chris@1406 80 void mouseDoubleClickEvent(QMouseEvent *e) override;
Chris@1406 81 void mouseMoveEvent(QMouseEvent *e) override;
Chris@1406 82 void mouseReleaseEvent(QMouseEvent *e) override;
Chris@1406 83 void wheelEvent(QWheelEvent *e) override;
Chris@1406 84 void paintEvent(QPaintEvent *e) override;
Chris@1406 85 void enterEvent(QEvent *) override;
Chris@1406 86 void leaveEvent(QEvent *) override;
Chris@189 87
Chris@132 88 int m_min;
Chris@132 89 int m_max;
Chris@132 90 int m_default;
Chris@132 91 int m_value;
Chris@908 92 double m_mappedValue;
Chris@187 93 bool m_noMappedUpdate;
Chris@165 94 float m_rotation;
Chris@132 95 Qt::Orientation m_orientation;
Chris@132 96 float m_speed;
Chris@132 97 bool m_tracking;
Chris@132 98 bool m_showScale;
Chris@132 99 bool m_clicked;
Chris@133 100 bool m_atDefault;
Chris@132 101 QPoint m_clickPos;
Chris@165 102 float m_clickRotation;
Chris@187 103 bool m_showTooltip;
Chris@1586 104 bool m_provideContextMenu;
Chris@1586 105 QString m_title;
Chris@1586 106 QMenu *m_lastContextMenu;
Chris@187 107 RangeMapper *m_rangeMapper;
Chris@382 108 QImage m_cache;
Chris@1303 109 WheelCounter m_wheelCounter;
Chris@132 110 };
Chris@132 111
Chris@132 112 #endif