]> sigrok.org Git - pulseview.git/commitdiff
Added a margin around ruler values
authorJoel Holdsworth <redacted>
Sat, 23 Mar 2013 10:59:43 +0000 (10:59 +0000)
committerJoel Holdsworth <redacted>
Sat, 23 Mar 2013 11:06:00 +0000 (11:06 +0000)
pv/view/ruler.cpp

index 350e49dcff0a2ee14656173ced94b422a9fc2697..4649b10d69648ddfc4625acb8a94ef01b8d9a32c 100644 (file)
@@ -65,6 +65,7 @@ void Ruler::paintEvent(QPaintEvent*)
 
        const double SpacingIncrement = 32.0f;
        const double MinValueSpacing = 32.0f;
+       const int ValueMargin = 3;
 
        QPainter p(this);
        p.setRenderHint(QPainter::Antialiasing);
@@ -118,6 +119,11 @@ void Ruler::paintEvent(QPaintEvent*)
 
        int division = (int)round(first_minor_division -
                first_major_division * MinorTickSubdivision);
+
+       const int major_tick_y1 = text_height + ValueMargin * 2;
+       const int tick_y2 = height();
+       const int minor_tick_y1 = (major_tick_y1 + tick_y2) / 2;
+
        while (1)
        {
                const double t = t0 + division * minor_tick_period;
@@ -129,17 +135,17 @@ void Ruler::paintEvent(QPaintEvent*)
                if (division % MinorTickSubdivision == 0)
                {
                        // Draw a major tick
-                       p.drawText(x, 0, 0, text_height, AlignCenter |
-                               AlignTop | TextDontClip,
+                       p.drawText(x, ValueMargin, 0, text_height,
+                               AlignCenter | AlignTop | TextDontClip,
                                format_time(t, multiplier, prefix));
-                       p.drawLine(QPointF(x, text_height),
-                               QPointF(x, height()));
+                       p.drawLine(QPointF(x, major_tick_y1),
+                               QPointF(x, tick_y2));
                }
                else
                {
                        // Draw a minor tick
-                       p.drawLine(QPointF(x, (text_height + height()) / 2),
-                               QPointF(x, height()));
+                       p.drawLine(QPointF(x, minor_tick_y1),
+                               QPointF(x, tick_y2));
                }
 
                division++;