Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_painting_assistants_decoration.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2009 Cyrille Berger <cberger@cberger.net>
3 * SPDX-FileCopyrightText: 2017 Scott Petrovic <scottpetrovic@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#ifndef _KIS_PAINTING_ASSISTANTS_MANAGER_H_
9#define _KIS_PAINTING_ASSISTANTS_MANAGER_H_
10
11#include <QPointF>
12#include <QColor>
13
14#include "KoPointerEvent.h"
15#include "KoSnapGuide.h"
16#include "kis_icon_utils.h"
19#include <kritaui_export.h>
20
21class KisView;
23
26
27// Data for editor widget. This is shared between the decoration and assistant tool which needs hit box information
29 //button count to loop over
30 unsigned int buttoncount = 6;
31 //button icon size
32 const int buttonSize = 24;
33 //boolean values track which buttons are enabled within the editor widget
39 bool widgetActivated = true;
40 const int widgetOffset = 10;
41 //padding for dynamic positioning between buttons
42 const int buttonPadding = 7;
43 //button positions
44 QPointF moveIconPosition = QPointF(0, 0);
45 QPointF snapIconPosition = QPointF(0, 0);
46 QPointF lockedIconPosition = QPointF(0, 0);
47 QPointF duplicateIconPosition = QPointF(0, 0);
48 QPointF deleteIconPosition = QPointF(0, 0);
49 QSize boundingSize = QSize(0, 0);
50 //size of the side drag decoration
51 const int dragDecorationWidth = 15;
52 //QPixMaps representing icons for buttons
53 const QImage m_iconMove = KisIconUtils::loadIcon("transform-move").pixmap(buttonSize+10, buttonSize+10).toImage();
54 const QImage m_iconSnapOn = KisIconUtils::loadIcon("visible").pixmap(buttonSize, buttonSize).toImage();
55 const QImage m_iconSnapOff = KisIconUtils::loadIcon("novisible").pixmap(buttonSize, buttonSize).toImage();
56 const QImage m_iconLockOn = KisIconUtils::loadIcon("layer-locked").pixmap(buttonSize, buttonSize).toImage();
57 const QImage m_iconLockOff = KisIconUtils::loadIcon("layer-unlocked").pixmap(buttonSize, buttonSize).toImage();
58 const QImage m_iconDuplicate = KisIconUtils::loadIcon("duplicateitem").pixmap(buttonSize, buttonSize).toImage();
59 const QImage m_iconDelete = KisIconUtils::loadIcon("deletelayer").pixmap(buttonSize, buttonSize).toImage();
60 //how many buttons fit horizontally before extending to the next row
61 const int horizontalButtonLimit = 3;
62};
63
75{
76 Q_OBJECT
77public:
80 void addAssistant(KisPaintingAssistantSP assistant);
81 void raiseAssistant(KisPaintingAssistantSP assistant);
82 void removeAssistant(KisPaintingAssistantSP assistant);
83 void removeAll();
84 void setAssistants(const QList<KisPaintingAssistantSP> &assistants);
85 QPointF adjustPosition(const QPointF& point, const QPointF& strokeBegin);
86 void adjustLine(QPointF &point, QPointF& strokeBegin);
87 void setAdjustedBrushPosition(const QPointF position);
88 void endStroke();
90 QList<KisPaintingAssistantSP> assistants() const;
91 //store the editor data to be used to control the render/interaction of the editor widget.
92 struct AssistantEditorData globalEditorWidgetData;
93 bool hasPaintableAssistants() const;
94
95
98 KisPaintingAssistantSP selectedAssistant();
99 void setSelectedAssistant(KisPaintingAssistantSP assistant);
100 void deselectAssistant();
101
102
105 void activateAssistantsEditor();
106
107
110 void deactivateAssistantsEditor();
111
114 bool isEditingAssistants();
115
116
118 void setAssistantVisible(bool set);
119
121 void setOutlineVisible(bool set);
122
124 void setOnlyOneAssistantSnap(bool assistant);
125
127 void setEraserSnap(bool assistant);
128
130 bool assistantVisibility();
131
133 bool outlineVisibility();
134
136 void uncache();
137
138 int handleSize();
139 void setHandleSize(int handleSize);
140
141 QColor globalAssistantsColor();
142 void setGlobalAssistantsColor(QColor color);
143
144Q_SIGNALS:
147
148public Q_SLOTS:
149
151 void toggleAssistantVisible();
152
154 void toggleOutlineVisible();
155 QPointF snapToGuide(KoPointerEvent *e, const QPointF &offset, bool useModifiers);
156 QPointF snapToGuide(const QPointF& pt, const QPointF &offset);
157
158 void slotUpdateDecorationVisibility();
159 void slotConfigChanged();
160
161protected:
162 void drawDecoration(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter,KisCanvas2* canvas) override;
163 void drawHandles(KisPaintingAssistantSP assistant, QPainter& gc, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *renderInterface);
164 void drawEditorWidget(KisPaintingAssistantSP assistant, QPainter& gc, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *renderInterface);
165
166private:
167 struct Private;
168 Private* const d;
169};
170
171#endif
virtual void drawDecoration(QPainter &gc, const QRectF &updateArea, const KisCoordinatesConverter *converter, KisCanvas2 *canvas)=0
KisSharedPtr< KisPaintingAssistantsDecoration > KisPaintingAssistantsDecorationSP
QIcon loadIcon(const QString &name)