From e676a65eac2bfa2abbfcd346492868ed17dc4667 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 19 Sep 2023 07:30:16 +0200 Subject: GraphUI Layout (Box/Grid): Adjust bottom-left offset according to center-axis - Remove the negative or positive delta on centered axis. - Only remove negative offset of non-centered axis (i.e. underline) --- .../com/jogamp/graph/ui/layout/BoxLayout.java | 25 +++++++++++++++++++--- .../com/jogamp/graph/ui/layout/GridLayout.java | 25 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) (limited to 'src/graphui/classes/com/jogamp') diff --git a/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java b/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java index c45fc3bb1..05e3189ae 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java +++ b/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java @@ -250,14 +250,33 @@ public class BoxLayout implements Group.Layout { final float aY = y + dyh; s.moveTo( aX, aY, s.getPosition().z() ); - // Remove the bottom-left delta + // Remove the negative or positive delta on centered axis. + // Only remove negative offset of non-centered axis (i.e. underline) final Vec3f diffBL = new Vec3f(s.getBounds().getLow()); diffBL.setZ(0); - diffBL.scale(s.getScale()).scale(-1f); + if( isCenteredHoriz || isCenteredVert ) { + if( !isCenteredVert && diffBL.y() > 0 ) { + diffBL.setY(0); // only adjust negative if !center-vert + } else if( !isCenteredHoriz && diffBL.x() > 0 ) { + diffBL.setX(0); // only adjust negative if !center-horiz + } + diffBL.scale(s.getScale()).scale(-1f); + s.move( diffBL.scale(sxy) ); + } else if( diffBL.x() < 0 || diffBL.y() < 0 ) { + if( diffBL.x() > 0 ) { + diffBL.setX(0); + } + if( diffBL.y() > 0 ) { + diffBL.setY(0); + } + diffBL.scale(s.getScale()).scale(-1f); + s.move( diffBL.scale(sxy) ); + } else { + diffBL.set(0, 0, 0); + } if( TRACE_LAYOUT ) { System.err.println("bl("+i+").bl: sbox0 "+s.getBounds()+", diffBL_ "+diffBL); } - s.move( diffBL.scale(sxy) ); // resize bounds box.resize( x, y, sbox.getMinZ()); diff --git a/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java b/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java index b6a7baf12..3afe093f3 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java +++ b/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java @@ -324,14 +324,33 @@ public class GridLayout implements Group.Layout { final float aY = y + dyh; s.moveTo( aX, aY, s.getPosition().z() ); - // Remove the bottom-left delta + // Remove the negative or positive delta on centered axis. + // Only remove negative offset of non-centered axis (i.e. underline) final Vec3f diffBL = new Vec3f(s.getBounds().getLow()); diffBL.setZ(0); - diffBL.scale(s.getScale()).scale(-1f); + if( isCenteredHoriz || isCenteredVert ) { + if( !isCenteredVert && diffBL.y() > 0 ) { + diffBL.setY(0); // only adjust negative if !center-vert + } else if( !isCenteredHoriz && diffBL.x() > 0 ) { + diffBL.setX(0); // only adjust negative if !center-horiz + } + diffBL.scale(s.getScale()).scale(-1f); + s.move( diffBL.scale(sxy) ); + } else if( diffBL.x() < 0 || diffBL.y() < 0 ) { + if( diffBL.x() > 0 ) { + diffBL.setX(0); + } + if( diffBL.y() > 0 ) { + diffBL.setY(0); + } + diffBL.scale(s.getScale()).scale(-1f); + s.move( diffBL.scale(sxy) ); + } else { + diffBL.set(0, 0, 0); + } if( TRACE_LAYOUT ) { System.err.println("gl("+i+")["+col_i+"]["+row_i+"].bl: sbox0 "+s.getBounds()+", diffBL_ "+diffBL); } - s.move( diffBL.scale(sxy) ); // resize bounds box.resize( x, y, sbox.getMinZ()); -- cgit v1.2.3