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 /src/demos | |
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.
Diffstat (limited to 'src/demos')
9 files changed, 119 insertions, 89 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()); |