]> sigrok.org Git - pulseview.git/commitdiff
TraceView: Implement view scroll margins
authorSoeren Apel <redacted>
Tue, 11 Feb 2020 18:06:11 +0000 (19:06 +0100)
committerSoeren Apel <redacted>
Tue, 11 Feb 2020 18:06:55 +0000 (19:06 +0100)
pv/views/trace/view.cpp
pv/views/trace/view.hpp

index 6159cdd997053b921dedb6158860796e0195cac1..e5cf980a79223b1a84412fb1c845070194d4458d 100644 (file)
@@ -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<int, int> 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();
index c2cceb274d851989c8d6b1f8d225fb5ec3e238a1..bf8b64325feef171b3c7fb17b01dff461985284f 100644 (file)
@@ -96,6 +96,7 @@ private:
        static const pv::util::Timestamp MinScale;
 
        static const int MaxScrollValue;
+       static const int ViewScrollMargin;
 
        static const int ScaleUnits[3];