Skip to content

Commit

Permalink
Added center constraint with offset
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon3055 committed Apr 22, 2024
1 parent 3a47b58 commit f95f2a8
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public static void center(ConstrainedGeometry<?> element, ConstrainedGeometry<?>
element.constrain(LEFT, midPoint(centerOn.get(LEFT), centerOn.get(RIGHT), () -> element.xSize() / -2));
}

public static void center(ConstrainedGeometry<?> element, ConstrainedGeometry<?> centerOn, double xOffset, double yOffset) {
element.constrain(TOP, midPoint(centerOn.get(TOP), centerOn.get(BOTTOM), () -> (element.ySize() / -2) + yOffset));
element.constrain(LEFT, midPoint(centerOn.get(LEFT), centerOn.get(RIGHT), () -> (element.xSize() / -2) + xOffset));
}

/**
* Constrain the specified element to a position inside the specified targetElement.
* See the following image for an example of what each LayoutPos does:
Expand Down

0 comments on commit f95f2a8

Please sign in to comment.