Package codechicken.lib.gui.modular.lib
Class Constraints
java.lang.Object
codechicken.lib.gui.modular.lib.Constraints
This class contains a bunch of static helper methods that can be used to quickly apply common constraints.
The plan is to keep adding common constraints to this class as they pop up.
Created by brandon3055 on 28/08/2023
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbind(ConstrainedGeometry<?> element, ConstrainedGeometry<?> reference) Bind an elements geometry to a reference element.static voidbind(ConstrainedGeometry<?> element, ConstrainedGeometry<?> reference, double borders) Bind an elements geometry to a reference element with border offsets.static voidbind(ConstrainedGeometry<?> element, ConstrainedGeometry<?> reference, double top, double left, double bottom, double right) Bind an elements geometry to a reference element with border offsets.static voidbind(ConstrainedGeometry<?> element, ConstrainedGeometry<?> reference, Borders borders) Bind an elements geometry to a reference element with border offsets.static voidcenter(ConstrainedGeometry<?> element, ConstrainedGeometry<?> centerOn) static voidcenter(ConstrainedGeometry<?> element, ConstrainedGeometry<?> centerOn, double xOffset, double yOffset) static voidplaceInside(ConstrainedGeometry<?> target, ConstrainedGeometry<?> reference, Constraints.LayoutPos position) Deprecated.static voidplaceInside(ConstrainedGeometry<?> target, ConstrainedGeometry<?> reference, Constraints.LayoutPos position, double xOffset, double yOffset) Deprecated.static voidplaceOutside(ConstrainedGeometry<?> target, ConstrainedGeometry<?> reference, Constraints.LayoutPos position) Deprecated.static voidplaceOutside(ConstrainedGeometry<?> target, ConstrainedGeometry<?> reference, Constraints.LayoutPos position, double xOffset, double yOffset) Deprecated.static voidpos(ConstrainedGeometry<?> element, double left, double top) static voidstatic voidsize(ConstrainedGeometry<?> element, double width, double height) static void
-
Constructor Details
-
Constraints
public Constraints()
-
-
Method Details
-
bind
Bind an elements geometry to a reference element.- Parameters:
element- The element to be bound.reference- The element to be bound to.
-
bind
public static void bind(ConstrainedGeometry<?> element, ConstrainedGeometry<?> reference, double borders) Bind an elements geometry to a reference element with border offsets. (Border offsets may be positive or negative)- Parameters:
element- The element to be bound.reference- The element to be bound to.
-
bind
public static void bind(ConstrainedGeometry<?> element, ConstrainedGeometry<?> reference, double top, double left, double bottom, double right) Bind an elements geometry to a reference element with border offsets. (Border offsets may be positive or negative)- Parameters:
element- The element to be bound.reference- The element to be bound to.
-
bind
public static void bind(ConstrainedGeometry<?> element, ConstrainedGeometry<?> reference, Borders borders) Bind an elements geometry to a reference element with border offsets. (Border offsets may be positive or negative) The border offsets are dynamic, meaning if the values stored in theBordersobject are updated, this binding will reflect those changes automatically.- Parameters:
element- The element to be bound.reference- The element to be bound to.borders- Border offsets.
-
size
-
size
public static void size(ConstrainedGeometry<?> element, Supplier<Double> width, Supplier<Double> height) -
pos
-
pos
-
center
-
center
public static void center(ConstrainedGeometry<?> element, ConstrainedGeometry<?> centerOn, double xOffset, double yOffset) -
placeInside
@Deprecated public static void placeInside(ConstrainedGeometry<?> target, ConstrainedGeometry<?> reference, Constraints.LayoutPos position) Deprecated.Constrain the specified element to a position inside the specified targetElement. See the following image for an example of what each LayoutPos does: https://ss.brandon3055.com/e89a6- Parameters:
target- The element whose position we are setting.reference- The reference element, the element that target will be placed inside.position- The layout position.
-
placeInside
@Deprecated public static void placeInside(ConstrainedGeometry<?> target, ConstrainedGeometry<?> reference, Constraints.LayoutPos position, double xOffset, double yOffset) Deprecated.Constrain the specified element to a position inside the specified targetElement. See the following image for an example of what each LayoutPos does: https://ss.brandon3055.com/e89a6- Parameters:
target- The element whose position we are setting.reference- The reference element, the element that target will be placed inside.position- The layout position.xOffset- Optional X offset to be applied to the final position.yOffset- Optional Y offset to be applied to the final position.
-
placeOutside
@Deprecated public static void placeOutside(ConstrainedGeometry<?> target, ConstrainedGeometry<?> reference, Constraints.LayoutPos position) Deprecated.Constrain the specified element to a position outside the specified targetElement. See the following image for an example of what each LayoutPos does: https://ss.brandon3055.com/baa7c- Parameters:
target- The element whose position we are setting.reference- The reference element, the element that target will be placed outside of.position- The layout position.
-
placeOutside
@Deprecated public static void placeOutside(ConstrainedGeometry<?> target, ConstrainedGeometry<?> reference, Constraints.LayoutPos position, double xOffset, double yOffset) Deprecated.Constrain the specified element to a position outside the specified targetElement. See the following image for an example of what each LayoutPos does: https://ss.brandon3055.com/baa7c- Parameters:
target- The element whose position we are setting.reference- The reference element, the element that target will be placed outside of.position- The layout position.xOffset- Optional X offset to be applied to the final position.yOffset- Optional Y offset to be applied to the final position.
-