Skip to content

Commit f95f2a8

Browse files
committed
Added center constraint with offset
1 parent 3a47b58 commit f95f2a8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/codechicken/lib/gui/modular/lib/Constraints.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public static void center(ConstrainedGeometry<?> element, ConstrainedGeometry<?>
9090
element.constrain(LEFT, midPoint(centerOn.get(LEFT), centerOn.get(RIGHT), () -> element.xSize() / -2));
9191
}
9292

93+
public static void center(ConstrainedGeometry<?> element, ConstrainedGeometry<?> centerOn, double xOffset, double yOffset) {
94+
element.constrain(TOP, midPoint(centerOn.get(TOP), centerOn.get(BOTTOM), () -> (element.ySize() / -2) + yOffset));
95+
element.constrain(LEFT, midPoint(centerOn.get(LEFT), centerOn.get(RIGHT), () -> (element.xSize() / -2) + xOffset));
96+
}
97+
9398
/**
9499
* Constrain the specified element to a position inside the specified targetElement.
95100
* See the following image for an example of what each LayoutPos does:

0 commit comments

Comments
 (0)