aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-19 07:30:16 +0200
committerSven Gothel <[email protected]>2023-09-19 07:30:16 +0200
commite676a65eac2bfa2abbfcd346492868ed17dc4667 (patch)
tree9e24a7ae52baf178465bedaca1652d70f4051e79 /src
parent81702c02e5111b6b5db8cbcc94e06472ee566b0a (diff)
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)
Diffstat (limited to 'src')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java25
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java25
2 files changed, 44 insertions, 6 deletions
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());