From: Soeren Apel Date: Fri, 13 Jan 2017 17:36:00 +0000 (+0100) Subject: TraceView: Center traces more than once X-Git-Tag: pulseview-0.4.0~207 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=66e4eae9ce743016c3f6d4974bceb9b7fc0ae7d7;p=pulseview.git TraceView: Center traces more than once This is to make sure the traces are centered when the view is first drawn but also properly centered when the final size is known. This fixes a "jumping" display when opening a new trace view in addition to an existing one. --- diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 08dc8828..546176b4 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -827,15 +827,6 @@ void View::set_scroll_default() const QSize areaSize = viewport_->size(); - // Special case: when starting up and the window isn't visible yet, - // areaSize is [0, 0]. In this case we want to be called again later - if ((areaSize.height() == 0) || (!size_finalized_)) { - scroll_needs_defaults_ = true; - return; - } else { - scroll_needs_defaults_ = false; - } - const pair extents = v_extents(); const int trace_height = extents.second - extents.first; @@ -847,6 +838,11 @@ void View::set_scroll_default() else // Put the first trace at the top, letting the bottom ones overflow set_v_offset(extents.first); + + // If we're not sure whether setting the defaults worked as + // the window wasn't set up entirely yet, we want to be called + // again later to make sure + scroll_needs_defaults_ = !size_finalized_; } void View::update_layout()