X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=pv%2Fviews%2Ftrace%2Fview.cpp;h=7f77635d235791192bb05ed5db79f680dfc5ae6d;hb=66279897e318a2549557054d1204c862f7d99469;hp=05e6da3e67000a75720595aba455697ac7d265d7;hpb=fe68068b2f8f3ae69b762636e91de91e8996aa11;p=pulseview.git diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index 05e6da3e..7f77635d 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -790,22 +790,36 @@ bool View::cursors_shown() const void View::show_cursors(bool show) { - show_cursors_ = show; - cursor_state_changed(show); + if (show_cursors_ != show) { + show_cursors_ = show; + + cursor_state_changed(show); + ruler_->update(); + viewport_->update(); + } +} + +void View::set_cursors(pv::util::Timestamp& first, pv::util::Timestamp& second) +{ + assert(cursors_); + + cursors_->first()->set_time(first); + cursors_->second()->set_time(second); + ruler_->update(); viewport_->update(); } void View::centre_cursors() { - if (cursors_) { - const double time_width = scale_ * viewport_->width(); - cursors_->first()->set_time(offset_ + time_width * 0.4); - cursors_->second()->set_time(offset_ + time_width * 0.6); + assert(cursors_); - ruler_->update(); - viewport_->update(); - } + const double time_width = scale_ * viewport_->width(); + cursors_->first()->set_time(offset_ + time_width * 0.4); + cursors_->second()->set_time(offset_ + time_width * 0.6); + + ruler_->update(); + viewport_->update(); } shared_ptr View::cursors() const