Loading...
Searching...
No Matches
QGraphicsXYSpinbox.hpp
1#pragma once
2#include <score/graphics/widgets/Constants.hpp>
3#include <score/graphics/widgets/QGraphicsSpinbox.hpp>
4
5#include <ossia-qt/value_metatypes.hpp>
6
7#include <QGraphicsItem>
8#include <QObject>
9
10#include <score_lib_base_export.h>
11
12#include <verdigris>
13
14namespace score
15{
16struct DefaultGraphicsSpinboxImpl;
17class SCORE_LIB_BASE_EXPORT QGraphicsXYSpinboxChooser final
18 : public QObject
19 , public QGraphicsItem
20{
22 SCORE_GRAPHICS_ITEM_TYPE(260)
23 friend struct DefaultGraphicsSpinboxImpl;
24 QRectF m_rect;
25 QGraphicsSpinbox m_x, m_y;
26
27 std::array<double, 2> m_prev{};
28 bool m_isRange{};
29
30public:
31 explicit QGraphicsXYSpinboxChooser(bool isRange, QGraphicsItem* parent);
33
34 void setPoint(const QPointF& r);
35 void setValue(std::array<float, 2> v);
36 void setValue(std::array<double, 2> v);
37 void setRange(
38 ossia::vec2f min = {0.f, 0.f}, ossia::vec2f max = {1.f, 1.f},
39 ossia::vec2f init = {0.f, 0.f});
40
41 std::array<double, 2> value() const noexcept;
42 std::array<double, 2> getMin() const noexcept;
43 std::array<double, 2> getMax() const noexcept;
44
45 bool moving = false;
46
47public:
48 void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
49 void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
50
51private:
52 void componentMoved(std::size_t source);
53 std::array<double, 2> normalizedValue() const noexcept;
54 std::array<double, 2> scaledValue(double x, double y) const noexcept;
55 QRectF boundingRect() const override;
56 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
57 override;
58};
59
60class SCORE_LIB_BASE_EXPORT QGraphicsIntXYSpinboxChooser final
61 : public QObject
62 , public QGraphicsItem
63{
65 SCORE_GRAPHICS_ITEM_TYPE(270)
66 friend struct DefaultGraphicsSpinboxImpl;
67 QRectF m_rect;
68 QGraphicsIntSpinbox m_x, m_y;
69
70 std::array<double, 2> m_prev{};
71 bool m_grab{};
72 bool m_isRange{};
73
74public:
75 explicit QGraphicsIntXYSpinboxChooser(bool isRange, QGraphicsItem* parent);
77
78 void setPoint(const QPointF& r);
79 void setValue(std::array<float, 2> v);
80 void setValue(std::array<double, 2> v);
81 void setRange(
82 ossia::vec2f min = {0.f, 0.f}, ossia::vec2f max = {1.f, 1.f},
83 ossia::vec2f init = {0.f, 0.f});
84
85 std::array<double, 2> value() const noexcept;
86 std::array<double, 2> getMin() const noexcept;
87 std::array<double, 2> getMax() const noexcept;
88
89 bool moving = false;
90
91public:
92 void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
93 void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
94
95private:
96 void componentMoved(std::size_t source);
97 std::array<double, 2> normalizedValue() const noexcept;
98 std::array<double, 2> scaledValue(double x, double y) const noexcept;
99 QRectF boundingRect() const override;
100 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
101 override;
102};
103}
Definition QGraphicsSpinbox.hpp:69
Definition QGraphicsXYSpinbox.hpp:63
Definition QGraphicsSpinbox.hpp:15
Definition QGraphicsXYSpinbox.hpp:20
Base toolkit upon which the software is built.
Definition Application.cpp:83
Definition DefaultGraphicsSpinboxImpl.hpp:25