Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Show ruler marker for cursor position
  • Loading branch information
mhugent committed Feb 14, 2013
1 parent 38c5214 commit 5f8e9e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gui/qgscomposerruler.cpp
Expand Up @@ -48,8 +48,8 @@ void QgsComposerRuler::paintEvent( QPaintEvent* event )
markerPos += 10.0;
}

qWarning( QString::number( startX ).toLocal8Bit().data() );
qWarning( QString::number( endX ).toLocal8Bit().data() );
p.setPen( QColor( Qt::red ) );
p.drawLine( mMarkerPos.x(), 0, mMarkerPos.x(), RULER_MIN_SIZE );
}
else //vertical
{
Expand All @@ -72,6 +72,9 @@ void QgsComposerRuler::paintEvent( QPaintEvent* event )
}
markerPos += 10.0;
}

p.setPen( QColor( Qt::red ) );
p.drawLine( 0, mMarkerPos.y(), RULER_MIN_SIZE, mMarkerPos.y() );
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgscomposerruler.h
Expand Up @@ -19,13 +19,15 @@ class QgsComposerRuler: public QWidget
QSize minimumSizeHint() const;

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

protected:
void paintEvent( QPaintEvent* event );

private:
Direction mDirection;
QTransform mTransform;
QPointF mMarkerPos;
};

#endif // QGSCOMPOSERRULER_H
9 changes: 9 additions & 0 deletions src/gui/qgscomposerview.cpp
Expand Up @@ -368,6 +368,15 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e )
return;
}

if ( mHorizontalRuler )
{
mHorizontalRuler->updateMarker( e->posF() );
}
if ( mVerticalRuler )
{
mVerticalRuler->updateMarker( e->posF() );
}

if ( e->buttons() == Qt::NoButton )
{
if ( mCurrentTool == Select )
Expand Down

0 comments on commit 5f8e9e1

Please sign in to comment.