Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
/* This file is part of the KDE project
* SPDX-FileCopyrightText: 2006, 2008 Jan Hambrecht <[email protected]>
* SPDX-FileCopyrightText: 2006, 2007 Thorsten Zachmann <[email protected]>
* SPDX-FileCopyrightText: 2007, 2010 Thomas Zander <[email protected]>
* SPDX-FileCopyrightText: 2007 Boudewijn Rempt <[email protected]>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KOPATHTOOLHANDLE_H
#define KOPATHTOOLHANDLE_H
#include <KoPathPoint.h>
#include "KoInteractionStrategy.h"
#include <QList>
#include <QRectF>
class KoPathTool;
class KoParameterShape;
class KoViewConverter;
class KoPointerEvent;
class QPainter;
class KoPathShape;
class KisHandlePainterHelper;
class KoColorDisplayRendererInterface;
class KoPathToolHandle
{
public:
explicit KoPathToolHandle(KoPathTool *tool);
virtual ~KoPathToolHandle();
virtual void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness, KoColorDisplayRendererInterface *renderInterface) = 0;
virtual QRectF boundingRect() const = 0;
virtual KoInteractionStrategy * handleMousePress(KoPointerEvent *event) = 0;
// test if handle is still valid
virtual bool check(const QList<KoPathShape*> &selectedShapes) = 0;
virtual void trySelectHandle() {};
protected:
KoPathTool *m_tool;
};
class PointHandle : public KoPathToolHandle
{
public:
PointHandle(KoPathTool *tool, KoPathPoint *activePoint, KoPathPoint::PointType activePointType);
void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness, KoColorDisplayRendererInterface *renderInterface) override;
QRectF boundingRect() const override;
KoInteractionStrategy *handleMousePress(KoPointerEvent *event) override;
bool check(const QList<KoPathShape*> &selectedShapes) override;
KoPathPoint *activePoint() const;
KoPathPoint::PointType activePointType() const;
void trySelectHandle() override;
private:
KoPathPoint *m_activePoint;
KoPathPoint::PointType m_activePointType;
mutable QRectF m_oldRepaintedRect;
};
class ParameterHandle : public KoPathToolHandle
{
public:
ParameterHandle(KoPathTool *tool, KoParameterShape *parameterShape, int handleId);
void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness, KoColorDisplayRendererInterface *renderInterface) override;
QRectF boundingRect() const override;
KoInteractionStrategy *handleMousePress(KoPointerEvent *event) override;
bool check(const QList<KoPathShape*> &selectedShapes) override;
protected:
KoParameterShape *m_parameterShape;
int m_handleId;
};
#endif // KOPATHTOOLHANDLE_H