aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java5
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/GraphShape.java2
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Scene.java2
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Shape.java45
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java6
5 files changed, 40 insertions, 20 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
index fe47db823..dfd6f55e7 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
@@ -40,6 +40,7 @@ import com.jogamp.common.net.Uri;
import com.jogamp.common.util.IOUtil;
import com.jogamp.common.util.VersionUtil;
import com.jogamp.graph.curve.Region;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
@@ -733,7 +734,7 @@ public class UISceneDemo20 implements GLEventListener {
setSoundPosition(shape, aSink.getContext(), aSink.getSource());
}
} );
- button.onInit( (final Shape shape) -> {
+ button.onDraw( (final Shape shape, final GL2ES2 gl_, final RegionRenderer renderer_) -> {
final ALAudioSink aSink = alAudioSink[0];
if( null != aSink && aSink.getContext().isValid() ) {
initSound(shape, aSink.getContext(), aSink.getSource());
@@ -804,7 +805,7 @@ public class UISceneDemo20 implements GLEventListener {
System.err.println("Sine "+sineSound);
} } );
- button.onInit( (final Shape shape) -> {
+ button.onDraw( (final Shape shape, final GL2ES2 gl_, final RegionRenderer renderer_) -> {
if( null != aSink && aSink.getContext().isValid() ) {
initSound(shape, aSink.getContext(), aSource);
System.err.println("Sine Audio: "+aSink);
diff --git a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java
index 0cc48b627..8f2337f0b 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java
@@ -151,6 +151,8 @@ public abstract class GraphShape extends Shape {
region.draw(gl, renderer);
}
+ public GLRegion getRegion() { return region; }
+
@Override
protected final void drawToSelectImpl0(final GL2ES2 gl, final RegionRenderer renderer) {
region.drawToSelect(gl, renderer);
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
index 7e45b44b1..56756de18 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
@@ -1377,7 +1377,7 @@ public final class Scene implements Container, GLEventListener {
final GLCapabilitiesImmutable caps = glad.getChosenGLCapabilities();
final String modeS = Region.getRenderModeString(renderModes, getAAQuality(), getSampleCount(), caps.getNumSamples());
final String blendStr;
- if( getRenderer().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
+ if( getRenderer().hintBitsSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
blendStr = ", blend";
} else {
blendStr = "";
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
index bd0983e5d..8eb4d9180 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
@@ -144,10 +144,22 @@ public abstract class Shape {
void run(final Shape shape);
}
/**
- * {@link Shape} listener action returning a boolean value
+ * {@link Shape} draw listener action returning a boolean value
+ * <p>
+ * If {@link #run(Shape, GL2ES2, RegionRenderer)} returns {@code true},
+ * the listener will be removed at {@link Shape#draw(GL2ES2, RegionRenderer)}
+ * otherwise kept calling.
+ * </p>
*/
- public static interface ListenerBool {
- boolean run(final Shape shape);
+ public static interface DrawListener {
+ /**
+ * Return {@code true} to remove this {@link DrawListener} at {@link Shape#draw(GL2ES2, RegionRenderer)},
+ * otherwise it is being kept and called.
+ * @param shape The shape
+ * @param gl the current {@link GL2ES2} object
+ * @param renderer the {@link RegionRenderer}
+ */
+ boolean run(final Shape shape, GL2ES2 gl, RegionRenderer renderer);
}
/**
@@ -288,7 +300,7 @@ public abstract class Shape {
private ArrayList<MouseGestureListener> mouseListeners = new ArrayList<MouseGestureListener>();
private ArrayList<KeyListener> keyListeners = new ArrayList<KeyListener>();
- private ListenerBool onInitListener = null;
+ private DrawListener onDrawListener = null;
private PointerListener onHoverListener = null;
private MoveListener onMoveListener = null;
private Listener onToggleListener = null;
@@ -428,7 +440,7 @@ public abstract class Shape {
box.reset();
mouseListeners.clear();
keyListeners.clear();
- onInitListener = null;
+ onDrawListener = null;
onMoveListener = null;
onToggleListener = null;
activationListeners.clear();
@@ -449,15 +461,20 @@ public abstract class Shape {
}
/**
- * Set a user one-shot initializer callback.
+ * Set a user one-shot initializer callback or custom {@link #draw(GL2ES2, RegionRenderer)} hook.
+ * <p>
+ * {@link #run(Shape, GL2ES2, RegionRenderer)} is called at {@link Shape#draw(GL2ES2, RegionRenderer)}
+ * and if returning {@code true}, the listener will be removed.
+ * Otherwise kept calling.
+ * </p>
* <p>
- * {@link ListenerBool#run(Shape)} will be called
- * after each {@link #draw(GL2ES2, RegionRenderer)}
- * until it returns true, signaling user initialization is completed.
+ * This instrument allows the user either to be signaled when initialization
+ * of this {@link Shape} is completed, or just too hook-up custom {@link #draw(GL2ES2, RegionRenderer)}
+ * actions.
* </p>
- * @param l callback, which shall return true signaling user initialization is done
+ * @param l callback, which shall return true to be removed, i.e. user initialization is done.
*/
- public final void onInit(final ListenerBool l) { onInitListener = l; }
+ public final void onDraw(final DrawListener l) { onDrawListener = l; }
/**
* Set user callback to be notified when a pointer/mouse is moving over this shape
*/
@@ -815,9 +832,9 @@ public abstract class Shape {
validate(gl);
drawImpl0(gl, renderer, rgba);
}
- if( null != onInitListener ) {
- if( onInitListener.run(this) ) {
- onInitListener = null;
+ if( null != onDrawListener ) {
+ if( onDrawListener.run(this, gl, renderer) ) {
+ onDrawListener = null;
}
}
}
diff --git a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
index 0ebe3a258..ab4b82706 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
@@ -104,7 +104,7 @@ public class RangedGroup extends Widget {
horizSlider = new RangeSlider(renderModes, horizSliderParam.size,
new Vec2f(0, content.getBounds().getWidth()), horizSliderParam.unitSize, contentSize.x(), 0).setInverted(horizSliderParam.inverted);
addShape(horizSlider);
- horizSlider.addChangeListener((final RangeSlider w, final float old_val, final float val, final float old_val_pct, final float val_pct, Vec3f pos, MouseEvent e) -> {
+ horizSlider.addChangeListener((final RangeSlider w, final float old_val, final float val, final float old_val_pct, final float val_pct, final Vec3f pos, final MouseEvent e) -> {
final Vec3f oldPos = content.getPosition();
if( horizSlider.isInverted() ) {
content.moveTo(contentPosZero.x()-val, oldPos.y(), oldPos.z());
@@ -119,7 +119,7 @@ public class RangedGroup extends Widget {
vertSlider = new RangeSlider(renderModes, vertSliderParam.size,
new Vec2f(0, content.getBounds().getHeight()), vertSliderParam.unitSize, contentSize.y(), 0).setInverted(vertSliderParam.inverted);
addShape(vertSlider);
- vertSlider.addChangeListener((final RangeSlider w, final float old_val, final float val, final float old_val_pct, final float val_pct, Vec3f pos, MouseEvent e) -> {
+ vertSlider.addChangeListener((final RangeSlider w, final float old_val, final float val, final float old_val_pct, final float val_pct, final Vec3f pos, final MouseEvent e) -> {
final Vec3f oldPos = content.getPosition();
if( vertSlider.isInverted() ) {
content.moveTo(oldPos.x(), contentPosZero.y()+val, oldPos.z());
@@ -130,7 +130,7 @@ public class RangedGroup extends Widget {
} else {
vertSlider = null;
}
- this.onInit( (final Shape shape) -> {
+ this.onDraw( (final Shape shape, final GL2ES2 gl_, final RegionRenderer renderer_) -> {
content.moveTo(contentPosZero.x(), contentPosZero.y(), 0);
return true;
});