aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph/ui/TooltipText.java
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-07 21:27:18 +0100
committerSven Göthel <[email protected]>2024-01-07 21:27:18 +0100
commit6dbd73108ec0b2f829674c07771c232395034157 (patch)
treef6d8083e5384f4b80785a03f6d30d9e061a2af76 /src/graphui/classes/com/jogamp/graph/ui/TooltipText.java
parentc2452b211dc3f347dbffaac4e6c35b3c3e8c6d65 (diff)
GraphUI Tooltip: Simplify integration w/ Scene + Shape; Use Shape.setToolTip(Tooltip) for generic usage; Add TooltipText colors.
Shape also takes care of setting Tooltip's tool-Shape (itself), simplifying Tooltip ctor and having it more independent from Scene/Shape. Tooltip also drop Scene reference, as it shall be passed from Scene caller at Tooltip.createTip(..)
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/TooltipText.java')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/TooltipText.java50
1 files changed, 36 insertions, 14 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/TooltipText.java b/src/graphui/classes/com/jogamp/graph/ui/TooltipText.java
index 6c2912bf4..b421604c9 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/TooltipText.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/TooltipText.java
@@ -31,35 +31,58 @@ import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.ui.shapes.Button;
+import com.jogamp.math.Vec4f;
import com.jogamp.math.geom.AABBox;
import com.jogamp.math.geom.plane.AffineTransform;
import com.jogamp.math.util.PMVMatrix4f;
import com.jogamp.opengl.GLProfile;
-/** A HUD text {@link Tooltip} for {@link Shape}, see {@link Shape#setToolTip(CharSequence, com.jogamp.graph.font.Font, float, Scene)}. */
+/** A HUD text {@link Tooltip} for {@link Shape}, see {@link Shape#setToolTip(Tooltip)}. */
public class TooltipText extends Tooltip {
/** Text of this tooltip */
- final private CharSequence tipText;
+ private final CharSequence tipText;
/** Font of this tooltip */
- final private Font tipFont;
- final private float scaleY;
- final private int renderModes;
+ private final Font tipFont;
+ private final float scaleY;
+ private final int renderModes;
+ private final Vec4f backColor = new Vec4f();
+ private final Vec4f labelColor = new Vec4f();
+
/**
* Ctor of {@link TooltipText}.
- * @param scene the {@link Scene} to be attached to while pressed
+ * @param tipText HUD tip text
+ * @param tipFont HUD tip font
+ * @param backColor HUD tip background color
+ * @param labelColor HUD tip label color
+ * @param scaleY HUD tip vertical scale against tool height
+ * @param delayMS delay until HUD tip is visible after timer start (mouse moved)
* @param renderModes Graph's {@link Region} render modes, see {@link GLRegion#create(GLProfile, int, TextureSequence) create(..)}.
*/
- /* pp */ TooltipText(final CharSequence tipText, final Font tipFont, final float scaleY, final Shape tool, final long delayMS, final Scene scene, final int renderModes) {
- super(tool, delayMS, scene);
+ public TooltipText(final CharSequence tipText, final Font tipFont, final Vec4f backColor, final Vec4f labelColor,
+ final float scaleY, final long delayMS, final int renderModes)
+ {
+ super(delayMS);
this.tipText = tipText;
this.tipFont = tipFont;
this.scaleY = scaleY;
this.renderModes = renderModes;
+ this.backColor.set(backColor);
+ this.labelColor.set(labelColor);
+ }
+ /**
+ * Ctor of {@link TooltipText} using {@link Tooltip#DEFAULT_DELAY}, {@link Region#VBAA_RENDERING_BIT}
+ * and a slightly transparent yellow background with an almost black opaque text color.
+ * @param tipText HUD tip text
+ * @param tipFont HUD tip font
+ * @param scaleY HUD tip vertical scale against tool height
+ * @param tool the tool shape for this tip
+ */
+ public TooltipText(final CharSequence tipText, final Font tipFont, final float scaleY) {
+ this(tipText, tipFont, new Vec4f(1, 1, 0, 0.80f), new Vec4f(0.1f, 0.1f, 0.1f, 1), scaleY, Tooltip.DEFAULT_DELAY, Region.VBAA_RENDERING_BIT);
}
@Override
- public GraphShape createTip(final PMVMatrix4f pmv) {
- this.delayT1 = 0;
+ public Shape createTip(final Scene scene, final PMVMatrix4f pmv) {
final float zEps = scene.getZEpsilon(16);
// Precompute text-box size .. guessing pixelSize
@@ -68,7 +91,7 @@ public class TooltipText extends Tooltip {
final AABBox tipBox_em = tipFont.getGlyphBounds(tipText, tempT1, tempT2);
// final AABBox toolAABox = scene.getBounds(new PMVMatrix4f(), tool);
- final AABBox toolAABox = tool.getBounds().transform(pmv.getMv(), new AABBox());
+ final AABBox toolAABox = getTool().getBounds().transform(pmv.getMv(), new AABBox());
final float h = toolAABox.getHeight() * scaleY;
final float w = tipBox_em.getWidth() / tipBox_em.getHeight() * h;
@@ -88,12 +111,11 @@ public class TooltipText extends Tooltip {
final Button ntip = (Button) new Button(renderModes, tipFont, tipText, w, h, zEps)
.setPerp()
.moveTo(xpos, ypos, 100*zEps)
- .setColor(1, 1, 0, 0.80f)
+ .setColor(backColor)
// .setBorder(0.05f).setBorderColor(0, 0, 0, 1)
.setInteractive(false);
- ntip.setLabelColor(0, 0, 0);
+ ntip.setLabelColor(labelColor);
ntip.setSpacing(0.10f, 0.10f);
- scene.addShape(ntip);
return ntip;
}
}