X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Fviewport.cpp;h=7f2cedea0ccde0a1975c5a202e82a46fd62400b2;hb=f1283456ae0859990ccd914f8c147064345df13f;hp=5882600524d1b77bdfaf0d02ce38ad2e040a96e3;hpb=2658961bdef3601e07d494a8ed3d01a8101b68cd;p=pulseview.git diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index 58826005..7f2cedea 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -67,7 +67,8 @@ void Viewport::paintEvent(QPaintEvent*) QPainter p(this); p.setRenderHint(QPainter::Antialiasing); - draw_cursors_background(p); + if (_view.cursors_shown()) + _view.cursors().draw_viewport_background(p, rect()); // Plot the signal const int v_offset = _view.v_offset(); @@ -78,7 +79,8 @@ void Viewport::paintEvent(QPaintEvent*) _view.scale(), _view.offset()); } - draw_cursors_foreground(p); + if (_view.cursors_shown()) + _view.cursors().draw_viewport_foreground(p, rect()); p.end(); } @@ -104,11 +106,6 @@ void Viewport::mouseMoveEvent(QMouseEvent *event) } } -void Viewport::mouseReleaseEvent(QMouseEvent *event) -{ - assert(event); -} - void Viewport::wheelEvent(QWheelEvent *event) { assert(event); @@ -124,34 +121,6 @@ void Viewport::wheelEvent(QWheelEvent *event) } } -void Viewport::draw_cursors_background(QPainter &p) -{ - if (!_view.cursors_shown()) - return; - - p.setPen(Qt::NoPen); - p.setBrush(QBrush(View::CursorAreaColour)); - - const pair &c = _view.cursors(); - const float x1 = (c.first.time() - _view.offset()) / _view.scale(); - const float x2 = (c.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)width()); - - p.drawRect(l, 0, r - l, height()); -} - -void Viewport::draw_cursors_foreground(QPainter &p) -{ - if (!_view.cursors_shown()) - return; - - const QRect r = rect(); - pair &cursors = _view.cursors(); - cursors.first.paint(p, r); - cursors.second.paint(p, r); -} - void Viewport::on_signals_moved() { update();