aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-19 06:11:46 +0100
committerSven Göthel <[email protected]>2024-01-19 06:11:46 +0100
commita516c694031e77c0e94d30f769c66495c4bf72ea (patch)
tree062658336b7abf5def31289279a9d8171e5dcb84
parent48f907dc431817806f8bd766d98dcca59dc8290c (diff)
GraphUI Tooltip: Use delayMS for no time-based alarm (only used for now()); FontView01: Use TooltipShape for GlyphShape only with mouse click -> Tooltip.now()
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java4
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Tooltip.java27
2 files changed, 16 insertions, 15 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
index a59cdfb74..bf8d96f9e 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
@@ -343,7 +343,7 @@ public class FontView01 {
mainView = new Group(new GridLayout(1, 0f, 0f, Alignment.None));
mainView.addShape(glyphInfoView);
final String infoText = "Hover over this label and wait 1s for tooltip help.";
- final String infoHelp = "Hover over a Glyph and wait 1s for a big tooltip view.\n"+
+ final String infoHelp = "Click on a Glyph for a big tooltip view.\n"+
"Key-Up/Down or Slider-Mouse-Scroll to move through glyphs.\n"+
"Page-Up/Down or Control + Slider-Mouse-Scroll to page faster.\n"+
"Mouse-Scroll over left-half of Window rotates and holding control zooms.";
@@ -526,7 +526,7 @@ public class FontView01 {
sink.receiveKeyEvents(c1);
// sink.receiveMouseEvents(c1);
c1.setToolTip( new TooltipShape(new Vec4f(1, 1, 1, 1), new Vec4f(0, 0, 0, 1), 0.01f,
- new Padding(0.05f), new Vec2f(14,14), 1000, options.renderModes,
+ new Padding(0.05f), new Vec2f(14,14), 0, options.renderModes,
g, TooltipShape.NoOpDtor) );
c1.onClicked((final Shape s) -> {
c1.getTooltip().now();
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Tooltip.java b/src/graphui/classes/com/jogamp/graph/ui/Tooltip.java
index 91e67dbb7..fd0bb6c2c 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Tooltip.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Tooltip.java
@@ -46,9 +46,10 @@ public abstract class Tooltip {
/** Default tooltip delay is {@value}ms */
public static final long DEFAULT_DELAY = 1000;
+ /** Delay in ms, zero implies no time based alarm */
private final long delayMS;
- /** Delay t1, time to show tooltip, i.e. t0 + delayMS */
- private volatile long delayT1;
+ /** Alarm t1, time to show tooltip, i.e. t0 + delayMS, if delayMS > 0 */
+ private volatile long alarmT1;
/** Toggle for forced tooltip display */
private volatile boolean forced;
/** Shape 'tool' owning this tooltip. */
@@ -60,18 +61,18 @@ public abstract class Tooltip {
@Override
public String toString() {
- return "Tooltip[d "+delayMS+", next "+delayT1+", forced "+forced+"]";
+ return "Tooltip[d "+delayMS+", next "+alarmT1+", forced "+forced+"]";
}
/**
*
* @param backColor optional HUD tip background color
* @param frontColor optional HUD tip front color
- * @param delayMS delay until HUD tip is visible after timer start (mouse moved)
+ * @param delayMS delay until HUD tip is visible after timer start (mouse moved), zero implies no time based alarm
* @param renderModes Graph's {@link Region} render modes, see {@link GLRegion#create(GLProfile, int, TextureSequence) create(..)}.
*/
protected Tooltip(final Vec4f backColor, final Vec4f frontColor, final long delayMS, final int renderModes) {
this.delayMS = delayMS;
- this.delayT1 = 0;
+ this.alarmT1 = 0;
this.forced = false;
this.tool = null;
this.renderModes = renderModes;
@@ -96,11 +97,11 @@ public abstract class Tooltip {
*/
public final boolean stop(final boolean clearForced) {
if( clearForced ) {
- this.delayT1 = 0;
+ this.alarmT1 = 0;
this.forced = false;
return true;
} else if( !this.forced ) {
- this.delayT1 = 0;
+ this.alarmT1 = 0;
return true;
} else {
return false;
@@ -109,15 +110,15 @@ public abstract class Tooltip {
/** Starts the timer. */
public final void start() {
- if( !this.forced ) {
- this.delayT1 = Clock.currentMillis() + delayMS;
+ if( !this.forced && delayMS > 0 ) {
+ this.alarmT1 = Clock.currentMillis() + delayMS;
}
}
/** Enforce tooltip display with next {@link #tick()}. */
public final void now() {
this.forced = true;
- this.delayT1 = Clock.currentMillis() - 1;
+ this.alarmT1 = Clock.currentMillis() - 1;
}
/** Returns true if display is enforced via {@link #now()}. */
@@ -130,13 +131,13 @@ public abstract class Tooltip {
* @return true if {@link #start() started} timer has been reached or is enforced via {@link #now()} to {@link #createTip(PMVMatrix4f)}, otherwise false
*/
public final boolean tick() {
- if( 0 == delayT1 ) {
+ if( 0 == alarmT1 ) {
return false;
}
- if( Clock.currentMillis() < delayT1 ) {
+ if( Clock.currentMillis() < alarmT1 ) {
return false;
}
- this.delayT1 = 0;
+ this.alarmT1 = 0;
this.forced = false;
return true;
}