summaryrefslogtreecommitdiffstats
path: root/stats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-06 14:33:06 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-06 12:31:22 -0800
commitcad00032fc040973cd348bcc3708e054b6e6ffba (patch)
tree8f38f8a462f7445409317f0990e5b9973a24f22c /stats
parent405e6b6b693234024ae541a74cfb9733f3b8f09d (diff)
downloadsubsurface-cad00032fc040973cd348bcc3708e054b6e6ffba.tar.gz
statistics: improve placement of info-box
The info box was placed either above or below the mouse-pointer. If the pointer is at the center and the infobox higher than half the chart, it would cross the border. Detect this case and place the info box at the center. Same logic for right/left, though that should typically not happen. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats')
-rw-r--r--stats/informationbox.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/stats/informationbox.cpp b/stats/informationbox.cpp
index 706035f93..727b6fe83 100644
--- a/stats/informationbox.cpp
+++ b/stats/informationbox.cpp
@@ -40,11 +40,19 @@ void InformationBox::setPos(QPointF pos)
QRectF plotArea = chart->plotArea();
double x = pos.x() + distanceFromPointer;
- if (x + width >= plotArea.right() && pos.x() - width >= plotArea.x())
- x = pos.x() - width;
+ if (x + width >= plotArea.right()) {
+ if (pos.x() - width >= plotArea.x())
+ x = pos.x() - width;
+ else
+ x = pos.x() - width / 2.0;
+ }
double y = pos.y() + distanceFromPointer;
- if (y + height >= plotArea.bottom() && pos.y() - height >= plotArea.y())
- y = pos.y() - height;
+ if (y + height >= plotArea.bottom()) {
+ if (pos.y() - height >= plotArea.y())
+ y = pos.y() - height;
+ else
+ y = pos.y() - height / 2.0;
+ }
setRect(x, y, width, height);
double actY = y + 2.0 * informationBorder;