mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 00:33:24 +00:00
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>
This commit is contained in:
parent
405e6b6b69
commit
cad00032fc
1 changed files with 12 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue