From: Joel Holdsworth Date: Thu, 18 Apr 2013 22:06:15 +0000 (+0100) Subject: Moved ruler cursor draw functions into CursorsPair X-Git-Tag: pulseview-0.1.0~36 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=332afa7438aa5532599fe65f9092e1b24b34fe04;p=pulseview.git Moved ruler cursor draw functions into CursorsPair --- 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. */