From 5406ac7c12e3aa4be6475f4fb12eca03a188c2f4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 10 Apr 2023 06:07:28 +0200 Subject: GraphUI Shape: Refined toString(), add onToggle(Listener), at toggle() only markStateDirty() if toggleable --- src/graphui/classes/com/jogamp/graph/ui/Shape.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java index 10532d462..e46700f26 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java @@ -139,6 +139,7 @@ public abstract class Shape { private ArrayList mouseListeners = new ArrayList(); private Listener onMoveListener = null; + private Listener onToggleListener = null; public Shape() { this.box = new AABBox(); @@ -199,6 +200,7 @@ public abstract class Shape { } public final void onMove(final Listener l) { onMoveListener = l; } + public final void onToggle(final Listener l) { onToggleListener = l; } /** Move to scaled position. Position ends up in PMVMatrix unmodified. */ public final void moveTo(final float tx, final float ty, final float tz) { @@ -833,12 +835,14 @@ public abstract class Shape { } final String rotateS; if( !rotation.isIdentity() ) { - rotateS = "rot "+rotation+", "; + final Vec3f euler = rotation.toEuler(new Vec3f()); + rotateS = "rot["+euler+"], "; } else { rotateS = ""; } - return "enabled "+enabled+", toggle[able "+toggleable+", state "+toggle+"], pos["+position+ - "], "+pivotS+scaleS+rotateS+ + return "enabled "+enabled+", toggle[able "+toggleable+", state "+toggle+ + "], able[iactive "+isInteractive()+", resize "+isResizable()+", move "+this.isDraggable()+ + "], ["+position+"], "+pivotS+scaleS+rotateS+ "box "+box; } @@ -878,8 +882,9 @@ public abstract class Shape { public void toggle() { if( isToggleable() ) { toggle = !toggle; + onToggleListener.run(this); + markStateDirty(); } - markStateDirty(); } public boolean isToggleOn() { return toggle; } -- cgit v1.2.3