Loading...
Searching...
No Matches
QGraphicsRangeSlider.hpp
1#pragma once
2#include <score/graphics/widgets/Constants.hpp>
3
4#include <ossia/network/value/value.hpp>
5#include <ossia/network/value/vec.hpp>
6
7#include <QGraphicsItem>
8#include <QObject>
9
10#include <score_lib_base_export.h>
11
12#include <verdigris>
13
15
16namespace score
17{
18class SCORE_LIB_BASE_EXPORT QGraphicsRangeSlider final
19 : public QObject
20 , public QGraphicsItem
21{
22 W_OBJECT(QGraphicsRangeSlider)
23 SCORE_GRAPHICS_ITEM_TYPE(160)
24 QRectF m_rect{defaultRangeSliderSize};
25
26 double m_start{0.}, m_end{1.};
27 double m_min{0}, m_max{1};
28 double m_init_start{0.}, m_init_end{1.};
29
30public:
31 bool moving = false;
32
33 explicit QGraphicsRangeSlider(QGraphicsItem* parent);
35
36 void setStart(double start);
37 void setEnd(double end);
38 void setRange(double min, double max, ossia::vec2f init);
39
40 void setValue(ossia::vec2f value);
41 ossia::vec2f value() const noexcept;
42 ossia::vec2f m_execValue{};
43 void setExecutionValue(ossia::vec2f); // TODO
44 void resetExecution(); // TODO
45
46 void startChanged(double arg_1) E_SIGNAL(SCORE_LIB_BASE_EXPORT, startChanged, arg_1)
47 void endChanged(double arg_1) E_SIGNAL(SCORE_LIB_BASE_EXPORT, endChanged, arg_1)
48
49 void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
50 void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
51private:
52 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
53 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
54 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
55 QRectF boundingRect() const override;
56 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
57 override;
58 void updateRect();
59 qreal y_factor{0.005};
60 qreal d2s{}, d2c{}, d2e{}, ypos{}, ydiff{};
61 double val1{}, val2{};
62
63 bool m_hasExec{};
64
65 enum Handle
66 {
67 START,
68 CENTER,
69 END,
70 NONE
71 };
72 Handle handle{};
73 QRectF m_rangeRect{};
74};
75}
Definition QGraphicsRangeSlider.hpp:21
Base toolkit upon which the software is built.
Definition Application.cpp:90