projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d0c0573
)
Ruler tick legends don't partly disappear when scrolled off the ends
author
Cenkron
<Cenkron@BrianAndChristine.com>
Mon, 15 Jan 2018 02:04:17 +0000
(20:04 -0600)
committer
Soeren Apel
<soeren@apelpie.net>
Thu, 8 Feb 2018 09:47:28 +0000
(10:47 +0100)
pv/views/trace/ruler.cpp
patch
|
blob
|
history
diff --git
a/pv/views/trace/ruler.cpp
b/pv/views/trace/ruler.cpp
index 0c2b6592cf3eb90f05f18a6ca95aadb2418acfb4..63d3d23fcb946536f173ee0e184aacd1084d0039 100644
(file)
--- a/
pv/views/trace/ruler.cpp
+++ b/
pv/views/trace/ruler.cpp
@@
-29,6
+29,8
@@
using namespace Qt;
using std::function;
using namespace Qt;
using std::function;
+using std::max;
+using std::min;
using std::shared_ptr;
using std::vector;
using std::shared_ptr;
using std::vector;
@@
-159,10
+161,18
@@
void Ruler::paintEvent(QPaintEvent*)
p.setPen(palette().color(foregroundRole()));
for (const auto& tick: tick_position_cache_->major) {
p.setPen(palette().color(foregroundRole()));
for (const auto& tick: tick_position_cache_->major) {
- p.drawText(tick.first, ValueMargin, 0, text_height,
+ const int leftedge = 0;
+ const int rightedge = width();
+ const int x_tick = tick.first;
+ if ((x_tick > leftedge) && (x_tick < rightedge)) {
+ const int x_left_bound = QFontMetrics(font()).width(tick.second) / 2;
+ const int x_right_bound = rightedge - x_left_bound;
+ const int x_legend = min(max(x_tick, x_left_bound), x_right_bound);
+ p.drawText(x_legend, ValueMargin, 0, text_height,
AlignCenter | AlignTop | TextDontClip, tick.second);
AlignCenter | AlignTop | TextDontClip, tick.second);
-
p.drawLine(QPointF(tick.first
, major_tick_y1),
+
p.drawLine(QPointF(x_tick
, major_tick_y1),
QPointF(tick.first, ruler_height));
QPointF(tick.first, ruler_height));
+ }
}
for (const auto& tick: tick_position_cache_->minor) {
}
for (const auto& tick: tick_position_cache_->minor) {