Krita Source Code Documentation
Loading...
Searching...
No Matches
PaintingResources.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Scott Petrovic <scottpetrovic@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#include "PaintingResources.h"
7
8#include "KisView.h"
9#include "KisPart.h"
11#include "KisViewManager.h"
12#include "KisMainWindow.h"
13#include "kis_image.h"
14#include "KisToolShapeUtils.h"
15
16
18 "None", // 0 = KisToolShapeUtils::StrokeStyle::StrokeStyleNone
19 "ForegroundColor", // KisToolShapeUtils::StrokeStyle::StrokeStyleForeground
20 "BackgroundColor" // KisToolShapeUtils::StrokeStyle::StrokeStyleBackground
21};
22
24 "None", // 0 = KisToolShapeUtils::FillStyle::FillStyleNone
25 "ForegroundColor", // KisToolShapeUtils::FillStyle::FillStyleForegroundColor
26 "BackgroundColor", // KisToolShapeUtils::FillStyle::FillStyleBackgroundColor
27 "Pattern" // KisToolShapeUtils::FillStyle::FillStylePattern
28};
29
31 KisNodeSP node,
32 const QString strokeStyleString,
33 const QString fillStyleString)
34{
35 // need to grab the resource provider
38
39 int strokeIndex = StrokeStyle.indexOf(strokeStyleString);
40 if (strokeIndex == -1) {
41 dbgScript << "Script tried to paint with invalid strokeStyle" << strokeStyleString << ", ignoring and using" << defaultStrokeStyle << ".";
42 strokeIndex = StrokeStyle.indexOf(defaultStrokeStyle);
43 if (strokeIndex == -1) {
44 warnScript << "PaintingResources::createHelper(): defaultStrokeStyle" << defaultStrokeStyle << "is invalid!";
45 strokeIndex = 1;
46 }
47 }
49
50 int fillIndex = FillStyle.indexOf(fillStyleString);
51 if (fillIndex == -1) {
52 dbgScript << "Script tried to paint with invalid fillStyle" << fillStyleString << ", ignoring and using" << defaultFillStyle << ".";
53 fillIndex = FillStyle.indexOf(defaultFillStyle);
54 if (fillIndex == -1) {
55 warnScript << "PaintingResources::createHelper(): defaultFillStyle" << defaultFillStyle << " is invalid!";
56 fillIndex = 0;
57 }
58 }
60
61 const KUndo2MagicString name = kundo2_i18n("Scripted Brush Stroke");
63 name,
64 image,
65 node, resourceManager,
66 strokeStyle,
67 fillStyle
68 );
69
70 return helper;
71}
const QStringList StrokeStyle
const QStringList FillStyle
KoCanvasResourceProvider * resourceManager()
QPointer< KisView > activeView
static KisPart * instance()
Definition KisPart.cpp:131
KisMainWindow * currentMainwindow() const
Definition KisPart.cpp:483
KisCanvasResourceProvider * canvasResourceProvider()
KisViewManager * viewManager
Definition KisView.cpp:129
#define dbgScript
Definition kis_debug.h:56
#define warnScript
Definition kis_debug.h:98
KUndo2MagicString kundo2_i18n(const char *text)
KisFigurePaintingToolHelper createHelper(KisImageWSP image, KisNodeSP node, const QString strokeStyle=defaultStrokeStyle, const QString fillStyle=defaultFillStyle)
const QString defaultStrokeStyle
const QString defaultFillStyle