mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Lock rotation handle UI/UX behind an enabled boolean
This commit is contained in:
parent
ae463d8b75
commit
1f6c1277dd
@ -44,6 +44,8 @@ QgsLayoutMouseHandles::QgsLayoutMouseHandles( QgsLayout *layout, QgsLayoutView *
|
||||
, mLayout( layout )
|
||||
, mView( view )
|
||||
{
|
||||
setRotationEnabled( true );
|
||||
|
||||
//listen for selection changes, and update handles accordingly
|
||||
connect( mLayout, &QGraphicsScene::selectionChanged, this, &QgsLayoutMouseHandles::selectionChanged );
|
||||
|
||||
|
@ -47,6 +47,17 @@ QgsGraphicsViewMouseHandles::QgsGraphicsViewMouseHandles( QGraphicsView *view )
|
||||
mRotationHandlePath.lineTo( 0, 14 );
|
||||
}
|
||||
|
||||
void QgsGraphicsViewMouseHandles::setRotationEnabled( bool enable )
|
||||
{
|
||||
if ( mRotationEnabled == enable )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mRotationEnabled = enable;
|
||||
update();
|
||||
}
|
||||
|
||||
void QgsGraphicsViewMouseHandles::paintInternal( QPainter *painter, bool showHandles, bool showStaticBoundingBoxes, bool showTemporaryBoundingBoxes, const QStyleOptionGraphicsItem *, QWidget * )
|
||||
{
|
||||
if ( !showHandles )
|
||||
@ -142,6 +153,8 @@ void QgsGraphicsViewMouseHandles::drawHandles( QPainter *painter, double rectHan
|
||||
//bottom right
|
||||
painter->drawRect( QRectF( rect().width() - rectHandlerSize, rect().height() - rectHandlerSize, rectHandlerSize, rectHandlerSize ) );
|
||||
|
||||
if ( isRotationEnabled() )
|
||||
{
|
||||
//draw rotate handles
|
||||
const double scale = rectHandlerSize / mHandleSize;
|
||||
const bool drawBottomRotationHandles = ( rectHandlerSize * 2 ) + ( mRotationHandleSize * scale * 2 ) < rect().height();
|
||||
@ -195,6 +208,7 @@ void QgsGraphicsViewMouseHandles::drawHandles( QPainter *painter, double rectHan
|
||||
painter->drawPath( mRotationHandlePath );
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsGraphicsViewMouseHandles::drawSelectedItemBounds( QPainter *painter )
|
||||
@ -434,7 +448,7 @@ Qgis::MouseHandlesAction QgsGraphicsViewMouseHandles::mouseActionForPosition( QP
|
||||
{
|
||||
nearLeftBorder = true;
|
||||
}
|
||||
else if ( itemCoordPos.x() >= borderTolerance && itemCoordPos.x() < ( borderTolerance + innerTolerance ) )
|
||||
else if ( isRotationEnabled() && itemCoordPos.x() >= borderTolerance && itemCoordPos.x() < ( borderTolerance + innerTolerance ) )
|
||||
{
|
||||
nearLeftInner = true;
|
||||
}
|
||||
@ -442,7 +456,7 @@ Qgis::MouseHandlesAction QgsGraphicsViewMouseHandles::mouseActionForPosition( QP
|
||||
{
|
||||
nearUpperBorder = true;
|
||||
}
|
||||
else if ( itemCoordPos.y() >= borderTolerance && itemCoordPos.y() < ( borderTolerance + innerTolerance ) )
|
||||
else if ( isRotationEnabled() && itemCoordPos.y() >= borderTolerance && itemCoordPos.y() < ( borderTolerance + innerTolerance ) )
|
||||
{
|
||||
nearUpperInner = true;
|
||||
}
|
||||
@ -450,7 +464,7 @@ Qgis::MouseHandlesAction QgsGraphicsViewMouseHandles::mouseActionForPosition( QP
|
||||
{
|
||||
nearRightBorder = true;
|
||||
}
|
||||
else if ( itemCoordPos.x() <= ( rect().width() - borderTolerance ) && itemCoordPos.x() > ( rect().width() - borderTolerance - innerTolerance ) )
|
||||
else if ( isRotationEnabled() && itemCoordPos.x() <= ( rect().width() - borderTolerance ) && itemCoordPos.x() > ( rect().width() - borderTolerance - innerTolerance ) )
|
||||
{
|
||||
nearRightInner = true;
|
||||
}
|
||||
@ -458,7 +472,7 @@ Qgis::MouseHandlesAction QgsGraphicsViewMouseHandles::mouseActionForPosition( QP
|
||||
{
|
||||
nearLowerBorder = true;
|
||||
}
|
||||
else if ( itemCoordPos.y() <= ( rect().height() - borderTolerance ) && itemCoordPos.y() > ( rect().height() - borderTolerance - innerTolerance ) )
|
||||
else if ( isRotationEnabled() && itemCoordPos.y() <= ( rect().height() - borderTolerance ) && itemCoordPos.y() > ( rect().height() - borderTolerance - innerTolerance ) )
|
||||
{
|
||||
nearLowerInner = true;
|
||||
}
|
||||
|
@ -85,6 +85,12 @@ class GUI_EXPORT QgsGraphicsViewMouseHandles : public QObject, public QGraphicsR
|
||||
//! Initializes a drag operation \since QGIS 3.34
|
||||
void startMove( QPointF sceneCoordPos );
|
||||
|
||||
//! Returns TRUE if rotation functionality is enabled
|
||||
bool isRotationEnabled() const { return mRotationEnabled; }
|
||||
|
||||
//! Sets whether rotation functionality is enabled
|
||||
void setRotationEnabled( bool enable );
|
||||
|
||||
public slots:
|
||||
|
||||
//! Redraws handles when selected item size changes
|
||||
@ -214,10 +220,14 @@ class GUI_EXPORT QgsGraphicsViewMouseHandles : public QObject, public QGraphicsR
|
||||
|
||||
QRectF mResizeRect;
|
||||
|
||||
bool mRotationEnabled = false;
|
||||
//! Center point around which rotation occurs
|
||||
QPointF mRotationCenter;
|
||||
//! The starting rotation angle from center point
|
||||
double mRotationBegin = 0.0;
|
||||
//! The current rotation angle from center point
|
||||
double mRotationCurrent = 0.0;
|
||||
//! The rotation angle delta to be applied (can be snapped to common angle)
|
||||
double mRotationDelta = 0.0;
|
||||
|
||||
//! Start point of the last mouse move action (in scene coordinates)
|
||||
|
Loading…
x
Reference in New Issue
Block a user