diff options
author | Sven Gothel <[email protected]> | 2023-05-23 02:15:53 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-05-23 02:15:53 +0200 |
commit | 31d430e19fdd6dcd69e652df10ac34dcfa0e7add (patch) | |
tree | 77f5ebaaa5bbef57e9c337852b9a3de7599d02b5 /src/graphui/classes/com | |
parent | 8c0f65869a4689d5f908249de3a3439930f2886e (diff) |
GraphUI Shape: Add one-shot init callback, will be called after each draw(..) until it returns true.
Diffstat (limited to 'src/graphui/classes/com')
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/Shape.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java index 03dd4b62a..ba1e50b1c 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java @@ -113,6 +113,12 @@ public abstract class Shape { public static interface Listener { void run(final Shape shape); } + /** + * {@link Shape} listener action returning a boolean value + */ + public static interface ListenerBool { + boolean run(final Shape shape); + } protected static final boolean DEBUG_DRAW = false; private static final boolean DEBUG = false; @@ -155,6 +161,7 @@ public abstract class Shape { private final Vec4f borderColor = new Vec4f(0.0f, 0.0f, 0.0f, 1.0f); private ArrayList<MouseGestureListener> mouseListeners = new ArrayList<MouseGestureListener>(); + private ListenerBool onInitListener = null; private Listener onMoveListener = null; private Listener onToggleListener = null; private Listener onClickedListener = null; @@ -250,6 +257,16 @@ public abstract class Shape { markShapeDirty(); } + /** + * Set a user one-shot initializer callback. + * <p> + * {@link ListenerBool#run(Shape)} will be called + * after each {@link #draw(GL2ES2, RegionRenderer, int[])} + * until it returns true, signaling user initialization is completed. + * </p> + * @param l callback, which shall return true signaling user initialization is done + */ + public final void onInit(final ListenerBool l) { onInitListener = l; } public final void onMove(final Listener l) { onMoveListener = l; } public final void onToggle(final Listener l) { onToggleListener = l; } public final void onClicked(final Listener l) { onClickedListener = l; } @@ -474,6 +491,11 @@ public abstract class Shape { validate(gl); drawImpl0(gl, renderer, sampleCount, rgba); } + if( null != onInitListener ) { + if( onInitListener.run(this) ) { + onInitListener = null; + } + } } /** |