From f95f2a82096c7e6a2b0d7a4ad485635351bfee9e Mon Sep 17 00:00:00 2001 From: brandon3055 Date: Tue, 23 Apr 2024 07:47:17 +1000 Subject: [PATCH] Added center constraint with offset --- .../java/codechicken/lib/gui/modular/lib/Constraints.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/codechicken/lib/gui/modular/lib/Constraints.java b/src/main/java/codechicken/lib/gui/modular/lib/Constraints.java index 1cb4de5b..91c84555 100644 --- a/src/main/java/codechicken/lib/gui/modular/lib/Constraints.java +++ b/src/main/java/codechicken/lib/gui/modular/lib/Constraints.java @@ -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: