Krita Source Code Documentation
Loading...
Searching...
No Matches
KisCanvasWidgetBase Class Referenceabstract

#include <kis_canvas_widget_base.h>

+ Inheritance diagram for KisCanvasWidgetBase:

Classes

struct  Private
 

Public Member Functions

void addDecoration (KisCanvasDecorationSP deco) override
 
QColor borderColor () const
 
KisCoordinatesConvertercoordinatesConverter () const
 
BitDepthMode currentBitDepthMode () const override
 
QString currentBitDepthUserReport () const override
 
KisCanvasDecorationSP decoration (const QString &id) const override
 
QList< KisCanvasDecorationSPdecorations () const override
 
void drawDecorations (QPainter &gc, const QRect &updateWidgetRect) const override
 
 KisCanvasWidgetBase (KisCanvas2 *canvas, KisCoordinatesConverter *coordinatesConverter)
 
void notifyDecorationsWindowMinimized (bool minimized)
 
void removeDecoration (const QString &id) override
 
void setDecorations (const QList< KisCanvasDecorationSP > &) override
 
void setWrapAroundViewingMode (bool value) override
 
void setWrapAroundViewingModeAxis (WrapAroundAxis value) override
 
KoToolProxytoolProxy () const override
 
QVector< QRect > updateCanvasProjection (const QVector< KisUpdateInfoSP > &infoObjects) override
 
virtual QVector< QRect > updateCanvasProjection (const QVector< KisUpdateInfoSP > &infoObjects)=0
 
virtual QRect updateCanvasProjection (KisUpdateInfoSP info)=0
 
 ~KisCanvasWidgetBase () override
 
- Public Member Functions inherited from KisAbstractCanvasWidget
virtual void channelSelectionChanged (const QBitArray &channelFlags)=0
 
virtual void finishResizingImage (qint32 w, qint32 h)=0
 
virtual bool isBusy () const =0
 
 KisAbstractCanvasWidget ()
 
virtual void notifyImageColorSpaceChanged (const KoColorSpace *cs)=0
 set/update the color space of the attached image
 
virtual void setDisplayConfig (const KisDisplayConfig &config)=0
 
virtual void setDisplayFilter (QSharedPointer< KisDisplayFilter > displayFilter)=0
 set the specified display filter on the canvas
 
virtual void setLodResetInProgress (bool value)=0
 
virtual KisUpdateInfoSP startUpdateCanvasProjection (const QRect &rc)=0
 
virtual void updateCanvasDecorations (const QRect &decoUpdateRect)=0
 
virtual void updateCanvasImage (const QRect &imageUpdateRect)=0
 
virtual QWidget * widget ()=0
 
virtual bool wrapAroundViewingMode () const =0
 
virtual WrapAroundAxis wrapAroundViewingModeAxis () const =0
 
virtual ~KisAbstractCanvasWidget ()
 

Static Public Member Functions

static QImage createCheckersImage (qint32 checkSize=-1)
 

Protected Member Functions

virtual bool callFocusNextPrevChild (bool next)=0
 To be implemented by the derived canvas.
 
KisCanvas2canvas () const
 
void notifyConfigChanged ()
 
void processFocusInEvent (QFocusEvent *event)
 
void processFocusOutEvent (QFocusEvent *event)
 
void processInputMethodEvent (QInputMethodEvent *event)
 
QVariant processInputMethodQuery (Qt::InputMethodQuery query) const
 

Private Attributes

Private *const m_d
 

Additional Inherited Members

- Public Types inherited from KisAbstractCanvasWidget
enum class  BitDepthMode { Depth8Bit = 0 , Depth10Bit }
 

Detailed Description

Definition at line 27 of file kis_canvas_widget_base.h.

Constructor & Destructor Documentation

◆ KisCanvasWidgetBase()

KisCanvasWidgetBase::KisCanvasWidgetBase ( KisCanvas2 * canvas,
KisCoordinatesConverter * coordinatesConverter )

Definition at line 56 of file kis_canvas_widget_base.cpp.

58{
59 m_d->blockMouseEvent.setSingleShot(true);
60}
KisCoordinatesConverter * coordinatesConverter() const
KisCanvas2 * canvas() const

References KisCanvasWidgetBase::Private::blockMouseEvent, and m_d.

◆ ~KisCanvasWidgetBase()

KisCanvasWidgetBase::~KisCanvasWidgetBase ( )
override

Clear all the attached decoration. Otherwise they might decide to process some events or signals after the canvas has been destroyed

Definition at line 62 of file kis_canvas_widget_base.cpp.

63{
69 //5qDeleteAll(m_d->decorations);
70 m_d->decorations.clear();
71
72 delete m_d;
73}
QList< KisCanvasDecorationSP > decorations

Member Function Documentation

◆ addDecoration()

void KisCanvasWidgetBase::addDecoration ( KisCanvasDecorationSP deco)
overridevirtual

Implements KisAbstractCanvasWidget.

Definition at line 122 of file kis_canvas_widget_base.cpp.

123{
124 m_d->decorations.push_back(deco);
125 std::stable_sort(m_d->decorations.begin(), m_d->decorations.end(), KisCanvasDecoration::comparePriority);
126}
static bool comparePriority(KisCanvasDecorationSP decoration1, KisCanvasDecorationSP decoration2)

References KisCanvasDecoration::comparePriority(), KisCanvasWidgetBase::Private::decorations, and m_d.

◆ borderColor()

QColor KisCanvasWidgetBase::borderColor ( ) const

Returns the color of the border, i.e. the part of the canvas outside the image contents.

Definition at line 200 of file kis_canvas_widget_base.cpp.

201{
202 return m_d->borderColor;
203}

References KisCanvasWidgetBase::Private::borderColor, and m_d.

◆ callFocusNextPrevChild()

virtual bool KisCanvasWidgetBase::callFocusNextPrevChild ( bool next)
protectedpure virtual

To be implemented by the derived canvas.

Implemented in KisQPainterCanvas, and KisOpenGLCanvas2.

◆ canvas()

KisCanvas2 * KisCanvasWidgetBase::canvas ( ) const
protected

Definition at line 205 of file kis_canvas_widget_base.cpp.

206{
207 return m_d->canvas;
208}

References KisCanvasWidgetBase::Private::canvas, and m_d.

◆ coordinatesConverter()

KisCoordinatesConverter * KisCanvasWidgetBase::coordinatesConverter ( ) const

Definition at line 210 of file kis_canvas_widget_base.cpp.

211{
213}
KisCoordinatesConverter * coordinatesConverter

References KisCanvasWidgetBase::Private::coordinatesConverter, and m_d.

◆ createCheckersImage()

QImage KisCanvasWidgetBase::createCheckersImage ( qint32 checkSize = -1)
static

Returns one check of the background checkerboard pattern.

Definition at line 174 of file kis_canvas_widget_base.cpp.

175{
176 KisConfig cfg(true);
177
178 if(checkSize < 0)
179 checkSize = cfg.checkSize();
180
181 QColor checkColor1 = cfg.checkersColor1();
182 QColor checkColor2 = cfg.checkersColor2();
183
184 QImage tile(checkSize * 2, checkSize * 2, QImage::Format_RGB32);
185 QPainter pt(&tile);
186 pt.fillRect(tile.rect(), checkColor2);
187 pt.fillRect(0, 0, checkSize, checkSize, checkColor1);
188 pt.fillRect(checkSize, checkSize, checkSize, checkSize, checkColor1);
189 pt.end();
190
191 return tile;
192}

References KisConfig::checkersColor1(), KisConfig::checkersColor2(), and KisConfig::checkSize().

◆ currentBitDepthMode()

KisAbstractCanvasWidget::BitDepthMode KisCanvasWidgetBase::currentBitDepthMode ( ) const
overridevirtual

◆ currentBitDepthUserReport()

QString KisCanvasWidgetBase::currentBitDepthUserReport ( ) const
overridevirtual

Implements KisAbstractCanvasWidget.

Reimplemented in KisOpenGLCanvas2.

Definition at line 256 of file kis_canvas_widget_base.cpp.

257{
258 return QString("Canvas bit depth management is not supported\n");
259}

◆ decoration()

KisCanvasDecorationSP KisCanvasWidgetBase::decoration ( const QString & id) const
overridevirtual

Implements KisAbstractCanvasWidget.

Definition at line 138 of file kis_canvas_widget_base.cpp.

139{
140 Q_FOREACH (KisCanvasDecorationSP deco, m_d->decorations) {
141 if (deco->id() == id) {
142 return deco;
143 }
144 }
145 return 0;
146}

References KisCanvasWidgetBase::Private::decorations, and m_d.

◆ decorations()

QList< KisCanvasDecorationSP > KisCanvasWidgetBase::decorations ( ) const
overridevirtual

Implements KisAbstractCanvasWidget.

Definition at line 154 of file kis_canvas_widget_base.cpp.

155{
156 return m_d->decorations;
157}

References KisCanvasWidgetBase::Private::decorations, and m_d.

◆ drawDecorations()

void KisCanvasWidgetBase::drawDecorations ( QPainter & gc,
const QRect & updateWidgetRect ) const
overridevirtual

Draw the specified decorations on the view.

Implements KisAbstractCanvasWidget.

Definition at line 75 of file kis_canvas_widget_base.cpp.

76{
77 if (!m_d->canvas) {
78 dbgFile<<"canvas doesn't exist, in canvas widget base!";
79 return;
80 }
81 gc.save();
82
83 // Setup the painter to take care of the offset; all that the
84 // classes that do painting need to keep track of is resolution
85 gc.setRenderHint(QPainter::Antialiasing);
86 gc.setRenderHint(QPainter::TextAntialiasing);
87
88 // This option does not do anything anymore with Qt4.6, so don't re-enable it since it seems to break display
89 // https://lists.qt-project.org/pipermail/qt-interest-old/2009-December/017078.html
90 // gc.setRenderHint(QPainter::Antialiasing);
91
92 gc.setRenderHint(QPainter::SmoothPixmapTransform);
93
94 {
95 KisQPainterStateSaver paintShapesState(&gc);
97
98 // Paint the shapes (other than the layers)
100
101 }
102
103 // ask the decorations to paint themselves
104 // decorations are painted in "widget" coordinate system
105 Q_FOREACH (KisCanvasDecorationSP deco, m_d->decorations) {
106 if (deco->visible()) {
107 deco->paint(gc, m_d->coordinatesConverter->widgetToDocument(updateWidgetRect), m_d->coordinatesConverter,m_d->canvas);
108 }
109 }
110
111 {
112 KisQPainterStateSaver paintDecorationsState(&gc);
114
115 // - some tools do not restore gc, but that is not important here
117 }
118
119 gc.restore();
120}
KoShapeManager * globalShapeManager() const
KoToolProxy * toolProxy() const override
_Private::Traits< T >::Result widgetToDocument(const T &obj) const
void paint(QPainter &painter)
void paint(QPainter &painter, const KoViewConverter &converter)
Forwarded to the current KoToolBase.
#define dbgFile
Definition kis_debug.h:53
const KoViewConverter * viewConverter

References KisCanvasWidgetBase::Private::canvas, KisCanvasWidgetBase::Private::coordinatesConverter, dbgFile, KisCanvasWidgetBase::Private::decorations, KisCoordinatesConverter::documentToWidgetTransform(), KisCoordinatesConverter::flakeToWidgetTransform(), KisCanvas2::globalShapeManager(), m_d, KoShapeManager::paint(), KoToolProxy::paint(), toolProxy(), KisCanvasWidgetBase::Private::viewConverter, and KisCoordinatesConverter::widgetToDocument().

◆ notifyConfigChanged()

void KisCanvasWidgetBase::notifyConfigChanged ( )
protected

Definition at line 194 of file kis_canvas_widget_base.cpp.

195{
196 KisConfig cfg(true);
197 m_d->borderColor = cfg.canvasBorderColor();
198}

References KisCanvasWidgetBase::Private::borderColor, KisConfig::canvasBorderColor(), and m_d.

◆ notifyDecorationsWindowMinimized()

void KisCanvasWidgetBase::notifyDecorationsWindowMinimized ( bool minimized)

Definition at line 158 of file kis_canvas_widget_base.cpp.

159{
160 Q_FOREACH (KisCanvasDecorationSP deco, m_d->decorations) {
161 deco->notifyWindowMinimized(minimized);
162 }
163}

References KisCanvasWidgetBase::Private::decorations, and m_d.

◆ processFocusInEvent()

void KisCanvasWidgetBase::processFocusInEvent ( QFocusEvent * event)
protected

Definition at line 241 of file kis_canvas_widget_base.cpp.

242{
243 m_d->toolProxy->focusInEvent(event);
244}
void focusInEvent(QFocusEvent *event)
Forwarded to the current KoToolBase.

References KoToolProxy::focusInEvent(), m_d, and KisCanvasWidgetBase::Private::toolProxy.

◆ processFocusOutEvent()

void KisCanvasWidgetBase::processFocusOutEvent ( QFocusEvent * event)
protected

Definition at line 246 of file kis_canvas_widget_base.cpp.

247{
248 m_d->toolProxy->focusOutEvent(event);
249}
void focusOutEvent(QFocusEvent *event)
Forwarded to the current KoToolBase.

References KoToolProxy::focusOutEvent(), m_d, and KisCanvasWidgetBase::Private::toolProxy.

◆ processInputMethodEvent()

void KisCanvasWidgetBase::processInputMethodEvent ( QInputMethodEvent * event)
protected

Definition at line 236 of file kis_canvas_widget_base.cpp.

