diff options
author | Sven Göthel <[email protected]> | 2024-02-04 20:49:20 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-02-04 20:49:20 +0100 |
commit | ec5d278a51eaaf4062010df41cf23f884e4b715b (patch) | |
tree | d3a5e0e680ad7a49b1325d7f74353f3021aefa40 | |
parent | d35a9d954fbe638546f95f0122b8c083ee4bd809 (diff) |
GraphUI Cleanup: Use TreeTool directly (Reduce virtl-funcs); Fix typos; Use PointerListener for onClicked(), add onHover();
Subsequent commits will fix complete cleanup where code was changed mostly regarding other issues.
20 files changed, 215 insertions, 284 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 d8f75610f..2e7d3c6e3 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java @@ -56,7 +56,7 @@ import com.jogamp.graph.ui.shapes.GlyphShape; import com.jogamp.graph.ui.shapes.Label; import com.jogamp.graph.ui.shapes.Rectangle; import com.jogamp.graph.ui.widgets.RangeSlider; -import com.jogamp.graph.ui.widgets.RangeSlider.SliderAdapter; +import com.jogamp.graph.ui.widgets.RangeSlider.SliderListener; import com.jogamp.graph.ui.widgets.RangedGroup; import com.jogamp.graph.ui.widgets.RangedGroup.SliderParam; import com.jogamp.math.FloatUtil; @@ -284,7 +284,7 @@ public class FontView01 { // final float gapSizeX = ( gridDim.rawSize.x() - 1 ) * cellSize * 0.1f; final Group glyphGrid = new Group(new GridLayout(gridDim.columns, glyphGridCellSize*0.9f, glyphGridCellSize*0.9f, Alignment.FillCenter, new Gap(glyphGridCellSize*0.1f))); - glyphGrid.setInteractive(true).setDragAndResizeable(false).setToggleable(false).setName("GlyphGrid"); + glyphGrid.setInteractive(true).setDragAndResizable(false).setToggleable(false).setName("GlyphGrid"); addGlyphs(reqCaps.getGLProfile(), font, glyphGrid, gridDim, showUnderline, showLabel, fontStatus, fontInfo, glyphMouseListener); glyphGrid.setRelayoutOnDirtyShapes(false); // avoid group re-validate to ease load in Group.isShapeDirty() w/ thousands of glyphs if( VERBOSE_UI ) { @@ -303,7 +303,7 @@ public class FontView01 { new SliderParam( new Vec2f(glyphGridCellSize/4f, glyphGridSize.y()), glyphGridCellSize/10f, true ) ); glyphView.getVertSlider().setColor(0.3f, 0.3f, 0.3f, 0.7f).setName("GlyphView"); if( VERBOSE_UI ) { - glyphView.getVertSlider().addSliderListener(new SliderAdapter() { + glyphView.getVertSlider().addSliderListener(new SliderListener() { @Override public void dragged(final RangeSlider w, final float old_val, final float val, final float old_val_pct, final float val_pct) { final Vec2f minmax = w.getMinMax(); @@ -515,17 +515,17 @@ public class FontView01 { final GlyphShape g = new GlyphShape(options.renderModes, fg, 0, 0); g.setColor(0.1f, 0.1f, 0.1f, 1).setName("GlyphShape"); - g.setInteractive(false).setDragAndResizeable(false); + g.setInteractive(false).setDragAndResizable(false); g.setName( "cp_0x"+Integer.toHexString(fg.getCodepoint()) ); final Group c0 = new Group("GlyphHolder", null, null, g); - c0.setInteractive(false).setDragAndResizeable(false); + c0.setInteractive(false).setDragAndResizable(false); // Group each GlyphShape with its bounding box Rectangle final AABBox gbox = fg.getBounds(tmpBox); // g.getBounds(glp); final boolean addUnderline = showUnderline && gbox.getMinY() < 0f; final Group c1 = new Group( new BoxLayout( 1f, 1f, addUnderline ? Alignment.None : Alignment.Center) ); - c1.setBorder(GlyphGridBorderThickness).setBorderColor(GlyphGridBorderColor).setInteractive(true).setDragAndResizeable(false).setName("GlyphHolder2"); + c1.setBorder(GlyphGridBorderThickness).setBorderColor(GlyphGridBorderColor).setInteractive(true).setDragAndResizable(false).setName("GlyphHolder2"); if( addUnderline ) { final Shape underline = new Rectangle(options.renderModes, 1f, gbox.getMinY(), 0.01f).setInteractive(false).setColor(0f, 0f, 1f, 0.25f); c1.addShape(underline); @@ -538,7 +538,7 @@ public class FontView01 { 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), 0, options.renderModes, g, TooltipShape.NoOpDtor) ); - c1.onClicked((final Shape s) -> { + c1.onClicked((final Shape s, final Vec3f pos, final MouseEvent e) -> { c1.getTooltip().now(); }); @@ -552,7 +552,7 @@ public class FontView01 { final Label l = new Label(options.renderModes, fontInfo, fg.getName()); // final AABBox lbox = l.getUnscaledGlyphBounds(); final float sxy = 1f/7f; // gridDim.maxNameLen; // 0.10f; // Math.min(sx, sy); - c2.addShape( l.scale(sxy, sxy, 1).setColor(0, 0, 0, 1).setInteractive(false).setDragAndResizeable(false) ); + c2.addShape( l.scale(sxy, sxy, 1).setColor(0, 0, 0, 1).setInteractive(false).setDragAndResizable(false) ); } sink.addShape(c2); // System.err.println("Add.2: "+c2); @@ -567,7 +567,7 @@ public class FontView01 { System.err.println("PERF: GlyphAdd took "+(total/1000000.0)+"ms, per-glyph "+(nsPerGlyph/1000000.0)+"ms, glyphs "+gridDim.glyphCount); } static void addLabel(final Group c, final Font font, final String text) { - c.addShape( new Label(options.renderModes, font, text).setColor(0, 0, 0, 1).setInteractive(false).setDragAndResizeable(false) ); + c.addShape( new Label(options.renderModes, font, text).setColor(0, 0, 0, 1).setInteractive(false).setDragAndResizable(false) ); } static void setGlyphInfo(final Font font, final Label label, final Font.Glyph g) { diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java index f5d373a50..dcd9a96d5 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java @@ -62,6 +62,8 @@ import com.jogamp.opengl.demos.graph.ui.util.Tooltips; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.util.Animator; +import jogamp.graph.ui.TreeTool; + /** * Res independent {@link Shape}s in a {@link Group} using a {@link BoxLayout}, contained within a Scene attached to GLWindow. * <p> @@ -435,7 +437,7 @@ public class UILayoutBox01 { g.validate(reqGLP); System.err.println("Group-A"+suffix+" "+g); System.err.println("Group-A"+suffix+" Layout "+g.getLayout()); - g.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; }); + TreeTool.forAll(g, (shape) -> { System.err.println("Shape... "+shape); return false; }); scene.addShape(g); { final float X_width = font.getGlyph( ' ' ).getAdvanceWidth(); @@ -457,7 +459,7 @@ public class UILayoutBox01 { l.getAlignment() ); final Shape label = new Label(options.renderModes, font, text).setColor(0, 0, 0, 1).validate(reqGLP); label.scale(l_sxy, l_sxy, 1).moveTo(sceneBox.getLow()).move(nextPos).move(l_sxy*X_width, g.getScaledHeight(), 0) - .addMouseListener(new Tooltips.ZoomLabelOnClickListener(scene, options.renderModes, 1/4f)).setDragAndResizeable(false); + .addMouseListener(new Tooltips.ZoomLabelOnClickListener(scene, options.renderModes, 1/4f)).setDragAndResizable(false); scene.addShape(label); System.err.println("ID "+id+": "+label); } diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBoxGridOffset01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBoxGridOffset01.java index 9c9a3b702..50a5c3349 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBoxGridOffset01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBoxGridOffset01.java @@ -56,6 +56,8 @@ import com.jogamp.opengl.demos.graph.ui.util.Tooltips; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.util.Animator; +import jogamp.graph.ui.TreeTool; + /** * Res independent {@link Shape}s with offset (not starting at origin) * in a {@link Group} using {@link BoxLayout} and {@link GridLayout}, contained within a Scene attached to GLWindow. @@ -148,7 +150,7 @@ public class UILayoutBoxGridOffset01 { sxy, nextPos, cellGapX, font, 11, (final Group gp) -> { - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); }, minX, minY ); nextPos.setX( nextPos.x() + cellGapX ); } @@ -161,7 +163,7 @@ public class UILayoutBoxGridOffset01 { sxy, nextPos, cellGapX, font, 12, (final Group gp) -> { - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); }, minX, minY ); nextPos.setX( nextPos.x() + cellGapX ); } @@ -171,7 +173,7 @@ public class UILayoutBoxGridOffset01 { sxy, nextPos, cellGapX, font, 13, (final Group gp) -> { - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); }, minX, minY ); nextPos.setX( nextPos.x() + cellGapX ); } @@ -181,7 +183,7 @@ public class UILayoutBoxGridOffset01 { sxy, nextPos, cellGapX, font, 14, (final Group gp) -> { - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); }, minX, minY ); nextPos.setX( nextPos.x() + cellGapX ); } @@ -191,7 +193,7 @@ public class UILayoutBoxGridOffset01 { sxy, nextPos, cellGapX, font, 15, (final Group gp) -> { - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); }, minX, minY ); nextPos.setX( nextPos.x() + cellGapX ); } @@ -211,9 +213,9 @@ public class UILayoutBoxGridOffset01 { sxy, nextPos, cellGapX, font, 21, (final Group gp) -> { - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); }, minX, minY ); nextPos.setX( nextPos.x() + cellGapX ); } @@ -226,9 +228,9 @@ public class UILayoutBoxGridOffset01 { sxy, nextPos, cellGapX, font, 22, (final Group gp) -> { - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); }, minX, minY ); nextPos.setX( nextPos.x() + cellGapX ); } @@ -238,9 +240,9 @@ public class UILayoutBoxGridOffset01 { sxy, nextPos, cellGapX, font, 23, (final Group gp) -> { - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); }, minX, minY ); nextPos.setX( nextPos.x() + cellGapX ); } @@ -250,9 +252,9 @@ public class UILayoutBoxGridOffset01 { sxy, nextPos, cellGapX, font, 24, (final Group gp) -> { - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); }, minX, minY ); nextPos.setX( nextPos.x() + cellGapX ); } @@ -262,9 +264,9 @@ public class UILayoutBoxGridOffset01 { sxy, nextPos, cellGapX, font, 25, (final Group gp) -> { - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); - gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizeable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); + gp.addShape( new Rectangle(options.renderModes, minX, minY, width, height, lineWidth, 0).setDragAndResizable(false) ); }, minX, minY ); nextPos.setX( nextPos.x() + cellGapX ); } @@ -312,7 +314,7 @@ public class UILayoutBoxGridOffset01 { g.moveTo(sceneBox.getLow()).move(nextPos); System.err.println("Group-"+suffix+" "+g); System.err.println("Group-"+suffix+" Layout "+g.getLayout()); - g.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; }); + TreeTool.forAll(g, (shape) -> { System.err.println("Shape... "+shape); return false; }); scene.addShape(g); { final float X_width = font.getGlyph( ' ' ).getAdvanceWidth(); @@ -345,7 +347,7 @@ public class UILayoutBoxGridOffset01 { } final Shape label = new Label(options.renderModes, font, text).setColor(0, 0, 0, 1).validate(reqGLP); label.scale(l_sxy, l_sxy, 1).moveTo(sceneBox.getLow()).move(nextPos).move(l_sxy*X_width, g.getScaledHeight(), 0) - .addMouseListener(new Tooltips.ZoomLabelOnClickListener(scene, options.renderModes, 1/6f)).setDragAndResizeable(false); + .addMouseListener(new Tooltips.ZoomLabelOnClickListener(scene, options.renderModes, 1/6f)).setDragAndResizable(false); scene.addShape(label); } if( reLayout ) { @@ -354,7 +356,7 @@ public class UILayoutBoxGridOffset01 { g.validate(reqGLP); System.err.println("Group-"+suffix+".2 "+g); System.err.println("Group-"+suffix+" Layout.2 "+g.getLayout()); - g.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; }); + TreeTool.forAll(g, (shape) -> { System.err.println("Shape... "+shape); return false; }); } return g; } diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java index 9f7cf5873..e11cc396f 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java @@ -58,6 +58,8 @@ import com.jogamp.opengl.demos.graph.ui.util.Tooltips; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.util.Animator; +import jogamp.graph.ui.TreeTool; + /** * Res independent {@link Shape}s in a {@link Group} using a {@link GridLayout}, contained within a Scene attached to GLWindow. * <p> @@ -173,8 +175,8 @@ public class UILayoutGrid01 { sxy, nextPos, cellGap, font, 12, (final Group gp) -> { - gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r1 r1", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 r1", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); } ); nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap ); } @@ -185,8 +187,8 @@ public class UILayoutGrid01 { sxy, nextPos, cellGap, font, 13, (final Group gp) -> { - gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r1 c1", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 c1", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); } ); nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap ); } @@ -198,8 +200,8 @@ public class UILayoutGrid01 { font, 14, (final Group gp) -> { gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); } ); nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap ); @@ -212,10 +214,10 @@ public class UILayoutGrid01 { font, 15, (final Group gp) -> { gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); } ); nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap ); } @@ -227,10 +229,10 @@ public class UILayoutGrid01 { font, 16, (final Group gp) -> { gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); } ); nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap ); } @@ -247,10 +249,10 @@ public class UILayoutGrid01 { font, 21, (final Group gp) -> { gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); } ); nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap ); } @@ -262,10 +264,10 @@ public class UILayoutGrid01 { font, 22, (final Group gp) -> { gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); } ); nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap ); } @@ -277,10 +279,10 @@ public class UILayoutGrid01 { font, 23, (final Group gp) -> { gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); } ); nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap ); } @@ -294,10 +296,10 @@ public class UILayoutGrid01 { font, 24, (final Group gp) -> { gp.addShape( new Button(options.renderModes, font, "ro co", bw, bh, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r1 c2", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r2 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 c2", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r2 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); gp.addShape( new Button(options.renderModes, font, "r2 c2", bw, bh, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r3 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r3 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); } ); nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap ); } @@ -310,10 +312,10 @@ public class UILayoutGrid01 { font, 25, (final Group gp) -> { gp.addShape( new Button(options.renderModes, font, "ro co", bw, bh, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r1 c2", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r2 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 c2", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r2 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); gp.addShape( new Button(options.renderModes, font, "r2 c2", bw, bh, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r3 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r3 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); } ); nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap ); } @@ -328,10 +330,10 @@ public class UILayoutGrid01 { font, 31, (final Group gp) -> { final Group glyphGrid = new Group(new GridLayout(2, 0.3f, 0.3f, Alignment.Fill, new Gap(0.3f * 0.10f))); - glyphGrid.addShape( new Button(options.renderModes, font, "0.0", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - glyphGrid.addShape( new Button(options.renderModes, font, "0.1", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - glyphGrid.addShape( new Button(options.renderModes, font, "1.0", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); - glyphGrid.addShape( new Button(options.renderModes, font, "1.1", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + glyphGrid.addShape( new Button(options.renderModes, font, "0.0", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + glyphGrid.addShape( new Button(options.renderModes, font, "0.1", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + glyphGrid.addShape( new Button(options.renderModes, font, "1.0", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); + glyphGrid.addShape( new Button(options.renderModes, font, "1.1", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); gp.addShape(glyphGrid.setBorder(borderThickness)); final Group infoGrid = new Group(new GridLayout(1, 1/4f, 1/2.2f, Alignment.Fill, new Gap(0.02f))); @@ -339,12 +341,12 @@ public class UILayoutGrid01 { // glyphView.addShape(new Rectangle(options.renderModes, 1f, 1f, 0.005f).setInteractive(false)); // glyphView.addShape(new Button(options.renderModes, font, "S", 1f, 1f).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); // infoGrid.addShape(glyphView.setBorder(borderThickness)); - infoGrid.addShape(new Button(options.renderModes, font, " S ", 1/2f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + infoGrid.addShape(new Button(options.renderModes, font, " S ", 1/2f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); // final Group infoView = new Group(); // infoView.addShape(new Button(options.renderModes, font, "Info", 1f, 1f).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); // infoGrid.addShape(infoView.setBorder(borderThickness)); - infoGrid.addShape(new Button(options.renderModes, font, " Info ", 1/2f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); + infoGrid.addShape(new Button(options.renderModes, font, " Info ", 1/2f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) ); gp.addShape(infoGrid.setBorder(borderThickness)); // groupC0.addShape(new Button(options.renderModes, font, "S", 1/4f, 0.5f).setPerp().setBorder(borderThickness).setDragAndResizeable(false) ); } ); @@ -359,8 +361,8 @@ public class UILayoutGrid01 { font, 32, (final Group gp) -> { gp.addShape( new Button(options.renderModes, font, "ro co", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).addMouseListener(dragZoomRotateListener) ); - gp.addShape( new Button(options.renderModes, font, "r1 c2", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).setDragAndResizeable(false) ); - gp.addShape( new Button(options.renderModes, font, "r2 c1", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).setDragAndResizeable(false) ); + gp.addShape( new Button(options.renderModes, font, "r1 c2", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).setDragAndResizable(false) ); + gp.addShape( new Button(options.renderModes, font, "r2 c1", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).setDragAndResizable(false) ); gp.addShape( new Button(options.renderModes, font, "r2 c2", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).addMouseListener(dragZoomRotateListener) ); gp.addShape( new Button(options.renderModes, font, "r3 c1", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).addMouseListener(dragZoomRotateListener) ); } ); @@ -403,7 +405,7 @@ public class UILayoutGrid01 { g.moveTo(sceneBox.getLow()).move(nextPos); System.err.println("Group-"+suffix+" "+g); System.err.println("Group-"+suffix+" Layout "+g.getLayout()); - g.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; }); + TreeTool.forAll(g, (shape) -> { System.err.println("Shape... "+shape); return false; }); scene.addShape(g); { final float X_width = font.getGlyph( ' ' ).getAdvanceWidth(); @@ -423,7 +425,7 @@ public class UILayoutGrid01 { l.getAlignment() ); final Shape label = new Label(options.renderModes, font, text).setColor(0, 0, 0, 1).validate(reqGLP); label.scale(l_sxy, l_sxy, 1).moveTo(sceneBox.getLow()).move(nextPos).move(l_sxy*X_width, g.getScaledHeight(), 0) - .addMouseListener(new Tooltips.ZoomLabelOnClickListener(scene, options.renderModes, 1/6f)).setDragAndResizeable(false); + .addMouseListener(new Tooltips.ZoomLabelOnClickListener(scene, options.renderModes, 1/6f)).setDragAndResizable(false); scene.addShape(label); } if( reLayout ) { @@ -432,7 +434,7 @@ public class UILayoutGrid01 { g.validate(reqGLP); System.err.println("Group-"+suffix+".2 "+g); System.err.println("Group-"+suffix+" Layout.2 "+g.getLayout()); - g.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; }); + TreeTool.forAll(g, (shape) -> { System.err.println("Shape... "+shape); return false; }); } return g; } diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid00.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid00.java index c41604af0..fec507d3c 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid00.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid00.java @@ -47,9 +47,11 @@ import com.jogamp.graph.ui.shapes.MediaButton; import com.jogamp.graph.ui.shapes.Rectangle; import com.jogamp.graph.ui.widgets.MediaPlayer; import com.jogamp.math.Vec2i; +import com.jogamp.math.Vec3f; import com.jogamp.math.geom.AABBox; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; @@ -63,6 +65,8 @@ import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayerFactory; +import jogamp.graph.ui.TreeTool; + /** * MediaButtons in a grid, filled by media files from a directory in different aspect ratios */ @@ -223,8 +227,8 @@ public class UIMediaGrid00 { fontSymbols.getUTF16String("reset_tv"), MediaPlayer.CtrlButtonWidth, MediaPlayer.CtrlButtonHeight, scene.getZEpsilon(16)); button.setName("reset"); button.setSpacing(MediaPlayer.SymSpacing, MediaPlayer.FixedSymSize).setPerp().setColor(MediaPlayer.CtrlCellCol); - button.onClicked((final Shape s0) -> { - scene.forAll((final Shape s1) -> { + button.onClicked((final Shape s0, final Vec3f pos, final MouseEvent e) -> { + TreeTool.forAll(scene, (final Shape s1) -> { System.err.println("- "+s1.getName()); if( s1 instanceof MediaButton ) { final MediaButton mb = (MediaButton)s1; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java index 60366ac45..9dfbca91c 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java @@ -54,14 +54,17 @@ import com.jogamp.graph.ui.shapes.MediaButton; import com.jogamp.graph.ui.shapes.Rectangle; import com.jogamp.graph.ui.widgets.MediaPlayer; import com.jogamp.graph.ui.widgets.RangeSlider; -import com.jogamp.graph.ui.widgets.RangeSlider.SliderAdapter; +import com.jogamp.graph.ui.widgets.RangeSlider.SliderListener; import com.jogamp.graph.ui.widgets.RangedGroup; import com.jogamp.graph.ui.widgets.RangedGroup.SliderParam; import com.jogamp.math.Vec2f; import com.jogamp.math.Vec2i; +import com.jogamp.math.Vec3f; import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; @@ -77,6 +80,8 @@ import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayerFactory; +import jogamp.graph.ui.TreeTool; + /** * MediaButtons in a {@link RangedGroup} w/ vertical slider, filled by media files from a directory. */ @@ -260,7 +265,7 @@ public class UIMediaGrid01 { { final Group mediaGrid = new Group(new GridLayout(gridDim.x(), mediaCellWidth*0.9f, mediaCellHeight*0.9f, Alignment.FillCenter, new Gap(mediaCellHeight*0.1f, mediaCellWidth*0.1f))); - mediaGrid.setInteractive(true).setDragAndResizeable(false).setToggleable(false).setName("MediaGrid"); + mediaGrid.setInteractive(false).setDragAndResizable(false).setToggleable(false).setName("MediaGrid"); addMedia(scene, reqCaps.getGLProfile(), mediaGrid, mediaFiles, videoAspectRatio); mediaGrid.setRelayoutOnDirtyShapes(false); // avoid group re-validate to ease load in Group.isShapeDirty() w/ thousands of glyphs if( VERBOSE_UI ) { @@ -275,7 +280,7 @@ public class UIMediaGrid01 { mediaView.getVertSlider().setColor(0.3f, 0.3f, 0.3f, 0.7f).setName("MediaView"); // mediaView.setRelayoutOnDirtyShapes(false); // avoid group re-validate to ease load in Group.isShapeDirty() w/ thousands of glyphs if( VERBOSE_UI ) { - mediaView.getVertSlider().addSliderListener(new SliderAdapter() { + mediaView.getVertSlider().addSliderListener(new SliderListener() { @Override public void dragged(final RangeSlider w, final float old_val, final float val, final float old_val_pct, final float val_pct) { final Vec2f minmax = w.getMinMax(); @@ -317,6 +322,15 @@ public class UIMediaGrid01 { printScreenOnGLThread(scene, window.getChosenGLCapabilities()); } else if( keySym == KeyEvent.VK_F4 || keySym == KeyEvent.VK_ESCAPE || keySym == KeyEvent.VK_Q ) { MiscUtils.destroyWindow(window); + } else if( keySym == KeyEvent.VK_D ) { + final PMVMatrix4f pmv = new PMVMatrix4f(); + scene.setupMatrix(pmv); + final int[] shapeIdx = { 0 }; + TreeTool.forAllRendered(scene, false, pmv, (final Shape s, final PMVMatrix4f pmv_) -> { + ++shapeIdx[0]; + System.err.printf("%03d: shape %s/%s, %s%n", shapeIdx[0], s.getClass().getSimpleName(), s.getName(), s); + return false; + }); } } }); @@ -366,8 +380,8 @@ public class UIMediaGrid01 { fontSymbols.getUTF16String("reset_tv"), MediaPlayer.CtrlButtonWidth, MediaPlayer.CtrlButtonHeight, scene.getZEpsilon(16)); button.setName("reset"); button.setSpacing(MediaPlayer.SymSpacing, MediaPlayer.FixedSymSize).setPerp().setColor(MediaPlayer.CtrlCellCol); - button.onClicked((final Shape s0) -> { - scene.forAll((final Shape s1) -> { + button.onClicked((final Shape s0, final Vec3f pos, final MouseEvent e) -> { + TreeTool.forAll(scene, (final Shape s1) -> { System.err.println("- "+s1.getName()); if( s1 instanceof MediaButton ) { final MediaButton mb = (MediaButton)s1; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java index 7e15a7991..07f3960b9 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java @@ -81,6 +81,8 @@ import com.jogamp.opengl.util.av.GLMediaPlayerFactory; import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; +import jogamp.graph.ui.TreeTool; + /** * Res independent Shape, Scene attached to GLWindow showing multiple animated shape movements. * <p> @@ -712,7 +714,7 @@ public class UISceneDemo03 { } } ); buttonsRight.addShape(button); } - buttonsRight.forAll((final Shape s) -> { s.setDragAndResizeable(false); return false; }); + TreeTool.forAll(buttonsRight, (final Shape s) -> { s.setDragAndResizable(false); return false; }); buttonsRight.validate(window.getChosenGLCapabilities().getGLProfile()); buttonsRight.moveTo(sceneBox.getWidth()/2f - buttonsRight.getScaledWidth()*1.02f, sceneBox.getHeight()/2f - buttonsRight.getScaledHeight()*1.02f, 0f); diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java index acf3a5699..8e6e51aed 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java @@ -52,6 +52,8 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.util.Animator; +import jogamp.graph.ui.TreeTool; + /** * Res independent {@link Shape}s in a {@link Group} using a {@link GridLayout}, contained within a Scene attached to GLWindow. * <p> @@ -84,17 +86,17 @@ public class UISceneDemo11 { final Group groupA0 = new Group(new GridLayout(2, 1f, 1/2f, Alignment.Fill, new Gap(0.10f))); { - groupA0.addShape( new Button(options.renderModes, font, "r1 c1", 1f, 1f/2f).setPerp().setDragAndResizeable(false) ); - groupA0.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f).setPerp().setDragAndResizeable(false) ); - groupA0.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f).setPerp().setDragAndResizeable(false) ); - groupA0.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f).setPerp().setDragAndResizeable(false) ); + groupA0.addShape( new Button(options.renderModes, font, "r1 c1", 1f, 1f/2f).setPerp().setDragAndResizable(false) ); + groupA0.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f).setPerp().setDragAndResizable(false) ); + groupA0.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f).setPerp().setDragAndResizable(false) ); + groupA0.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f).setPerp().setDragAndResizable(false) ); } groupA0.setInteractive(true); groupA0.scale(1/8f, 1/8f, 1); groupA0.validate(reqCaps.getGLProfile()); System.err.println("Group-A0 "+groupA0); System.err.println("Group-A0 Layout "+groupA0.getLayout()); - groupA0.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; }); + TreeTool.forAll(groupA0, (shape) -> { System.err.println("Shape... "+shape); return false; }); final Scene scene = new Scene(options.graphAASamples); scene.setPMVMatrixSetup(new MyPMVMatrixSetup()); @@ -135,7 +137,7 @@ public class UISceneDemo11 { final AABBox sceneBox = scene.getBounds(); System.err.println("SceneBox "+sceneBox); System.err.println("Group-A0 "+groupA0); - groupA0.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; }); + TreeTool.forAll(groupA0, (shape) -> { System.err.println("Shape... "+shape); return false; }); groupA0.moveTo(0, sceneBox.getMinY(), 0f); // move shape to min start position try { Thread.sleep(1000); } catch (final InterruptedException e1) { } @@ -189,7 +191,7 @@ public class UISceneDemo11 { final float has_dur_s = ( ( Clock.currentNanos() / 1000 ) - t0_us ) / 1e6f; // [us] System.err.printf("Actual travel-duration %.3f s, delay %.3f s%n", has_dur_s, has_dur_s-exp_dur_s); System.err.println("Group-A0 bounds "+groupA0); - groupA0.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; }); + TreeTool.forAll(groupA0, (shape) -> { System.err.println("Shape... "+shape); return false; }); try { Thread.sleep(1000); } catch (final InterruptedException e1) { } } if( !options.stayOpen ) { 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 b5a70bda5..8e466dbe5 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java @@ -98,6 +98,8 @@ import com.jogamp.opengl.util.caps.NonFSAAGLCapsChooser; import com.jogamp.opengl.util.texture.ImageSequence; import com.jogamp.opengl.util.texture.TextureIO; +import jogamp.graph.ui.TreeTool; + /** * Complex interactive GraphUI Scene demo with different Button and Label Shapes layout on the screen. * <p> @@ -1040,8 +1042,8 @@ public class UISceneDemo20 implements GLEventListener { final float sceneHeight = sceneBox.getHeight(); final float button_sxy = sceneWidth > sceneHeight ? sceneWidth : sceneHeight; - buttonsLeft.forAll((final Shape s) -> { if( s instanceof Button) { ((Button)s).setLabelZOffset(zEpsilon); } return false; } ); - buttonsRight.forAll((final Shape s) -> { if( s instanceof Button) { ((Button)s).setLabelZOffset(zEpsilon); } return false; } ); + TreeTool.forAll(buttonsLeft, (final Shape s) -> { if( s instanceof Button) { ((Button)s).setLabelZOffset(zEpsilon); } return false; } ); + TreeTool.forAll(buttonsRight, (final Shape s) -> { if( s instanceof Button) { ((Button)s).setLabelZOffset(zEpsilon); } return false; } ); buttonsLeft.validate(drawable.getGL().getGL2ES2()); buttonsRight.validate(drawable.getGL().getGL2ES2()); diff --git a/src/graphui/classes/com/jogamp/graph/ui/Container.java b/src/graphui/classes/com/jogamp/graph/ui/Container.java index 82f2fda4f..106ffcfe9 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Container.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Container.java @@ -147,55 +147,4 @@ public interface Container { * @see Shape#isOutside() */ public boolean isOutside2(final Matrix4f mvCont, final Shape shape, final PMVMatrix4f pmvShape); - - /** - * Traverses through the graph up until {@code shape} of {@link Container#getShapes()} and apply {@code action} on it. - * @param pmv - * @param shape - * @param action - * @return true to signal operation complete, i.e. {@code shape} found, otherwise false - */ - boolean forOne(final PMVMatrix4f pmv, final Shape shape, final Runnable action); - - /** - * Traverses through the graph and apply {@link Visitor1#visit(Shape)} for each {@link Shape} of {@link Container#getShapes()}, - * stops if it returns true. - * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor1#visit(Shape)} returned true, otherwise false - */ - boolean forAll(Visitor1 v); - - /** - * Traverses through the graph and apply {@link Visitor2#visit(Shape, PMVMatrix4f)} for each {@link Shape} of {@link Container#getShapes()}, - * stops if it returns true. - * @param pmv - * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false - */ - boolean forAll(final PMVMatrix4f pmv, Visitor2 v); - - /** - * Traverses through the graph and apply {@link Visitor2#visit(Shape, PMVMatrix4f)} for each {@link Shape} of {@link Container#getShapes()}, - * stops if it returns true. - * - * Each {@link Container} level is sorted using {@code sortComp} - * @param sortComp - * @param pmv - * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false - */ - boolean forSortedAll(final Comparator<Shape> sortComp, final PMVMatrix4f pmv, final Visitor2 v); - - /** - * Traverses through the graph and apply {@link Visitor2#visit(Shape, PMVMatrix4f)} for each {@link Shape} of {@link Container#getRenderedShapes()}, - * stops if it returns true. - * <p> - * Each {@link Container} level is sorted using {@code sortComp} - * </p> - * @param sortComp - * @param pmv - * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false - */ - public boolean forAllRendered(final Comparator<Shape> sortComp, final PMVMatrix4f pmv, final Visitor2 v); } diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java index 4e10d071f..c44fbe110 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Group.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java @@ -98,7 +98,7 @@ public class Group extends Shape implements Container { /** * Create a group of {@link Shape}s w/o {@link Group.Layout}. * <p> - * Default is non-interactive, see {@link #setInteractive(boolean)}. + * Default is {@link #setInteractive(boolean) non-interactive}. * </p> */ public Group() { @@ -108,7 +108,7 @@ public class Group extends Shape implements Container { /** * Create a group of {@link Shape}s w/ given {@link Group.Layout}. * <p> - * Default is non-interactive, see {@link #setInteractive(boolean)}. + * Default is {@link #setInteractive(boolean) non-interactive}. * </p> * @param l optional {@link Layout}, maybe {@code null} */ @@ -119,7 +119,7 @@ public class Group extends Shape implements Container { /** * Create a group of {@link Shape}s w/ given {@link Group.Layout} and {@link Shape}. * <p> - * Default is non-interactive, see {@link #setInteractive(boolean)}. + * Default is {@link #setInteractive(boolean) non-interactive}. * </p> * @param name optional name for {@link #setName(String)} * @param l optional {@link Layout}, maybe {@code null} @@ -488,7 +488,7 @@ public class Group extends Shape implements Container { public boolean getRelayoutOnDirtyShapes() { return relayoutOnDirtyShapes; } /** - * Toggles widget behavior for this group and all its elements, default is disabled. + * Toggles widget behavior for this group, default is disabled. * <p> * Enabled widget behavior for a group causes * <ul> @@ -515,8 +515,8 @@ public class Group extends Shape implements Container { protected final void enableUniActivationImpl(final boolean v, final Listener activationListener) { for(final Shape s : shapes ) { if( s.isGroup() ) { - final Group sg = (Group)s; - sg.setWidgetMode(v); + // ((Group)s).enableUniActivationImpl(v, activationListener); + ((Group)s).setWidgetMode(v); } s.addActivationListener(activationListener); } @@ -527,14 +527,14 @@ public class Group extends Shape implements Container { @Override public boolean isActive() { - return super.isActive() || ( widgetMode && forAll((final Shape gs) -> { return gs.isActive(); } ) ); + return super.isActive() || ( widgetMode && TreeTool.forAll(this, (final Shape gs) -> { return gs.isActive(); } ) ); } @Override public float getAdjustedZ() { final float[] v = { getAdjustedZImpl() }; if( widgetMode && !super.isActive() ) { - forAll((final Shape gs) -> { + TreeTool.forAll(this, (final Shape gs) -> { if( gs.isActive() ) { v[0] = gs.getAdjustedZImpl(); return true; @@ -687,7 +687,7 @@ public class Group extends Shape implements Container { if( null == shape ) { return res; } - forOne(pmv, shape, () -> { + TreeTool.forOne(this, pmv, shape, () -> { shape.getBounds().transform(pmv.getMv(), res); }); return res; @@ -697,30 +697,5 @@ public class Group extends Shape implements Container { public String getSubString() { return super.getSubString()+", shapes "+shapes.size(); } - - @Override - public boolean forOne(final PMVMatrix4f pmv, final Shape shape, final Runnable action) { - return TreeTool.forOne(this, pmv, shape, action); - } - - @Override - public boolean forAll(final Visitor1 v) { - return TreeTool.forAll(this, v); - } - - @Override - public boolean forAll(final PMVMatrix4f pmv, final Visitor2 v) { - return TreeTool.forAll(this, pmv, v); - } - - @Override - public boolean forSortedAll(final Comparator<Shape> sortComp, final PMVMatrix4f pmv, final Visitor2 v) { - return TreeTool.forSortedAll(this, sortComp, pmv, v); - } - - @Override - public boolean forAllRendered(final Comparator<Shape> sortComp, final PMVMatrix4f pmv, final Visitor2 v) { - return TreeTool.forAllRendered(this, pmv, v); - } } diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java index 7f47b2d98..31c45359d 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java @@ -378,7 +378,7 @@ public final class Scene implements Container, GLEventListener { public int setAAQuality(final int v) { return renderer.setAAQuality(v); /* markStatesDirty() -> autodetected within GLRegion.draw(..) */ } public void setSharpness(final float sharpness) { - forAll((final Shape s) -> { + TreeTool.forAll(this, (final Shape s) -> { if( s instanceof GraphShape ) { ((GraphShape)s).setSharpness(sharpness); } @@ -386,13 +386,13 @@ public final class Scene implements Container, GLEventListener { }); } public void markShapesDirty() { - forAll((final Shape s) -> { + TreeTool.forAll(this, (final Shape s) -> { s.markShapeDirty(); return false; }); } public void markStatesDirty() { - forAll((final Shape s) -> { + TreeTool.forAll(this, (final Shape s) -> { s.markStateDirty(); return false; }); @@ -783,7 +783,7 @@ public final class Scene implements Container, GLEventListener { } final Recti viewport = getViewport(); setupMatrix(pmv); - forOne(pmv, shape, () -> { + TreeTool.forOne(this, pmv, shape, () -> { if( null != shape.winToShapeCoord(pmv, viewport, glWinX, glWinY, objPos) ) { runnable.run(); } @@ -797,65 +797,13 @@ public final class Scene implements Container, GLEventListener { return res; } setupMatrix(pmv); - forOne(pmv, shape, () -> { + TreeTool.forOne(this, pmv, shape, () -> { shape.getBounds().transform(pmv.getMv(), res); }); return res; } /** - * Traverses through the graph up until {@code shape} and apply {@code action} on it. - * @param pmv {@link PMVMatrix4f}, which shall be properly initialized, e.g. via {@link Scene#setupMatrix(PMVMatrix4f)} - * @param shape - * @param action - * @return true to signal operation complete, i.e. {@code shape} found, otherwise false - */ - @Override - public boolean forOne(final PMVMatrix4f pmv, final Shape shape, final Runnable action) { - return TreeTool.forOne(this, pmv, shape, action); - } - - /** - * Traverses through the graph and apply {@link Visitor2#visit(Shape, PMVMatrix4f)} for each, stop if it returns true. - * @param pmv {@link PMVMatrix4f}, which shall be properly initialized, e.g. via {@link Scene#setupMatrix(PMVMatrix4f)} - * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false - */ - @Override - public boolean forAll(final PMVMatrix4f pmv, final Visitor2 v) { - return TreeTool.forAll(this, pmv, v); - } - - /** - * Traverses through the graph and apply {@link Visitor1#visit(Shape)} for each, stop if it returns true. - * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor1#visit(Shape)} returned true, otherwise false - */ - @Override - public boolean forAll(final Visitor1 v) { - return TreeTool.forAll(this, v); - } - - /** - * Traverses through the graph and apply {@link Visitor2#visit(Shape, PMVMatrix4f)} for each, stop if it returns true. - * - * Each {@link Container} level is sorted using {@code sortComp} - * @param sortComp - * @param pmv - * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false - */ - @Override - public boolean forSortedAll(final Comparator<Shape> sortComp, final PMVMatrix4f pmv, final Visitor2 v) { - return TreeTool.forSortedAll(this, sortComp, pmv, v); - } - - @Override - public boolean forAllRendered(final Comparator<Shape> sortComp, final PMVMatrix4f pmv, final Visitor2 v) { - return TreeTool.forAllRendered(this, pmv, v); - } - - /** * Interface providing {@link #set(PMVMatrix4f, Recti) a method} to * setup {@link PMVMatrix4f}'s {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW}. * <p> @@ -1272,7 +1220,7 @@ public final class Scene implements Container, GLEventListener { private void activateTooltipImpl(final GLAutoDrawable drawable, final PMVMatrix4f pmv, final Tooltip tt) { if( null == toolTipHUD.get() ) { final Shape[] hud = { null }; - if( tt.tick() && forOne(pmv, tt.getTool(), () -> { + if( tt.tick() && TreeTool.forOne(this, pmv, tt.getTool(), () -> { final AABBox toolMvBounds = tt.getToolMvBounds(pmv); hud[0] = tt.createTip(drawable, Scene.this, pmv, toolMvBounds); }) ) diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java index 1527f0fd0..d7c91ed2f 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java @@ -124,6 +124,19 @@ public abstract class Shape { } /** + * {@link Shape} pointer listener, e.g. for {@link Shape#onClicked(PointerListener)} + */ + public static interface PointerListener { + /** + * Event callback + * @param s the associated {@link Shape} for this event + * @param pos relative object coordinates to the associated {@link Shape} + * @param e original Newt {@link MouseEvent} + */ + void run(Shape s, final Vec3f pos, MouseEvent e); + } + + /** * General {@link Shape} listener action */ public static interface Listener { @@ -257,12 +270,12 @@ public abstract class Shape { private static final int IO_RESIZABLE = 1 << 5; private static final int IO_RESIZE_FIXED_RATIO = 1 << 6; private static final int IO_ACTIVE = 1 << 7; - private static final int IO_DOWN = 1 << 8; - private static final int IO_TOGGLE = 1 << 9; - private static final int IO_DRAG_FIRST = 1 << 10; - private static final int IO_IN_MOVE = 1 << 11; - private static final int IO_IN_RESIZE_BR = 1 << 12; - private static final int IO_IN_RESIZE_BL = 1 << 13; + private static final int IO_DOWN = 1 << 26; + private static final int IO_TOGGLE = 1 << 27; + private static final int IO_DRAG_FIRST = 1 << 28; + private static final int IO_IN_MOVE = 1 << 29; + private static final int IO_IN_RESIZE_BR = 1 << 30; + private static final int IO_IN_RESIZE_BL = 1 << 31; private volatile int ioState = IO_DRAGGABLE | IO_RESIZABLE | IO_INTERACTIVE | IO_ACTIVABLE | IO_VISIBLE; private final boolean isIO(final int mask) { return mask == ( ioState & mask ); } private final Shape setIO(final int mask, final boolean v) { if( v ) { ioState |= mask; } else { ioState &= ~mask; } return this; } @@ -274,10 +287,11 @@ public abstract class Shape { private ArrayList<KeyListener> keyListeners = new ArrayList<KeyListener>(); private ListenerBool onInitListener = null; + private PointerListener onHoverListener = null; private MoveListener onMoveListener = null; private Listener onToggleListener = null; private ArrayList<Listener> activationListeners = new ArrayList<Listener>(); - private Listener onClickedListener = null; + private PointerListener onClickedListener = null; private final Vec2f objDraggedFirst = new Vec2f(); // b/c its relative to Shape and we stick to it private final int[] winDraggedLast = { 0, 0 }; // b/c its absolute window pos @@ -417,6 +431,7 @@ public abstract class Shape { onToggleListener = null; activationListeners.clear(); onClickedListener = null; + onHoverListener = null; markShapeDirty(); } @@ -442,19 +457,31 @@ public abstract class Shape { */ public final void onInit(final ListenerBool l) { onInitListener = l; } /** + * Set user callback to be notified when a pointer/mouse is moving over this shape + */ + public final void onHover(final PointerListener l) { onHoverListener = l; } + /** * Set user callback to be notified when shape is {@link #move(Vec3f)}'ed. */ public final void onMove(final MoveListener 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)}. + * This is usually the case when clicked, see {@link #onClicked(PointerListener)}. * </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 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 PointerListener l) { onClickedListener = l; } /** * Add user callback to be notified when shape is activated (pointer-over and/or click) or de-activated (pointer left). @@ -493,15 +520,6 @@ public abstract class Shape { } } - /** - * 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. No {@link MoveListener} notification will occur. */ public final Shape moveTo(final float tx, final float ty, final float tz) { position.set(tx, ty, tz); @@ -1505,13 +1523,13 @@ public abstract class Shape { } else { rotateS = ""; } - final String activeS = isIO(IO_ACTIVE) ? ", active" : ""; + final String activeS = ", active["+(isIO(IO_ACTIVE) ? "SELF," : "")+(isGroup() && isActive()?"GROUP":"")+"]"; final String ps = hasPadding() ? padding.toString()+", " : ""; final String bs = hasBorder() ? "border[l "+getBorderThickness()+", c "+getBorderColor()+"], " : ""; final String idS = -1 != id ? ", id "+id : ""; final String nameS = "noname" != name ? ", '"+name+"'" : ""; return getDirtyString()+idS+nameS+", visible "+isIO(IO_VISIBLE)+activeS+", toggle "+isIO(IO_TOGGLE)+ - ", able[toggle "+isIO(IO_TOGGLEABLE)+", iactive "+isInteractive()+", resize "+isResizable()+", move "+this.isDraggable()+ + ", able[toggle "+isIO(IO_TOGGLEABLE)+", iactive "+isInteractive()+", resize "+isResizable()+", drag "+this.isDraggable()+ "], pos["+position+"], "+pivotS+scaleS+rotateS+iMatS+ ps+bs+"box"+box; } @@ -1671,7 +1689,7 @@ public abstract class Shape { * @see #isVisible() * @see #setDraggable(boolean) * @see #setResizable(boolean) - * @see #setDragAndResizeable(boolean) + * @see #setDragAndResizable(boolean) */ public final Shape setInteractive(final boolean v) { return setIO(IO_INTERACTIVE, v); } /** @@ -1702,7 +1720,7 @@ public abstract class Shape { * @see #isDraggable() * @see #setInteractive(boolean) * @see #setResizable(boolean) - * @see #setDragAndResizeable(boolean) + * @see #setDragAndResizable(boolean) */ public final Shape setDraggable(final boolean draggable) { return setIO(IO_DRAGGABLE, draggable); } /** @@ -1720,12 +1738,12 @@ public abstract class Shape { * @see #isResizable() * @see #setInteractive(boolean) * @see #setDraggable(boolean) - * @see #setDragAndResizeable(boolean) + * @see #setDragAndResizable(boolean) */ public final Shape setResizable(final boolean resizable) { return setIO(IO_RESIZABLE, resizable); } /** - * Returns if this shape is resiable, a user interaction. + * Returns if this shape is resizable, a user interaction. * @see #setResizable(boolean) */ public final boolean isResizable() { return isIO(IO_RESIZABLE); } @@ -1754,7 +1772,7 @@ public abstract class Shape { * @see #setDraggable(boolean) * @see #setResizable(boolean) */ - public final Shape setDragAndResizeable(final boolean v) { + public final Shape setDragAndResizable(final boolean v) { setDraggable(v); setResizable(v); return this; diff --git a/src/graphui/classes/com/jogamp/graph/ui/TooltipShape.java b/src/graphui/classes/com/jogamp/graph/ui/TooltipShape.java index e627d671f..f8152635d 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/TooltipShape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/TooltipShape.java @@ -43,6 +43,8 @@ import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.util.texture.TextureSequence; +import jogamp.graph.ui.TreeTool; + /** A HUD {@link Shape} {@link Tooltip} for {@link Shape}, see {@link Shape#setToolTip(Tooltip)}. */ public class TooltipShape extends Tooltip { /** @@ -169,7 +171,7 @@ public class TooltipShape extends Tooltip { final Group tipWrapper = (Group)tipGroup.getShapeByIdx(1); if( null == tipWrapper.removeShape(tip) ) { System.err.println("TooltipShape.destroyTip: Warning: Tip "+tip.getName()+" not contained in "+tipWrapper.getName()+"; Internal Group: "); - tipGroup.forAll((final Shape s) -> { + TreeTool.forAll(tipGroup, (final Shape s) -> { System.err.println("- "+s.getName()); return false; }); diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java index 0a501f3db..486ba8067 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java @@ -149,14 +149,11 @@ public class Button extends BaseButton { @Override protected void toggleNotify(final boolean on) { - int i=0; if( null != labelOn ) { if( on ) { labelNow = labelOn; - i = 1; } else { labelNow = labelOff; - i = -1; } markShapeDirty(); } diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/MediaButton.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/MediaButton.java index 89d598d4e..3ba2a039a 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/MediaButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/MediaButton.java @@ -146,7 +146,7 @@ public class MediaButton extends TexSeqButton { setSubtitleColor(DEFAULT_ASS_SUB_COLOR, DEFAULT_ASS_SUB_BLEND); this.subTexImg = new ImageButton(renderModes, width, height, new ImageSequence(mPlayer.getTextureUnit(), true /* useBuildInTexLookup */)); - this.subTexImg.setPerp().setToggleable(false).setDragAndResizeable(false).setInteractive(false); + this.subTexImg.setPerp().setToggleable(false).setDragAndResizable(false).setInteractive(false); // this.subTexImg.setBorder(0.001f).setBorderColor(1, 1, 0, 1); this.subTexImg.getImageSequence().setParams(GL.GL_LINEAR, GL.GL_LINEAR, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); this.subTexImg.setARatioAdjustment(false); diff --git a/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java b/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java index fd4cd726f..ce810b3ef 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java +++ b/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java @@ -27,6 +27,7 @@ */ package com.jogamp.graph.ui.widgets; +import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.concurrent.atomic.AtomicReference; @@ -52,7 +53,7 @@ import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.Label; import com.jogamp.graph.ui.shapes.MediaButton; import com.jogamp.graph.ui.shapes.Rectangle; -import com.jogamp.graph.ui.widgets.RangeSlider.SliderAdapter; +import com.jogamp.graph.ui.widgets.RangeSlider.SliderListener; import com.jogamp.math.FloatUtil; import com.jogamp.math.Vec2f; import com.jogamp.math.Vec3f; @@ -70,6 +71,8 @@ import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException; import com.jogamp.opengl.util.texture.TextureSequence; +import jogamp.graph.ui.TreeTool; + /** * Media player {@link Widget}, embedding a {@link MediaButton} and its controls. * @see #MediaPlayer(int, Scene, GLMediaPlayer, Uri, int, float, boolean, float, List) @@ -620,7 +623,7 @@ public class MediaPlayer extends Widget { mButton.setPressedColorMod(1f, 1f, 1f, 0.85f); } } ); - this.forAll((final Shape s) -> { s.setDraggable(false).setResizable(false); return false; }); + TreeTool.forAll(this, (final Shape s) -> { s.setDraggable(false).setResizable(false); return false; }); ctrlSlider.getKnob().setDraggable(true); } diff --git a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangeSlider.java b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangeSlider.java index 0970c6c4e..b2693da3d 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangeSlider.java +++ b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangeSlider.java @@ -62,12 +62,6 @@ public final class RangeSlider extends Widget { * {@link RangeSlider} slider listener */ public static interface SliderListener { - /** Slider clicked by user (after completing pressed + released). */ - void clicked(RangeSlider w, final MouseEvent e); - /** Slider pressed down by user. */ - void pressed(RangeSlider w, final MouseEvent e); - /** Slider released down by user. */ - void released(RangeSlider w, final MouseEvent e); /** * Slide dragged by user (including clicked position) * @param w the {@link RangeSlider} widget owning the slider @@ -78,16 +72,6 @@ public final class RangeSlider extends Widget { */ void dragged(RangeSlider w, float old_val, float val, float old_val_pct, float val_pct); } - public static abstract class SliderAdapter implements SliderListener { - @Override - public void clicked(final RangeSlider w, final MouseEvent e) { } - @Override - public void pressed(final RangeSlider w, final MouseEvent e) { } - @Override - public void released(final RangeSlider w, final MouseEvent e) { } - @Override - public void dragged(final RangeSlider w, final float old_val, final float val, final float old_val_pct, final float val_pct) { } - }; private static interface SliderAction { public void run(SliderListener l); } 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 307b66863..4be829048 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java +++ b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java @@ -34,7 +34,7 @@ import com.jogamp.graph.ui.Group; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.layout.Alignment; import com.jogamp.graph.ui.layout.GridLayout; -import com.jogamp.graph.ui.widgets.RangeSlider.SliderAdapter; +import com.jogamp.graph.ui.widgets.RangeSlider.SliderListener; import com.jogamp.math.Vec2f; import com.jogamp.math.Vec3f; import com.jogamp.math.Vec4f; @@ -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.addSliderListener( new SliderAdapter() { + horizSlider.addSliderListener( new SliderListener() { @Override public void dragged(final RangeSlider w, final float old_val, final float val, final float old_val_pct, final float val_pct) { final Vec3f oldPos = content.getPosition(); @@ -122,7 +122,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.addSliderListener( new SliderAdapter() { + vertSlider.addSliderListener( new SliderListener() { @Override public void dragged(final RangeSlider w, final float old_val, final float val, final float old_val_pct, final float val_pct) { final Vec3f oldPos = content.getPosition(); diff --git a/src/graphui/classes/jogamp/graph/ui/TreeTool.java b/src/graphui/classes/jogamp/graph/ui/TreeTool.java index 1a12ff461..d80a6c103 100644 --- a/src/graphui/classes/jogamp/graph/ui/TreeTool.java +++ b/src/graphui/classes/jogamp/graph/ui/TreeTool.java @@ -160,11 +160,19 @@ public class TreeTool { * Each {@link Container} level is sorted using {@code sortComp} * </p> * @param cont container of the shapes + * @param ascnZOrder if {@code true}, traverse through {@link Container#getRenderedShapes()} in ascending z-axis order (bottom-up), otherwise descending (top-down) * @param pmv * @param v * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false */ - public static boolean forAllRendered(final Container cont, final PMVMatrix4f pmv, final Visitor2 v) { + public static boolean forAllRendered(final Container cont, final boolean ascnZOrder, final PMVMatrix4f pmv, final Visitor2 v) { + if( ascnZOrder ) { + return forAllRenderedAscn(cont, pmv, v); + } else { + return forAllRenderedDesc(cont, pmv, v); + } + } + private static boolean forAllRenderedAscn(final Container cont, final PMVMatrix4f pmv, final Visitor2 v) { final List<Shape> shapes = cont.getRenderedShapes(); boolean res = false; @@ -175,7 +183,24 @@ public class TreeTool { res = v.visit(s, pmv); if( !res && s instanceof Container ) { final Container c = (Container)s; - res = forAllRendered(c, pmv, v); + res = forAllRenderedAscn(c, pmv, v); + } + pmv.popMv(); + } + return res; + } + private static boolean forAllRenderedDesc(final Container cont, final PMVMatrix4f pmv, final Visitor2 v) { + final List<Shape> shapes = cont.getRenderedShapes(); + boolean res = false; + + for(int i=shapes.size()-1; !res && i>=0; --i) { + final Shape s = shapes.get(i); + pmv.pushMv(); + s.applyMatToMv(pmv); + res = v.visit(s, pmv); + if( !res && s instanceof Container ) { + final Container c = (Container)s; + res = forAllRenderedDesc(c, pmv, v); } pmv.popMv(); } |