From f998e21e7d4922fb9e6517c638cffb47ffe0e5df Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Wed, 21 Oct 2020 11:46:08 +0300 Subject: [PATCH] Scale tooltip font by display DPI. Dragging or moving pointer out of view clears hover objects. gitlab #142 Change-Id: I68e8f1da87ad9c2a979792bfc14911cc474f6ead --- .../g3d/vtk/awt/vtkCameraAndSelectorAction.java | 12 ++++++++++++ .../src/org/simantics/g3d/vtk/utils/vtkToolTip.java | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/vtkCameraAndSelectorAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/vtkCameraAndSelectorAction.java index 0ce1acd2..eef4e247 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/vtkCameraAndSelectorAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/vtkCameraAndSelectorAction.java @@ -196,6 +196,10 @@ public class vtkCameraAndSelectorAction extends vtkAwtAction implements ISelecti resetCameraClippingRange(); } } + if (hoverActor.size() > 0) { + hoverActor.clear(); + fireHoverChanged(); + } lastX = x; lastY = y; panel.Render(); @@ -295,6 +299,14 @@ public class vtkCameraAndSelectorAction extends vtkAwtAction implements ISelecti } } + @Override + public void mouseExited(MouseEvent e) { + if (hoverActor.size() > 0) { + hoverActor.clear(); + fireHoverChanged(); + } + } + /** * Returns mouse position in AWT screen coordinates. * @return diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/utils/vtkToolTip.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/utils/vtkToolTip.java index e5625746..bb03d3b0 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/utils/vtkToolTip.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/utils/vtkToolTip.java @@ -18,6 +18,7 @@ public class vtkToolTip implements RenderListener{ double backgroundOpacity = 0.8; double color[] = new double[] {0.0,0.0,0.0}; double frameColor[] = new double[] {0.0,0.0,0.0}; + int fontSize = 12; T obj = null; Point3d pos3d; @@ -80,6 +81,10 @@ public class vtkToolTip implements RenderListener{ this.frameColor = frameColor; } + public void setFontSize(int fontSize) { + this.fontSize = fontSize; + } + /** * Removes/hides current tooltip. */ @@ -190,6 +195,7 @@ public class vtkToolTip implements RenderListener{ } else { prop.SetFrame(0); } + prop.SetFontSize(view.upscale(fontSize)); prop.Delete(); view.addDeletable(textActor); -- 2.47.1