Loading...
Searching...
No Matches
QGraphicsTextButton.hpp
1#pragma once
2#include <score/graphics/TextItem.hpp>
3#include <score/graphics/widgets/Constants.hpp>
4
5#include <QGraphicsItem>
6#include <QObject>
7
8#include <score_lib_base_export.h>
9
10#include <verdigris>
11namespace score
12{
13class SCORE_LIB_BASE_EXPORT QGraphicsTextButton final
14 : public QObject
15 , public QGraphicsItem
16{
17 W_OBJECT(QGraphicsTextButton)
18 SCORE_GRAPHICS_ITEM_TYPE(220)
19
20 bool m_pressed{};
21
22public:
23 QGraphicsTextButton(QString text, QGraphicsItem* parent);
24
25 void pressed() E_SIGNAL(SCORE_LIB_BASE_EXPORT, pressed);
26 void dropped(QString filename) E_SIGNAL(SCORE_LIB_BASE_EXPORT, dropped, filename);
27 void bang();
28
29 const QString& text() const noexcept { return m_string; }
30 void setText(const QString& s)
31 {
32 m_string = std::move(s);
33 updateBounds();
34 }
35 QRectF boundingRect() const override;
36
37private:
38 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
39 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
40 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
41
42 void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
43 void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
44 void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override;
45 void dropEvent(QGraphicsSceneDragDropEvent* event) override;
46
47 void updateBounds();
48 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
49 final override;
50 QRectF m_rect;
51 QString m_string;
52};
53}
Definition QGraphicsTextButton.hpp:16
Base toolkit upon which the software is built.
Definition Application.cpp:90