aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph/ui/TooltipText.java
diff options
context:
space:
mode:
authorSven Göthel <sgothel@jausoft.com>2024-02-04 07:35:20 +0100
committerSven Göthel <sgothel@jausoft.com>2024-02-04 07:35:20 +0100
commit5e24fc150f505fc5e08fc6c8cc9274ecea66b28b (patch)
tree9d6bb8a17d0739d20522ad6d83032482357ae98c /src/graphui/classes/com/jogamp/graph/ui/TooltipText.java
parent6caed46dba2c8be34c3cb32dc6bddf31f98eac02 (diff)
Tooltip[Text]: Use a slightly round button, change to grayscale colors matching our buildin-theme and have the tips placed just above center of the toop (not above it)
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/TooltipText.java')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/TooltipText.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/TooltipText.java b/src/graphui/classes/com/jogamp/graph/ui/TooltipText.java
index 77386d224..b02c420cf 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/TooltipText.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/TooltipText.java
@@ -27,6 +27,7 @@
*/
package com.jogamp.graph.ui;
+import com.jogamp.common.util.StringUtil;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.font.Font;
@@ -39,7 +40,7 @@ import com.jogamp.math.util.PMVMatrix4f;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLProfile;
-/** A HUD text {@link Tooltip} for {@link Shape}, see {@link Shape#setToolTip(Tooltip)}. */
+/** A round {@link Button HUD text} {@link Tooltip} for {@link Shape}, see {@link Shape#setToolTip(Tooltip)}. */
public class TooltipText extends Tooltip {
/** Text of this tooltip */
private final CharSequence tipText;
@@ -67,7 +68,7 @@ public class TooltipText extends Tooltip {
}
/**
* 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.
+ * and a slightly transparent light-grey background with an slightly transparent almost-black text color.
* @param tipText HUD tip text
* @param tipFont HUD tip font
* @param scaleY HUD tip vertical scale against tool height
@@ -86,9 +87,14 @@ public class TooltipText extends Tooltip {
final AffineTransform tempT1 = new AffineTransform();
final AffineTransform tempT2 = new AffineTransform();
final AABBox tipBox_em = tipFont.getGlyphBounds(tipText, tempT1, tempT2);
-
- float h = toolMvBounds.getHeight() * scaleY;
- float w = tipBox_em.getWidth() * h / tipBox_em.getHeight();
+ final float dys;
+ {
+ // lineHeight = tipBox_em.getHeight() / StringUtil.getLineCount(tipText);
+ final float totalH = tipBox_em.getHeight() * ( 1 + 0.5f/StringUtil.getLineCount(tipText) );
+ dys = totalH / tipBox_em.getHeight() - 1;
+ }
+ float h = toolMvBounds.getHeight() * scaleY * ( 1 + dys );
+ float w = ( tipBox_em.getWidth() * h / tipBox_em.getHeight() ) * ( 1 - dys );
if( w > sceneAABox.getWidth() * 0.9f) {
w = sceneAABox.getWidth() * 0.9f;
h = tipBox_em.getHeight() * w / tipBox_em.getWidth();
@@ -99,13 +105,13 @@ public class TooltipText extends Tooltip {
final Vec2f pos = getTipMvPosition(scene, toolMvBounds, w, h);
final Button ntip = (Button) new Button(renderModes, tipFont, tipText, w, h, zEps)
- .setPerp()
.moveTo(pos.x(), pos.y(), 100*zEps)
.setColor(backColor)
- // .setBorder(0.05f).setBorderColor(0, 0, 0, 1)
+ // .setBorder(0.05f).setBorderColor(0, 0, 0, 0.5f)
.setInteractive(false);
ntip.setLabelColor(frontColor);
- ntip.setSpacing(0.10f, 0.10f);
+ ntip.setSpacing(0.075f, dys);
+ ntip.setCorner(0.75f);
return ntip;
}
}