Skip to content

Commit 5f8e9e1

Browse files
committed
Show ruler marker for cursor position
1 parent 38c5214 commit 5f8e9e1

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/gui/qgscomposerruler.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ void QgsComposerRuler::paintEvent( QPaintEvent* event )
4848
markerPos += 10.0;
4949
}
5050

51-
qWarning( QString::number( startX ).toLocal8Bit().data() );
52-
qWarning( QString::number( endX ).toLocal8Bit().data() );
51+
p.setPen( QColor( Qt::red ) );
52+
p.drawLine( mMarkerPos.x(), 0, mMarkerPos.x(), RULER_MIN_SIZE );
5353
}
5454
else //vertical
5555
{
@@ -72,6 +72,9 @@ void QgsComposerRuler::paintEvent( QPaintEvent* event )
7272
}
7373
markerPos += 10.0;
7474
}
75+
76+
p.setPen( QColor( Qt::red ) );
77+
p.drawLine( 0, mMarkerPos.y(), RULER_MIN_SIZE, mMarkerPos.y() );
7578
}
7679
}
7780

src/gui/qgscomposerruler.h

+2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ class QgsComposerRuler: public QWidget
1919
QSize minimumSizeHint() const;
2020

2121
void setSceneTransform( const QTransform& transform );
22+
void updateMarker( const QPointF& pos ) { mMarkerPos = pos; repaint(); }
2223

2324
protected:
2425
void paintEvent( QPaintEvent* event );
2526

2627
private:
2728
Direction mDirection;
2829
QTransform mTransform;
30+
QPointF mMarkerPos;
2931
};
3032

3133
#endif // QGSCOMPOSERRULER_H

src/gui/qgscomposerview.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,15 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e )
368368
return;
369369
}
370370

371+
if ( mHorizontalRuler )
372+
{
373+
mHorizontalRuler->updateMarker( e->posF() );
374+
}
375+
if ( mVerticalRuler )
376+
{
377+
mVerticalRuler->updateMarker( e->posF() );
378+
}
379+
371380
if ( e->buttons() == Qt::NoButton )
372381
{
373382
if ( mCurrentTool == Select )

0 commit comments

Comments
 (0)