From: Joel Holdsworth Date: Sat, 23 Mar 2013 10:59:43 +0000 (+0000) Subject: Added a margin around ruler values X-Git-Tag: pulseview-0.1.0~66 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f260e3bfe8cc0f221b3d4498b548295b9168ffbf;p=pulseview.git Added a margin around ruler values --- diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index 350e49dc..4649b10d 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -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++;