From 6381b375ae391a79ab50f1f5dcbe0014ff9bd46c Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Tue, 11 Feb 2020 19:06:11 +0100 Subject: [PATCH] TraceView: Implement view scroll margins --- pv/views/trace/view.cpp | 14 ++++++++++---- pv/views/trace/view.hpp | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index 6159cdd9..e5cf980a 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -94,8 +94,10 @@ const Timestamp View::MinScale("1e-12"); const int View::MaxScrollValue = INT_MAX / 2; -const int View::ScaleUnits[3] = {1, 2, 5}; +/* Area at the top and bottom of the view that can't be scrolled out of sight */ +const int View::ViewScrollMargin = 50; +const int View::ScaleUnits[3] = {1, 2, 5}; CustomScrollArea::CustomScrollArea(QWidget *parent) : QAbstractScrollArea(parent) @@ -1245,9 +1247,13 @@ void View::update_scroll() const pair extents = v_extents(); // Don't change the scrollbar range if there are no traces - if (extents.first != extents.second) - vscrollbar->setRange(extents.first - areaSize.height(), - extents.second); + if (extents.first != extents.second) { + int top_margin = ViewScrollMargin; + int btm_margin = ViewScrollMargin; + + vscrollbar->setRange(extents.first - areaSize.height() + top_margin, + extents.second - btm_margin); + } if (scroll_needs_defaults_) { set_scroll_default(); diff --git a/pv/views/trace/view.hpp b/pv/views/trace/view.hpp index c2cceb27..bf8b6432 100644 --- a/pv/views/trace/view.hpp +++ b/pv/views/trace/view.hpp @@ -96,6 +96,7 @@ private: static const pv::util::Timestamp MinScale; static const int MaxScrollValue; + static const int ViewScrollMargin; static const int ScaleUnits[3]; -- 2.30.2