Loading...
Searching...
No Matches
QGraphicsToggleGrid.hpp
1#pragma once
2#include <score/graphics/widgets/Constants.hpp>
3
4#include <ossia/network/value/value.hpp>
5
6#include <QGraphicsItem>
7#include <QObject>
8#include <QStringList>
9
10#include <score_lib_base_export.h>
11
12#include <vector>
13
14#include <verdigris>
15
16namespace score
17{
26class SCORE_LIB_BASE_EXPORT QGraphicsToggleGrid
27 : public QObject
28 , public QGraphicsItem
29{
30 W_OBJECT(QGraphicsToggleGrid)
31 SCORE_GRAPHICS_ITEM_TYPE(340)
32
33public:
34 explicit QGraphicsToggleGrid(QGraphicsItem* parent);
36
39 void setLabels(QStringList labels, int perRow);
40 const QStringList& labels() const noexcept { return m_labels; }
41
42 void setValue(const ossia::value& v);
43 ossia::value value() const;
44
45 virtual QString toText() const;
47 virtual bool setText(const QString& text);
48
49 bool moving = false;
50
51 QRectF boundingRect() const override;
52
53public:
54 void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
55 void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
56
57protected:
59 void set(std::vector<bool> on);
60 const std::vector<bool>& cells() const noexcept { return m_on; }
61
62 virtual QString editTitle() const;
63 virtual QString editHint() const;
64 virtual QString editError() const;
65
66private:
67 QRectF cellRect(int cell) const noexcept;
68 int cellAt(QPointF p) const noexcept;
69
70 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
71 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
72 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
73 bool sceneEvent(QEvent* event) override;
74 void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
75 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
76 override;
77
78 QStringList m_labels;
79 std::vector<bool> m_on;
80 int m_perRow{8};
81 qreal m_cellWidth{16.};
83 bool m_paint{};
84 bool m_grab{};
85};
86}
Definition QGraphicsToggleGrid.hpp:29
Base toolkit upon which the software is built.
Definition Application.cpp:83