31 ,
public QGraphicsItem
34 SCORE_GRAPHICS_ITEM_TYPE(330)
48 static constexpr uint32_t
flag(Unit u)
noexcept
50 return u == Parent ? (1u << 4) : (1u << int(u));
53 using Feel = note_values::Feel;
56 static constexpr std::array<float, 7> periodDetents{0.25f, 0.5f, 1.f, 2.f,
61 double min{0.}, max{8.};
63 ossia::vec2f init{0.25f, float(Note)};
66 explicit QGraphicsGridChooser(QGraphicsItem* parent);
67 ~QGraphicsGridChooser();
70 void setUnits(uint32_t units);
71 [[nodiscard]] uint32_t units() const noexcept {
return m_units; }
72 void setMaxBars(
int bars);
73 [[nodiscard]]
int maxBars() const noexcept {
return m_maxBars; }
75 void setPeriodName(
const QString& name);
76 [[nodiscard]]
const QString& periodName() const noexcept {
return m_periodName; }
77 void setMaxSeconds(
double seconds);
79 void setRect(
const QRectF& r);
80 void setValue(ossia::vec2f v);
81 [[nodiscard]] ossia::vec2f value() const noexcept;
82 void setExecutionValue(ossia::vec2f v);
83 void resetExecution();
85 [[nodiscard]] Unit unit() const noexcept {
return m_unit; }
86 [[nodiscard]] Feel feel() const noexcept {
return m_feel; }
89 void chooseUnit(Unit u);
91 void chooseFeel(Feel f);
94 [[nodiscard]] QString text()
const;
96 [[nodiscard]]
static QString
97 label(ossia::vec2f v,
const QString& periodName = QStringLiteral(
"loop"));
99 [[nodiscard]]
static QString
100 unitName(Unit u,
const QString& periodName = QStringLiteral(
"loop"));
103 [[nodiscard]] QMenu* makeUnitMenu();
105 QRectF boundingRect()
const override;
107 void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
108 void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
111 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
113 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
114 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
115 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
116 bool sceneEvent(QEvent* event) override;
117 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
118 void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
119 void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
120 void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
124 double map(
double position) const noexcept;
125 double unmap(
double seconds) const noexcept;
126 bool onReadout(QPointF pos) const noexcept;
129 double positionOf(Unit u,
double value) const noexcept;
130 double valueAt(Unit u,
double position) const noexcept;
132 double snap(
double position,
bool allNoteValues) const noexcept;
133 void dragTo(
double position,
bool allNoteValues);
134 void popupUnitMenu(QPoint screenPos);
137 QRectF m_rect{0., 0., 35., 35.};
140 double m_execValue{};
143 std::array<double, 4> m_values{0., 0.25, 1., 1.};
144 QString m_periodName{QStringLiteral(
"loop")};
145 uint32_t m_units{flag(Free) | flag(Note) | flag(Bars)};
148 Feel m_feel{Feel::Straight};