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{0., 0., 150., 24.};
25 QGraphicsSpinbox m_x, m_y;
26
27 bool m_isRange{};
28
29public:
30 explicit QGraphicsXYSpinboxChooser(bool isRange, QGraphicsItem* parent);
32
33 void setPoint(const QPointF& r);
34 void setValue(std::array<float, 2> v);
35 void setValue(std::array<double, 2> v);
36 void setRange(
37 ossia::vec2f min = {0.f, 0.f}, ossia::vec2f max = {1.f, 1.f},
38 ossia::vec2f init = {0.f, 0.f});
39
40 std::array<double, 2> value() const noexcept;
41 std::array<double, 2> getMin() const noexcept;
42 std::array<double, 2> getMax() const noexcept;
43
44 bool moving = false;
45
46public:
47 void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
48 void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
49
50private:
51 std::array<double, 2> scaledValue(double x, double y) const noexcept;
52 QRectF boundingRect() const override;
53 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
54 override;
55};
56
57class SCORE_LIB_BASE_EXPORT QGraphicsIntXYSpinboxChooser final
58 : public QObject
59 , public QGraphicsItem
60{
62 SCORE_GRAPHICS_ITEM_TYPE(270)
63 friend struct DefaultGraphicsSpinboxImpl;
64 QRectF m_rect{0., 0., 150., 24.};
65 QGraphicsIntSpinbox m_x, m_y;
66
67 bool m_grab{};
68 bool m_isRange{};
69
70public:
71 explicit QGraphicsIntXYSpinboxChooser(bool isRange, QGraphicsItem* parent);
73
74 void setPoint(const QPointF& r);
75 void setValue(std::array<float, 2> v);
76 void setValue(std::array<double, 2> v);
77 void setRange(
78 ossia::vec2f min = {0.f, 0.f}, ossia::vec2f max = {1.f, 1.f},
79 ossia::vec2f init = {0.f, 0.f});
80
81 std::array<double, 2> value() const noexcept;
82 std::array<double, 2> getMin() const noexcept;
83 std::array<double, 2> getMax() const noexcept;
84
85 bool moving = false;
86
87public:
88 void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
89 void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
90
91private:
92 std::array<double, 2> scaledValue(double x, double y) const noexcept;
93 QRectF boundingRect() const override;
94 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
95 override;
96};
97}
Definition QGraphicsSpinbox.hpp:64
Definition QGraphicsXYSpinbox.hpp:60
Definition QGraphicsSpinbox.hpp:15
Definition QGraphicsXYSpinbox.hpp:20
Base toolkit upon which the software is built.
Definition Application.cpp:90
Definition DefaultGraphicsSpinboxImpl.hpp:24