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 <QGraphicsScene>
11#include <QGraphicsView>
12#include <QPainterPath>
13#include <QGraphicsPixmapItem>
14
15#include "kis_paintop_preset.h"
17#include "kis_paint_layer.h"
18#include "kis_painter.h"
21#include <kis_image.h>
22#include <kis_types.h>
23#include <KoColor.h>
25
27
35class KisPresetLivePreviewView : public QGraphicsView
36{
37 Q_OBJECT
38
39
40public:
41
42 KisPresetLivePreviewView(QWidget *parent);
44
50 void setup(KoCanvasResourceProvider* resourceManager);
51
59
60private Q_SLOTS:
61 void updateStroke();
63
64private:
65
68
71
74
76 const KoColorSpace *m_colorSpace {nullptr};
77
80
82 QGraphicsScene *m_brushPreviewScene {nullptr};
83
85 QGraphicsPixmapItem *m_sceneImageItem {nullptr};
86
88 QGraphicsTextItem *m_noPreviewText {nullptr};
89
94
98
102 QPainterPath m_curvedLine;
105
110
115
118
120 const float m_minBrushVal {10.0};
121 const float m_maxBrushVal {100.0};
122
124 const qreal m_minScale {1.0};
125 const qreal m_maxScale {0.3};
126
128 const float m_minStrokeScale {0.4}; // for smaller brush stroke
129 const float m_maxStrokeScale {1.0}; // for larger brush stroke
130
131
136 void paintBackground();
137
142 void setupAndPaintStroke();
143
144 void changeEvent(QEvent*) override;
145};
146
147#endif
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%
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()
works as both clearing the previous stroke, providing striped backgrounds for smudging brushes,...
QGraphicsPixmapItem * m_sceneImageItem
holds the preview brush stroke data
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,...
KoColor m_paintColor
the color which is used for rendering the stroke
const float m_minBrushVal
the range of brush sizes that will control zooming in/out