Skip to content

Commit

Permalink
[Zest 2.0] Ignore node size when calculating position in grid
Browse files Browse the repository at this point in the history
The location of a node describes its top-left pixel, rather than its
center. When using layout algorithms that are based on the grid layout,
this causes the offset to be half the space between the rows and columns
plus the half the width and height of the nodes.
Latter is undesirable and may cause nodes to be partially moved outside
the client area.
  • Loading branch information
ptziegler committed Sep 27, 2024
1 parent 9985300 commit 033630b
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,8 @@ protected synchronized void applyLayoutInternal(EntityLayout[] entitiesToLayout,
node.setSize(Math.max(childrenWidth, MIN_ENTITY_SIZE),
Math.max(childrenHeight, MIN_ENTITY_SIZE));
}
DisplayIndependentDimension size = node.getSize();
double xmove = bounds.x + j * colWidth + offsetX + size.width / 2;
double ymove = bounds.y + i * rowHeight + offsetY + size.height / 2;
double xmove = bounds.x + j * colWidth + offsetX;
double ymove = bounds.y + i * rowHeight + offsetY;
if (node.isMovable()) {
node.setLocation(xmove, ymove);
}
Expand Down

0 comments on commit 033630b

Please sign in to comment.