From 332afa7438aa5532599fe65f9092e1b24b34fe04 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Thu, 18 Apr 2013 23:06:15 +0100 Subject: [PATCH] Moved ruler cursor draw functions into CursorsPair --- pv/view/cursorpair.cpp | 7 +++++++ pv/view/cursorpair.h | 3 +++ pv/view/ruler.cpp | 14 ++------------ pv/view/ruler.h | 2 -- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index a677c503..c148b851 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -56,6 +56,13 @@ Cursor& CursorPair::second() return _second; } +void CursorPair::draw_markers(QPainter &p, + const QRect &rect, unsigned int prefix) +{ + _first.paint_label(p, rect, prefix); + _second.paint_label(p, rect, prefix); +} + void CursorPair::draw_viewport_background(QPainter &p, const QRect &rect) { diff --git a/pv/view/cursorpair.h b/pv/view/cursorpair.h index 2bf85d83..05035cc2 100644 --- a/pv/view/cursorpair.h +++ b/pv/view/cursorpair.h @@ -60,6 +60,9 @@ public: const Cursor& second() const; public: + void draw_markers(QPainter &p, + const QRect &rect, unsigned int prefix); + void draw_viewport_background(QPainter &p, const QRect &rect); void draw_viewport_foreground(QPainter &p, const QRect &rect); diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index 0322af8a..d323f9be 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -163,7 +163,8 @@ void Ruler::paintEvent(QPaintEvent*) } while (x < width()); // Draw the cursors - draw_cursors(p, prefix); + if (_view.cursors_shown()) + _view.cursors().draw_markers(p, rect(), prefix); // Draw the hover mark draw_hover_mark(p); @@ -202,17 +203,6 @@ void Ruler::mouseReleaseEvent(QMouseEvent *) _grabbed_marker = NULL; } -void Ruler::draw_cursors(QPainter &p, unsigned int prefix) -{ - if (!_view.cursors_shown()) - return; - - const QRect r = rect(); - CursorPair &cursors = _view.cursors(); - cursors.first().paint_label(p, r, prefix); - cursors.second().paint_label(p, r, prefix); -} - void Ruler::draw_hover_mark(QPainter &p) { const int x = _view.hover_point().x(); diff --git a/pv/view/ruler.h b/pv/view/ruler.h index f40f8255..689b073c 100644 --- a/pv/view/ruler.h +++ b/pv/view/ruler.h @@ -56,8 +56,6 @@ private: void mouseReleaseEvent(QMouseEvent *); private: - void draw_cursors(QPainter &p, unsigned int prefix); - /** * Draw a hover arrow under the cursor position. */ -- 2.30.2