Loading...
Searching...
No Matches
QGraphicsKnob.hpp
1#pragma once
2#include <score/graphics/widgets/Constants.hpp>
3
4#include <QGraphicsItem>
5#include <QObject>
6
7#include <score_lib_base_export.h>
8
9#include <verdigris>
10
11namespace score
12{
13class SCORE_LIB_BASE_EXPORT QGraphicsKnob
14 : public QObject
15 , public QGraphicsItem
16{
17 W_OBJECT(QGraphicsKnob)
18 SCORE_GRAPHICS_ITEM_TYPE(70)
19 friend struct DefaultControlImpl;
20 friend struct DefaultGraphicsKnobImpl;
21
22protected:
23 double m_value{};
24 double m_execValue{};
25 QRectF m_rect{defaultKnobSize};
26
27public:
28 double min{}, max{}, init{};
29
30private:
31 bool m_grab{};
32 bool m_hasExec{};
33
34public:
35 explicit QGraphicsKnob(QGraphicsItem* parent);
37
38 double unmap(double v) const noexcept { return (v - min) / (max - min); }
39 double map(double v) const noexcept { return (v * (max - min)) + min; }
40
41 void setRect(const QRectF& r);
42 void setRange(double min, double max, double init);
43 void setValue(double v);
44 double value() const;
45 void setExecutionValue(double v);
46 void resetExecution();
47
48 QRectF boundingRect() const override;
49
50 bool moving = false;
51
52public:
53 void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
54 void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
55
56private:
57 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
58 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
59 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
60 void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
61 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
62
63 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
64 override;
65};
66}
Definition QGraphicsKnob.hpp:16
Base toolkit upon which the software is built.
Definition Application.cpp:90
Definition DefaultControlImpl.hpp:10
Definition DefaultGraphicsKnobImpl.hpp:24