17 #ifndef QGSLAYOUTMOUSEHANDLES_H 18 #define QGSLAYOUTMOUSEHANDLES_H 22 #include <QGraphicsRectItem> 47 class GUI_EXPORT QgsLayoutMouseHandles:
public QObject,
public QGraphicsRectItem
93 void setLayout(
QgsLayout *layout ) { mLayout = layout; }
101 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget =
nullptr )
override;
104 QgsLayoutMouseHandles::MouseAction mouseActionForScenePos( QPointF sceneCoordPos );
107 bool isDragging()
const {
return mIsDragging; }
110 bool isResizing()
const {
return mIsResizing; }
112 bool shouldBlockEvent( QInputEvent *event )
const;
116 void mouseMoveEvent( QGraphicsSceneMouseEvent *event )
override;
117 void mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
override;
118 void mousePressEvent( QGraphicsSceneMouseEvent *event )
override;
119 void mouseDoubleClickEvent( QGraphicsSceneMouseEvent *event )
override;
120 void hoverMoveEvent( QGraphicsSceneHoverEvent *event )
override;
121 void hoverLeaveEvent( QGraphicsSceneHoverEvent *event )
override;
126 void selectionChanged();
129 void selectedItemSizeChanged();
132 void selectedItemRotationChanged();
137 QPointer< QgsLayoutView > mView;
139 MouseAction mCurrentMouseMoveAction = NoAction;
141 QPointF mMouseMoveStartPos;
143 QPointF mLastMouseEventPos;
145 QPointF mBeginMouseEventPos;
147 QPointF mBeginHandlePos;
149 double mBeginHandleWidth = 0;
150 double mBeginHandleHeight = 0;
153 double mResizeMoveX = 0;
154 double mResizeMoveY = 0;
157 bool mIsDragging =
false;
159 bool mIsResizing =
false;
162 QGraphicsLineItem *mHorizontalSnapLine =
nullptr;
163 QGraphicsLineItem *mVerticalSnapLine =
nullptr;
165 QSizeF mCursorOffset;
168 QRectF selectionBounds()
const;
171 bool selectionRotation(
double &rotation )
const;
174 void updateHandles();
176 void drawHandles( QPainter *painter,
double rectHandlerSize );
178 void drawSelectedItemBounds( QPainter *painter );
183 double rectHandlerBorderTolerance();
186 Qt::CursorShape cursorForPosition( QPointF itemCoordPos );
189 MouseAction mouseActionForPosition( QPointF itemCoordPos );
192 void dragMouseMove( QPointF currentPosition,
bool lockMovement,
bool preventSnap );
195 QSizeF calcCursorEdgeOffset( QPointF cursorPos );
198 void resizeMouseMove( QPointF currentPosition,
bool lockAspect,
bool fromCenter );
201 void setViewportCursor( Qt::CursorShape cursor );
204 void resetStatusBar();
207 QPointF snapPoint( QPointF originalPoint, SnapGuideMode mode,
bool snapHorizontal =
true,
bool snapVertical =
true );
209 void hideAlignItems();
212 void collectItems( QList< QgsLayoutItem * > items, QList< QgsLayoutItem * > &collected );
218 #endif // QGSLAYOUTMOUSEHANDLES_H Base class for graphical items within a QgsLayout.
A graphical widget to display and interact with QgsLayouts.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.