Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_preset_live_preview_view.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Scott Petrovic <scottpetrovic@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef _KIS_PRESET_LIVE_PREVIEW_
8#define _KIS_PRESET_LIVE_PREVIEW_
9
10#include <QGraphicsView>
11#include <QPainterPath>
12
13#include <KoColor.h>
14
16#include "kis_paintop_preset.h"
19#include <kis_types.h>
20
22class KoColorSpace;
23class QGraphicsPixmapItem;
24class QGraphicsScene;
25class QGraphicsTextItem;
26
34class KisPresetLivePreviewView : public QGraphicsView
35{
36 Q_OBJECT
37
38
39public:
40
41 KisPresetLivePreviewView(QWidget *parent);
43
50
59 void setCachePreviewMode(bool enabled);
61
62Q_SIGNALS:
69 void sigPreviewImageReady(int presetId, QImage previewImage);
70
71private Q_SLOTS:
72 void updateStroke();
74
75private:
76 static constexpr int DefaultUpdateDelayMs = 100;
77
80
83
86
88 const KoColorSpace *m_colorSpace {nullptr};
89
92
94 QGraphicsScene *m_brushPreviewScene {nullptr};
95
97 QGraphicsPixmapItem *m_sceneImageItem {nullptr};
98
100 QGraphicsTextItem *m_noPreviewText {nullptr};
101
106
110
114 QPainterPath m_curvedLine;
117
122
127
130 bool m_cachePreviewMode {false};
131
133 const float m_minBrushVal {10.0};
134 const float m_maxBrushVal {100.0};
135
137 const qreal m_minScale {1.0};
138 const qreal m_maxScale {0.3};
139
141 const float m_minStrokeScale {0.4}; // for smaller brush stroke
142 const float m_maxStrokeScale {1.0}; // for larger brush stroke
143
144
149 void paintBackground(bool cacheMode);
150
155
160 void setupAndPaintStroke();
161
162 void changeEvent(QEvent*) override;
163
166
169};
170
171#endif
int m_previewPresetId
presetId (resource id) associated with the in-flight preview generation.
QGraphicsScene * m_brushPreviewScene
the scene that can add items like text and the brush stroke image
const float m_minStrokeScale
multiplier that is used for lengthening the brush stroke points
const qreal m_minScale
range of scale values. 1.0 == 100%
void sigPreviewImageReady(int presetId, QImage previewImage)
Emitted when a preview image is generated.
const KoColorSpace * m_colorSpace
internally sets the color space for brush preview
void setupAndPaintStroke()
creates and performs the actual stroke that goes on top of the background this is internally and shou...
KoCanvasResourceProvider * m_resourceManager
internally sets the Resource Provider for brush preview (allowing gradients in preview)
void setCurrentPreset(KisPaintOpPresetSP preset)
set the current preset from resource manager for the live preview to use. Good to call this every str...
QGraphicsTextItem * m_noPreviewText
holds the 'no preview available' text object
KisImageSP m_image
internally sets the image area for brush preview
void paintBackground(bool cacheMode)
works as both clearing the previous stroke, providing striped backgrounds for smudging brushes,...
QGraphicsPixmapItem * m_sceneImageItem
holds the preview brush stroke data
QImage m_lastPreviewImage
Last preview image.
KisLayerSP m_layer
internally sets the layer area for brush preview
void setup(KoCanvasResourceProvider *resourceManager)
one time setup for initialization of many variables. This live preview might be in a UI file,...
KoCanvasResourceProvider * resourceManager() const
KoColor m_paintColor
the color which is used for rendering the stroke
void paintStripedBackground()
Paint alternating gray stripes on the paint device.
const float m_minBrushVal
the range of brush sizes that will control zooming in/out