aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphui')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Scene.java14
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Shape.java44
2 files changed, 52 insertions, 6 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
index 16e650124..2822ddc09 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
@@ -916,11 +916,14 @@ public final class Scene implements Container, GLEventListener {
}
public void releaseActiveShape() {
- if( null != activeShape && !FloatUtil.isZero(lastActiveZOffset) ) {
- activeShape.move(0, 0, -lastActiveZOffset);
- lastActiveZOffset = 0f;
+ if( null != activeShape ) {
+ if( !FloatUtil.isZero(lastActiveZOffset) ) {
+ activeShape.move(0, 0, -lastActiveZOffset);
+ lastActiveZOffset = 0f;
+ }
+ activeShape.setActive(false);
+ activeShape = null;
}
- activeShape = null;
}
private void setActiveShape(final Shape shape) {
if( activeShape != shape ) {
@@ -930,6 +933,9 @@ public final class Scene implements Container, GLEventListener {
shape.move(0, 0, +lastActiveZOffset);
}
}
+ if( null != shape ) {
+ shape.setActive(true);
+ }
activeShape = shape;
}
private float lastActiveZOffset = 0f;
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
index db7d7d9c2..6b15e3afd 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
@@ -156,6 +156,7 @@ public abstract class Shape {
private boolean draggable = true;
private boolean resizable = true;
private boolean interactive = true;
+ private boolean active = false;
private boolean enabled = true;
private float borderThickness = 0f;
private Padding padding = null;
@@ -165,6 +166,7 @@ public abstract class Shape {
private ListenerBool onInitListener = null;
private Listener onMoveListener = null;
private Listener onToggleListener = null;
+ private Listener onActivationListener = null;
private Listener onClickedListener = null;
/**
@@ -279,8 +281,34 @@ public abstract class Shape {
* @param l callback, which shall return true signaling user initialization is done
*/
public final void onInit(final ListenerBool l) { onInitListener = l; }
+ /**
+ * Set user callback to be notified when shape is {@link #move(Vec3f)}'ed.
+ */
public final void onMove(final Listener l) { onMoveListener = l; }
+ /**
+ * Set user callback to be notified when shape {@link #toggle()}'ed.
+ * <p>
+ * This is usually the case when clicked, see {@link #onClicked(Listener)}.
+ * </p>
+ * <p>
+ * Use {@link #isToggleOn()} to retrieve the state.
+ * </p>
+ */
public final void onToggle(final Listener l) { onToggleListener = l; }
+ /**
+ * Set user callback to be notified when shape is activated (pointer-over and/or click) or de-activated (pointer left).
+ * <p>
+ * Use {@link #isActive()} to retrieve the state.
+ * </p>
+ */
+ public final void onActivation(final Listener l) { onActivationListener = l; }
+ /**
+ * Set user callback to be notified when shape is clicked.
+ * <p>
+ * Usually shape is {@link #toggle()}'ed when clicked, see {@link #onToggle(Listener)}.
+ * However, in case shape is not {@link #isToggleable()} this is the last resort.
+ * </p>
+ */
public final void onClicked(final Listener l) { onClickedListener = l; }
/** Move to scaled position. Position ends up in PMVMatrix4f unmodified. */
@@ -1101,10 +1129,11 @@ public abstract class Shape {
} else {
rotateS = "";
}
+ final String activeS = active ? ", active" : "";
final String ps = hasPadding() ? padding.toString()+", " : "";
final String bs = hasBorder() ? "border[l "+getBorderThickness()+", c "+getBorderColor()+"], " : "";
- return getDirtyString()+", id "+name+", enabled "+enabled+", toggle[able "+toggleable+", state "+toggle+
- "], able[iactive "+isInteractive()+", resize "+isResizable()+", move "+this.isDraggable()+
+ return getDirtyString()+", id "+name+", enabled "+enabled+activeS+", toggle "+toggle+
+ ", able[toggle "+toggleable+", iactive "+isInteractive()+", resize "+isResizable()+", move "+this.isDraggable()+
"], pos["+position+"], "+pivotS+scaleS+rotateS+
ps+bs+"box"+box;
}
@@ -1155,8 +1184,19 @@ public abstract class Shape {
}
return this;
}
+ /** Returns true this shape's toggle state. */
public boolean isToggleOn() { return toggle; }
+ protected void setActive(final boolean v) {
+ active = v;
+ if( null != onActivationListener ) {
+ onActivationListener.run(this);
+ }
+ }
+
+ /** Returns true of this shape is active */
+ public boolean isActive() { return active; }
+
/**
* Set whether this shape is interactive,
* i.e. any user interaction like