Krita Source Code Documentation
Loading...
Searching...
No Matches
DefaultTool::MoveGradientHandleInteractionFactory Class Reference
+ Inheritance diagram for DefaultTool::MoveGradientHandleInteractionFactory:

Public Member Functions

KoInteractionStrategycreateStrategy (KoPointerEvent *ev) override
 
bool hoverEvent (KoPointerEvent *ev) override
 
 MoveGradientHandleInteractionFactory (KoFlake::FillVariant fillVariant, int priority, const QString &id, DefaultTool *_q)
 
bool paintOnHover (QPainter &painter, const KoViewConverter &converter) override
 
bool tryUseCustomCursor () override
 
- Public Member Functions inherited from KoInteractionStrategyFactory
QString id () const
 
 KoInteractionStrategyFactory (int priority, const QString &id)
 
int priority () const
 
virtual ~KoInteractionStrategyFactory ()
 

Private Member Functions

KoShapeGradientHandles::Handle handleAt (const QPointF &pos)
 
KoShapeonlyEditableShape () const
 

Private Attributes

KoShapeGradientHandles::Handle m_currentHandle
 
KoFlake::FillVariant m_fillVariant
 
DefaultToolq
 

Additional Inherited Members

- Static Public Member Functions inherited from KoInteractionStrategyFactory
static bool compareLess (KoInteractionStrategyFactorySP f1, KoInteractionStrategyFactorySP f2)
 

Detailed Description

Definition at line 174 of file DefaultTool.cpp.

Constructor & Destructor Documentation

◆ MoveGradientHandleInteractionFactory()

DefaultTool::MoveGradientHandleInteractionFactory::MoveGradientHandleInteractionFactory ( KoFlake::FillVariant fillVariant,
int priority,
const QString & id,
DefaultTool * _q )
inline

Definition at line 177 of file DefaultTool.cpp.

Member Function Documentation

◆ createStrategy()

KoInteractionStrategy * DefaultTool::MoveGradientHandleInteractionFactory::createStrategy ( KoPointerEvent * ev)
inlineoverridevirtual

Implements KoInteractionStrategyFactory.

Definition at line 185 of file DefaultTool.cpp.

186 {
188
190 KoShape *shape = onlyEditableShape();
192
194 }
195
196 return 0;
197 }
KoShapeGradientHandles::Handle m_currentHandle
KoShapeGradientHandles::Handle handleAt(const QPointF &pos)
QPointF point
The point in document coordinates.
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References handleAt(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, m_currentHandle, m_fillVariant, KoShapeGradientHandles::Handle::None, onlyEditableShape(), KoPointerEvent::point, q, and KoShapeGradientHandles::Handle::type.

◆ handleAt()

KoShapeGradientHandles::Handle DefaultTool::MoveGradientHandleInteractionFactory::handleAt ( const QPointF & pos)
inlineprivate

Definition at line 235 of file DefaultTool.cpp.

235 {
237
238 KoShape *shape = onlyEditableShape();
239 if (shape) {
240 KoFlake::SelectionHandle globalHandle = q->handleAt(pos);
241 const qreal distanceThresholdSq =
242 globalHandle == KoFlake::NoHandle ?
244
245 const KoViewConverter *converter = q->canvas()->viewConverter();
246 const QPointF viewPoint = converter->documentToView(pos);
247 qreal minDistanceSq = std::numeric_limits<qreal>::max();
248
250 auto handless = sh.handles();
251 Q_FOREACH (const KoShapeGradientHandles::Handle &handle, sh.handles()) {
252 const QPointF handlePoint = converter->documentToView(handle.pos);
253 const qreal distanceSq = kisSquareDistance(viewPoint, handlePoint);
254
255 if (distanceSq < distanceThresholdSq && distanceSq < minDistanceSq) {
256 result = handle;
257 minDistanceSq = distanceSq;
258 }
259 }
260 }
261
262 return result;
263 }
#define HANDLE_DISTANCE_SQ
KoFlake::SelectionHandle handleAt(const QPointF &point, bool *innerHandleMeaning=0)
virtual const KoViewConverter * viewConverter() const =0
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
virtual QPointF documentToView(const QPointF &documentPoint) const
qreal kisSquareDistance(const QPointF &pt1, const QPointF &pt2)
Definition kis_global.h:194
SelectionHandle
Enum determining which handle is meant, used in KoInteractionTool.
Definition KoFlake.h:55
@ NoHandle
Value to indicate no handle.
Definition KoFlake.h:64

References KoToolBase::canvas(), KoViewConverter::documentToView(), HANDLE_DISTANCE_SQ, DefaultTool::handleAt(), KoShapeGradientHandles::handles(), kisSquareDistance(), m_fillVariant, KoFlake::NoHandle, onlyEditableShape(), KoShapeGradientHandles::Handle::pos, q, and KoCanvasBase::viewConverter().

◆ hoverEvent()

bool DefaultTool::MoveGradientHandleInteractionFactory::hoverEvent ( KoPointerEvent * ev)
inlineoverridevirtual

Implements KoInteractionStrategyFactory.

Definition at line 199 of file DefaultTool.cpp.

200 {
202 return false;
203 }

References handleAt(), m_currentHandle, and KoPointerEvent::point.

◆ onlyEditableShape()

KoShape * DefaultTool::MoveGradientHandleInteractionFactory::onlyEditableShape ( ) const
inlineprivate

Definition at line 223 of file DefaultTool.cpp.

223 {
225 QList<KoShape*> shapes = selection->selectedEditableShapes();
226
227 KoShape *shape = 0;
228 if (shapes.size() == 1) {
229 shape = shapes.first();
230 }
231
232 return shape;
233 }
virtual KoSelection * koSelection() const
KoToolSelection * selection() override
reimplemented

References DefaultTool::koSelection(), q, and DefaultTool::selection().

◆ paintOnHover()

bool DefaultTool::MoveGradientHandleInteractionFactory::paintOnHover ( QPainter & painter,
const KoViewConverter & converter )
inlineoverridevirtual

Implements KoInteractionStrategyFactory.

Definition at line 205 of file DefaultTool.cpp.

206 {
207 Q_UNUSED(painter);
208 Q_UNUSED(converter);
209 return false;
210 }

◆ tryUseCustomCursor()

bool DefaultTool::MoveGradientHandleInteractionFactory::tryUseCustomCursor ( )
inlineoverridevirtual

Implements KoInteractionStrategyFactory.

Definition at line 212 of file DefaultTool.cpp.

212 {
214 q->useCursor(Qt::OpenHandCursor);
215 return true;
216 }
217
218 return false;
219 }
void useCursor(const QCursor &cursor)

References m_currentHandle, KoShapeGradientHandles::Handle::None, q, KoShapeGradientHandles::Handle::type, and KoToolBase::useCursor().

Member Data Documentation

◆ m_currentHandle

KoShapeGradientHandles::Handle DefaultTool::MoveGradientHandleInteractionFactory::m_currentHandle
private

Definition at line 268 of file DefaultTool.cpp.

◆ m_fillVariant

KoFlake::FillVariant DefaultTool::MoveGradientHandleInteractionFactory::m_fillVariant
private

Definition at line 267 of file DefaultTool.cpp.

◆ q

DefaultTool* DefaultTool::MoveGradientHandleInteractionFactory::q
private

Definition at line 266 of file DefaultTool.cpp.


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