aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-19 04:53:40 +0200
committerSven Gothel <[email protected]>2023-09-19 04:53:40 +0200
commit162f8e309b67c333a482d636e59d207a6c5924e7 (patch)
treefe5ded6c6d1cfd9a7919a5026eaef28a2ce224d2 /src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java
parent376554c6a5bd25edd5490f51118a92ef93a0fc33 (diff)
GraphUI GridLayout: Fix scaled non-center: Only add center offset if requested and avoid double-add.
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java18
1 files changed, 9 insertions, 9 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 67f3ff445..c45fc3bb1 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java
@@ -201,22 +201,22 @@ public class BoxLayout implements Group.Layout {
float dxh = 0, dyh = 0;
if( isScaled ) {
// scaling to cell size
- final float cellWidth2 = hasCellWidth ? cellSize.x() - margin.width() : shapeWidthU;
- final float cellHeight2 = hasCellHeight ? cellSize.y() - margin.height() : shapeHeightU;
- final float sx = cellWidth2 / shapeWidthU;
- final float sy = cellHeight2/ shapeHeightU;
+ final float cellWidth = hasCellWidth ? cellSize.x() - margin.width() : shapeWidthU;
+ final float cellHeight = hasCellHeight ? cellSize.y() - margin.height() : shapeHeightU;
+ final float sx = cellWidth / shapeWidthU;
+ final float sy = cellHeight/ shapeHeightU;
sxy = sx < sy ? sx : sy;
if( isCenteredHoriz ) {
- dxh += shapeWidthU * ( sx - sxy ) * 0.5f; // horiz-center (adjustment for scale-axis)
+ dxh += shapeWidthU * ( sx - sxy ) * 0.5f; // horiz-center (adjustment for scale-axis w/o margin)
}
if( isCenteredVert ) {
- dyh += shapeHeightU * ( sy - sxy ) * 0.5f; // vert-center (adjustment for scale-axis)
+ dyh += shapeHeightU * ( sy - sxy ) * 0.5f; // vert-center (adjustment for scale-axis w/o margin)
}
- dyh += margin.bottom;
- dxh += margin.left;
+ dyh += margin.bottom; // always consider unscaled margin when scaling
+ dxh += margin.left; // ditto
if( TRACE_LAYOUT ) {
- System.err.println("bl("+i+").s: "+sx+" x "+sy+" -> "+sxy+": +"+dxh+" / "+dyh+", U: s "+shapeWidthU+" x "+shapeHeightU+", sz "+cellWidth2+" x "+cellHeight2);
+ System.err.println("bl("+i+").s: "+sx+" x "+sy+" -> "+sxy+": +"+dxh+" / "+dyh+", U: s "+shapeWidthU+" x "+shapeHeightU+", sz "+cellWidth+" x "+cellHeight);
}
} else {
sxy = 1;