From c65c750e032118f229050ff8e834961264ed0591 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 18 Apr 2023 05:15:16 +0200 Subject: Graph + GraphUI: Consolidate Vertex: Drop SVertex and factory, use Vec[234]f instead of float[] and remove unused VectorUtil methods After Matrix4f consolidation and proving same or better performance on non array types, this enhances code readability, simplifies API, reduces bugs and may improve performance. GraphUI: - Have RoundButton as a functional class to make a round or rectangular backdrop, i.e. impl. addShapeToRegion() via reused addRoundShapeToRegion() --- .../classes/com/jogamp/graph/ui/shapes/Button.java | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java') 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 e8b0be863..0f754d32a 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java @@ -37,6 +37,7 @@ import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.GraphShape; import com.jogamp.opengl.math.Vec2f; import com.jogamp.opengl.math.Vec3f; +import com.jogamp.opengl.math.Vec4f; import com.jogamp.opengl.math.geom.AABBox; import jogamp.graph.ui.shapes.Label0; @@ -72,7 +73,7 @@ public class Button extends RoundButton { final String labelText, final float width, final float height) { super(renderModes | Region.COLORCHANNEL_RENDERING_BIT, width, height); - this.label = new Label0(labelFont, labelText, new float[] { 1.33f, 1.33f, 1.33f, 1.0f }); // 0.75 * 1.33 = 1.0 + this.label = new Label0(labelFont, labelText, new Vec4f( 1.33f, 1.33f, 1.33f, 1.0f )); // 0.75 * 1.33 = 1.0 setColor(0.75f, 0.75f, 0.75f, 1.0f); setPressedColorMod(0.9f, 0.9f, 0.9f, 0.7f); setToggleOffColorMod(0.65f, 0.65f, 0.65f, 1.0f); @@ -93,16 +94,7 @@ public class Button extends RoundButton { @Override protected void addShapeToRegion() { - final OutlineShape shape = new OutlineShape(vertexFactory); - if(corner == 0.0f) { - createSharpOutline(shape, twoPassLabelZOffset); - } else { - createCurvedOutline(shape, twoPassLabelZOffset); - } - shape.setIsQuadraticNurbs(); - shape.setSharpness(oshapeSharpness); - region.addOutlineShape(shape, null, rgbaColor); - box.resize(shape.getBounds()); + addRoundShapeToRegion( twoPassLabelZOffset ); // Precompute text-box size .. guessing pixelSize final float lw = box.getWidth() * ( 1f - spacingX ) ; @@ -133,12 +125,6 @@ public class Button extends RoundButton { if( DEBUG_DRAW ) { System.err.printf("Button.X: lbox2 %s%n", lbox2); } - - setRotationPivot( ctr ); - - if( DEBUG_DRAW ) { - System.err.println("XXX.Button: Added Shape: "+shape+", "+box); - } } public float get2PassLabelZOffset() { return twoPassLabelZOffset; } @@ -174,7 +160,7 @@ public class Button extends RoundButton { markShapeDirty(); } - public final float[] getLabelColor() { + public final Vec4f getLabelColor() { return label.getColor(); } -- cgit v1.2.3