X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Fcursorpair.cpp;h=5ce398a0ff3f764e9b0e6d6914bf9f258254bce0;hb=199441e4fe68f1ee45f3d4b7617a7166a87c7926;hp=feac91d20d47a513c60f0a294c97b4f4fbda65cb;hpb=96d3ad83edb89b2d4e0e4a4f0860c13ebbcf737a;p=pulseview.git diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index feac91d2..5ce398a0 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -69,10 +69,11 @@ void CursorPair::draw_viewport_background(QPainter &p, p.setPen(Qt::NoPen); p.setBrush(QBrush(View::CursorAreaColour)); - const float x1 = (_first.time() - _view.offset()) / _view.scale(); - const float x2 = (_second.time() - _view.offset()) / _view.scale(); - const int l = (int)max(min(x1, x2), 0.0f); - const int r = (int)min(max(x1, x2), (float)rect.width()); + const pair offsets(get_cursor_offsets()); + const int l = (int)max(min( + offsets.first, offsets.second), 0.0f); + const int r = (int)min(max( + offsets.first, offsets.second), (float)rect.width()); p.drawRect(l, 0, r - l, rect.height()); } @@ -84,5 +85,12 @@ void CursorPair::draw_viewport_foreground(QPainter &p, _second.paint(p, rect); } +pair CursorPair::get_cursor_offsets() const +{ + return pair( + (_first.time() - _view.offset()) / _view.scale(), + (_second.time() - _view.offset()) / _view.scale()); +} + } // namespace view } // namespace pv