Debian Codegraph @

libs/ui/canvas/kis_canvas_decoration.h

raw symbols SCIP
1 /*
2 * SPDX-FileCopyrightText: 2008 Cyrille Berger <[email protected]>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef _KIS_CANVAS_DECORATION_H_
8 #define _KIS_CANVAS_DECORATION_H_
9
10 #include <QObject>
11 #include <QPointer>
12
13 #include <kritaui_export.h>
14 #include <kis_image.h>
15 #include "KisView.h"
16 #include <kis_shared.h>
17
18 class KisCanvasWidgetBase;
19 class KisCanvas2;
20 class QRectF;
21 class QPainter;
22 class KisCoordinatesConverter;
23
24 class KisCanvasDecoration;
25 typedef KisSharedPtr<KisCanvasDecoration> KisCanvasDecorationSP;
26
27 /**
28 * This class is the base class for object that draw a decoration on the canvas,
29 * for instance, selections, grids, tools, ...
30 */
31 class KRITAUI_EXPORT KisCanvasDecoration : public QObject, public KisShared
32 {
33 Q_OBJECT
34 public:
35 KisCanvasDecoration(const QString& id, QPointer<KisView>parent);
36
37 ~KisCanvasDecoration() override;
38
39 void setView(QPointer<KisView> imageView);
40
41 const QString& id() const;
42
43 /**
44 * @return whether the decoration is visible.
45 */
46 bool visible() const;
47
48 /**
49 * Will paint the decoration on the QPainter, if the visible is set to @c true.
50 *
51 * @param gc the painter
52 * @param updateRect dirty rect in document pixels
53 * @param converter coordinate converter
54 * @param canvas the canvas
55 */
56 void paint(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter,KisCanvas2* canvas);
57
58 /**
59 * Return z-order priority of the decoration. The higher the priority, the higher
60 * the decoration is painted.
61 */
62 int priority() const;
63
64 static bool comparePriority(KisCanvasDecorationSP decoration1, KisCanvasDecorationSP decoration2);
65
66 virtual void notifyWindowMinimized(bool minimized);
67 virtual void setCanvasWidget(KisCanvasWidgetBase* canvas) { Q_UNUSED(canvas); };
68
69 public Q_SLOTS:
70 /**
71 * Set if the decoration is visible or not.
72 */
73 virtual void setVisible(bool v);
74 /**
75 * If decoration is visible, hide it, if not show it.
76 */
77 void toggleVisibility();
78 protected:
79 virtual void drawDecoration(QPainter& gc, const QRectF& updateArea, const KisCoordinatesConverter *converter,KisCanvas2* canvas) = 0;
80
81
82 /**
83 * @return the parent KisView
84 */
85 QPointer<KisView> view() const;
86
87 /**
88 * Set the priority of the decoration. The higher the priority, the higher
89 * the decoration is painted.
90 */
91 void setPriority(int value);
92
93 // returns the minimum decoration thickness, somewhat equivalent to the display scaling.
94 int decorationThickness() const;
95
96 private:
97 struct Private;
98 Private* const d;
99 };
100
101 #endif