Loading...
Searching...
No Matches
GraphicsItem.hpp
1#pragma once
2#include <QList>
3#include <QPainterPath>
4#include <QUrl>
5
6#include <score_lib_base_export.h>
7
8#include <memory>
9#include <optional>
10#include <verdigris>
11class QGraphicsObject;
12class QGraphicsItem;
13class QGraphicsScene;
14class QGraphicsView;
15
16namespace score
17{
18struct DocumentContext;
19}
27SCORE_LIB_BASE_EXPORT void deleteGraphicsObject(QGraphicsObject* item);
28SCORE_LIB_BASE_EXPORT void deleteGraphicsItem(QGraphicsItem* item);
29
30SCORE_LIB_BASE_EXPORT
31QGraphicsView* getView(const QGraphicsItem& self);
32SCORE_LIB_BASE_EXPORT
33QGraphicsView* getView(const QPainter& painter);
34
35SCORE_LIB_BASE_EXPORT
36QImage newImage(double logical_w, double logical_h);
37
38SCORE_LIB_BASE_EXPORT
39std::optional<QPointF> mapPointToItem(QPoint global, QGraphicsItem& item);
40
41SCORE_LIB_BASE_EXPORT
42void registerItemHelp(int itemType, QString tooltip, QUrl url) noexcept;
43SCORE_LIB_BASE_EXPORT
44QUrl getItemHelpUrl(int itemType) noexcept;
45
46namespace score
47{
59SCORE_LIB_BASE_EXPORT
60void retargetInputMethod(QObject* target) noexcept;
61
67SCORE_LIB_BASE_EXPORT
68void watchSceneInputMethod(QGraphicsScene& scene);
69}
70
71template <typename T>
73{
74 T* impl{};
75 graphics_item_ptr() = default;
76 graphics_item_ptr(const graphics_item_ptr&) = default;
77 graphics_item_ptr(graphics_item_ptr&&) noexcept = default;
78 graphics_item_ptr& operator=(const graphics_item_ptr&) = default;
79 graphics_item_ptr& operator=(graphics_item_ptr&&) noexcept = default;
80
82 : impl{p}
83 {
84 }
85
86 ~graphics_item_ptr() { deleteGraphicsItem(impl); }
87
88 auto operator=(T* other) { impl = other; }
89
90 operator bool() const { return impl; }
91
92 operator T*() const { return impl; }
93
94 T& operator*() const { return *impl; }
95
96 T* operator->() const { return impl; }
97};
Base toolkit upon which the software is built.
Definition Application.cpp:116
void retargetInputMethod(QObject *target) noexcept
Point the platform input method at target.
Definition GraphicsItem.cpp:43
void watchSceneInputMethod(QGraphicsScene &scene)
Keep the platform input method in sync with the scene's focus item.
Definition GraphicsItem.cpp:48
Definition GraphicsItem.hpp:73