73 lines
2.5 KiB
Diff
73 lines
2.5 KiB
Diff
From 7352be721b90b630efd742b53e1a0ea16bb834b8 Mon Sep 17 00:00:00 2001
|
|
From: Soeren Apel <soeren@apelpie.net>
|
|
Date: Thu, 4 Feb 2016 22:38:34 +0100
|
|
Subject: [PATCH 07/13] DecodeTrace: Try to keep annotation labels within the
|
|
view
|
|
|
|
Up until now, annotation labels were always drawn centered,
|
|
even if the annotation was very wide and mostly off-screen.
|
|
This resulted in annotation labels being out of view, even
|
|
if there would be enough space to draw it within the view.
|
|
This patch fixes this.
|
|
---
|
|
pv/view/decodetrace.cpp | 15 +++++++++++----
|
|
pv/view/decodetrace.hpp | 2 +-
|
|
2 files changed, 12 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp
|
|
index e7ffbbb..eb1f7f8 100644
|
|
--- a/pv/view/decodetrace.cpp
|
|
+++ b/pv/view/decodetrace.cpp
|
|
@@ -425,7 +425,7 @@ void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a,
|
|
if (a.start_sample() == a.end_sample())
|
|
draw_instant(a, p, fill, outline, h, start, y);
|
|
else
|
|
- draw_range(a, p, fill, outline, h, start, end, y);
|
|
+ draw_range(a, p, fill, outline, h, start, end, y, pp);
|
|
}
|
|
|
|
void DecodeTrace::draw_annotation_block(
|
|
@@ -485,7 +485,7 @@ void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &
|
|
|
|
void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p,
|
|
QColor fill, QColor outline, int h, double start,
|
|
- double end, int y) const
|
|
+ double end, int y, const ViewItemPaintParams &pp) const
|
|
{
|
|
const double top = y + .5 - h / 2;
|
|
const double bottom = y + .5 + h / 2;
|
|
@@ -516,8 +516,15 @@ void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p,
|
|
if (annotations.empty())
|
|
return;
|
|
|
|
- QRectF rect(start + cap_width, y - h / 2,
|
|
- end - start - cap_width * 2, h);
|
|
+ const int ann_start = start + cap_width;
|
|
+ const int ann_end = end - cap_width;
|
|
+
|
|
+ const int real_start = std::max(ann_start, pp.left());
|
|
+ const int real_end = std::min(ann_end, pp.right());
|
|
+
|
|
+ const int real_width = real_end - real_start;
|
|
+
|
|
+ QRectF rect(real_start, y - h / 2, real_width, h);
|
|
if (rect.width() <= 4)
|
|
return;
|
|
|
|
diff --git a/pv/view/decodetrace.hpp b/pv/view/decodetrace.hpp
|
|
index 4964a95..af91518 100644
|
|
--- a/pv/view/decodetrace.hpp
|
|
+++ b/pv/view/decodetrace.hpp
|
|
@@ -141,7 +141,7 @@ private:
|
|
|
|
void draw_range(const pv::data::decode::Annotation &a, QPainter &p,
|
|
QColor fill, QColor outline, int h, double start,
|
|
- double end, int y) const;
|
|
+ double end, int y, const ViewItemPaintParams &pp) const;
|
|
|
|
void draw_error(QPainter &p, const QString &message,
|
|
const ViewItemPaintParams &pp);
|
|
--
|
|
2.4.3
|
|
|