237{
239}
void inputMethodEvent(QInputMethodEvent *event)
Forwarded to the current KoToolBase.

References KoToolProxy::inputMethodEvent(), m_d, and KisCanvasWidgetBase::Private::toolProxy.

◆ processInputMethodQuery()

QVariant KisCanvasWidgetBase::processInputMethodQuery ( Qt::InputMethodQuery query) const
protected

Event handlers to be called by derived canvas event handlers. All common event processing is carried out by these functions.

Definition at line 231 of file kis_canvas_widget_base.cpp.

232{
233 return m_d->toolProxy->inputMethodQuery(query);
234}
QVariant inputMethodQuery(Qt::InputMethodQuery query) const
Forwarded to the current KoToolBase.

References KoToolProxy::inputMethodQuery(), m_d, and KisCanvasWidgetBase::Private::toolProxy.

◆ removeDecoration()

void KisCanvasWidgetBase::removeDecoration ( const QString & id)
overridevirtual

Implements KisAbstractCanvasWidget.

Definition at line 128 of file kis_canvas_widget_base.cpp.

129{
130 for (auto it = m_d->decorations.begin(); it != m_d->decorations.end(); ++it) {
131 if ((*it)->id() == id) {
132 it = m_d->decorations.erase(it);
133 break;
134 }
135 }
136}

References KisCanvasWidgetBase::Private::decorations, and m_d.

◆ setDecorations()

void KisCanvasWidgetBase::setDecorations ( const QList< KisCanvasDecorationSP > & decorations)
overridevirtual

Implements KisAbstractCanvasWidget.

Definition at line 148 of file kis_canvas_widget_base.cpp.

149{
151 std::stable_sort(m_d->decorations.begin(), m_d->decorations.end(), KisCanvasDecoration::comparePriority);
152}
QList< KisCanvasDecorationSP > decorations() const override

References KisCanvasDecoration::comparePriority(), KisCanvasWidgetBase::Private::decorations, decorations(), and m_d.

◆ setWrapAroundViewingMode()

void KisCanvasWidgetBase::setWrapAroundViewingMode ( bool value)
overridevirtual

Implements KisAbstractCanvasWidget.

Reimplemented in KisQPainterCanvas, and KisOpenGLCanvas2.

Definition at line 164 of file kis_canvas_widget_base.cpp.

165{
166 Q_UNUSED(value);
167}
float value(const T *src, size_t ch)

References value().

◆ setWrapAroundViewingModeAxis()

void KisCanvasWidgetBase::setWrapAroundViewingModeAxis ( WrapAroundAxis value)
overridevirtual

Implements KisAbstractCanvasWidget.

Reimplemented in KisQPainterCanvas, and KisOpenGLCanvas2.

Definition at line 169 of file kis_canvas_widget_base.cpp.

170{
171 Q_UNUSED(value);
172}

References value().

◆ toolProxy()

KoToolProxy * KisCanvasWidgetBase::toolProxy ( ) const
overridevirtual

Implements KisAbstractCanvasWidget.

Definition at line 226 of file kis_canvas_widget_base.cpp.

227{
228 return m_d->toolProxy;
229}

References m_d, and KisCanvasWidgetBase::Private::toolProxy.

◆ updateCanvasProjection() [1/3]

QVector< QRect > KisCanvasWidgetBase::updateCanvasProjection ( const QVector< KisUpdateInfoSP > & infoObjects)
overridevirtual

Implements KisAbstractCanvasWidget.

Reimplemented in KisQPainterCanvas, KisOpenGLCanvas2, and KisQPainterCanvas.

Definition at line 215 of file kis_canvas_widget_base.cpp.

216{
217 QVector<QRect> dirtyViewRects;
218
219 Q_FOREACH (KisUpdateInfoSP info, infoObjects) {
220 dirtyViewRects << this->updateCanvasProjection(info);
221 }
222
223 return dirtyViewRects;
224}
QVector< QRect > updateCanvasProjection(const QVector< KisUpdateInfoSP > &infoObjects) override

References updateCanvasProjection().

◆ updateCanvasProjection() [2/3]

virtual QVector< QRect > KisAbstractCanvasWidget::updateCanvasProjection ( const QVector< KisUpdateInfoSP > & infoObjects)
virtual

◆ updateCanvasProjection() [3/3]

virtual QRect KisAbstractCanvasWidget::updateCanvasProjection ( KisUpdateInfoSP info)
virtual

Member Data Documentation

◆ m_d

Private* const KisCanvasWidgetBase::m_d
private

Definition at line 94 of file kis_canvas_widget_base.h.


The documentation for this class was generated from the following files: