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

Public Member Functions

KoInteractionStrategycreateStrategy (KoPointerEvent *ev) override
 
bool hoverEvent (KoPointerEvent *ev) override
 
 MoveMeshGradientHandleInteractionFactory (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

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

Private Attributes

KoShapeMeshGradientHandles::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 274 of file DefaultTool.cpp.

Constructor & Destructor Documentation

◆ MoveMeshGradientHandleInteractionFactory()

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

Definition at line 277 of file DefaultTool.cpp.

Member Function Documentation

◆ createStrategy()

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

Implements KoInteractionStrategyFactory.

Definition at line 287 of file DefaultTool.cpp.

288 {
292
293
295 KoShape *shape = onlyEditableShape();
297
299 }
300
301 return nullptr;
302 }
KoShapeMeshGradientHandles::Handle handleAt(const QPointF &pos) const
KoShapeMeshGradientHandles::Handle m_currentHandle
KoShapeMeshGradientHandles::Handle m_selectedMeshHandle
void meshgradientHandleSelected(KoShapeMeshGradientHandles::Handle)
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, DefaultTool::m_selectedMeshHandle, DefaultTool::meshgradientHandleSelected(), KoShapeMeshGradientHandles::Handle::None, onlyEditableShape(), KoPointerEvent::point, q, and KoShapeMeshGradientHandles::Handle::type.

◆ handleAt()

KoShapeMeshGradientHandles::Handle DefaultTool::MoveMeshGradientHandleInteractionFactory::handleAt ( const QPointF & pos) const
inlineprivate

Definition at line 356 of file DefaultTool.cpp.

357 {
358 // FIXME: copy of KoShapeGradientHandles. use a template?
360
361 KoShape *shape = onlyEditableShape();
362 if (shape) {
363 KoFlake::SelectionHandle globalHandle = q->handleAt(pos);
364 const qreal distanceThresholdSq =
365 globalHandle == KoFlake::NoHandle ?
367
368 const KoViewConverter *converter = q->canvas()->viewConverter();
369 const QPointF viewPoint = converter->documentToView(pos);
370 qreal minDistanceSq = std::numeric_limits<qreal>::max();
371
373
374 for (const auto& handle: sh.handles()) {
375 const QPointF handlePoint = converter->documentToView(handle.pos);
376 const qreal distanceSq = kisSquareDistance(viewPoint, handlePoint);
377
378 if (distanceSq < distanceThresholdSq && distanceSq < minDistanceSq) {
379 result = handle;
380 minDistanceSq = distanceSq;
381 }
382 }
383 }
384
385 return result;
386 }
#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(), KoShapeMeshGradientHandles::handles(), kisSquareDistance(), m_fillVariant, KoFlake::NoHandle, onlyEditableShape(), q, and KoCanvasBase::viewConverter().

◆ hoverEvent()

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

Implements KoInteractionStrategyFactory.

Definition at line 304 of file DefaultTool.cpp.

305 {
306 // for custom cursor
308
309 // refresh
312 }
313
314 m_currentHandle = handle;
316
317 // highlight the decoration which is being hovered
320 }
321 return false;
322 }
KoShapeMeshGradientHandles::Handle m_hoveredMeshHandle
virtual void repaintDecorations()

References handleAt(), m_currentHandle, DefaultTool::m_hoveredMeshHandle, KoShapeMeshGradientHandles::Handle::None, KoPointerEvent::point, q, KoToolBase::repaintDecorations(), and KoShapeMeshGradientHandles::Handle::type.

◆ onlyEditableShape()

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

Definition at line 343 of file DefaultTool.cpp.

343 {
344 // FIXME: copy of KoShapeGradientHandles
346 QList<KoShape*> shapes = selection->selectedEditableShapes();
347
348 KoShape *shape = 0;
349 if (shapes.size() == 1) {
350 shape = shapes.first();
351 }
352
353 return shape;
354 }
virtual KoSelection * koSelection() const
KoToolSelection * selection() override
reimplemented

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

◆ paintOnHover()

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

Implements KoInteractionStrategyFactory.

Definition at line 324 of file DefaultTool.cpp.

325 {
326 Q_UNUSED(painter);
327 Q_UNUSED(converter);
328 return false;
329 }

◆ tryUseCustomCursor()

bool DefaultTool::MoveMeshGradientHandleInteractionFactory::tryUseCustomCursor ( )
inlineoverridevirtual

Implements KoInteractionStrategyFactory.

Definition at line 331 of file DefaultTool.cpp.

332 {
334 q->useCursor(Qt::OpenHandCursor);
335 return true;
336 }
337
338 return false;
339 }
void useCursor(const QCursor &cursor)

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

Member Data Documentation

◆ m_currentHandle

KoShapeMeshGradientHandles::Handle DefaultTool::MoveMeshGradientHandleInteractionFactory::m_currentHandle
private

Definition at line 390 of file DefaultTool.cpp.

◆ m_fillVariant

KoFlake::FillVariant DefaultTool::MoveMeshGradientHandleInteractionFactory::m_fillVariant
private

Definition at line 389 of file DefaultTool.cpp.

◆ q

DefaultTool* DefaultTool::MoveMeshGradientHandleInteractionFactory::q
private

Definition at line 391 of file DefaultTool.cpp.


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