Class GuiManipulable
java.lang.Object
codechicken.lib.gui.modular.lib.geometry.ConstrainedGeometry<GuiManipulable>
codechicken.lib.gui.modular.elements.GuiElement<GuiManipulable>
codechicken.lib.gui.modular.elements.GuiManipulable
- All Implemented Interfaces:
ContentElement<GuiElement<?>>,ElementEvents,GuiParent<GuiManipulable>,TooltipHandler<GuiManipulable>
- Direct Known Subclasses:
GuiColourPicker
public class GuiManipulable
extends GuiElement<GuiManipulable>
implements ContentElement<GuiElement<?>>
This element can be used to create movable/resizable guis of gui elements.
This is achieved via a "contentElement" to which all child elements should eb attached.
Initially the bounds of the content element will match the parent
GuiManipulable element.
However, depending on which features are enabled, it is possible for the user to resize the
content element by clicking and dragging the edges, or move the element by clicking and dragging
a specified "dragArea".
It should be noted that the constraints on the underlying GuiManipulable should be fairly rigid.
Things like dynamic constraint changes will not translate through to the contentElement,
If a UI resize occurs the content element's bounds will be reset to default.
You can also trigger a manual reset by calling resetBounds()
Created by brandon3055 on 13/11/2023
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Rectangleprotected Rectangleprotected GuiManipulable.PositionRestraintintintintintFields inherited from class codechicken.lib.gui.modular.elements.GuiElement
hoverTime, initialized -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddBottomHandle(int handleSize) addLeftHandle(int handleSize) addMoveHandle(int handleSize) addResizeHandles(int handleSize, boolean includeTopHandle) addRightHandle(int handleSize) addTopHandle(int handleSize) constrain(GeoParam param, @Nullable Constraint constraint) enableCursors(boolean enableCursors) Enables rendering of custom mouse cursors when hovering over a draggable handle.GuiElement<?> You can use this to retrieve the current bottom resize handle.GuiElement<?> GuiElement<?> You can use this to retrieve the current left resize handle.GuiElement<?> You can use this to retrieve the current move handle.GuiElement<?> You can use this to retrieve the current right resize handle.GuiElement<?> You can use this to retrieve the current top resize handle.booleanisMoving()booleanvoidmouseMoved(double mouseX, double mouseY) Called whenever the cursor position changes.booleanmouseReleased(double mouseX, double mouseY, int button, boolean consumed) Root handler for mouseReleased event.protected voidonMoved(boolean finished) protected voidonResized(boolean finished) voidonScreenInit(net.minecraft.client.Minecraft mc, net.minecraft.client.gui.Font font, int screenWidth, int screenHeight) Called when the minecraft Screen is initialised or resized.setBottomHandle(GuiElement<?> bottomHandle) setLeftHandle(GuiElement<?> leftHandle) voidsetMaxSize(Rectangle maxSize) voidsetMinSize(Rectangle minSize) setMoveHandle(GuiElement<?> moveHandle) setOnMovedCallback(Runnable onMovedCallback) setOnMovedCallback(Consumer<Boolean> onMovedCallback) setOnResizedCallback(Runnable onResizedCallback) setOnResizedCallback(Consumer<Boolean> onResizedCallback) setPositionRestraint(GuiManipulable.PositionRestraint positionRestraint) setResetOnUiInit(boolean resetOnUiInit) setRightHandle(GuiElement<?> rightHandle) setTopHandle(GuiElement<?> topHandle) voidvoidtick(double mouseX, double mouseY) Called every tick to update the element.protected voidvalidatePosition(boolean finished) Methods inherited from class codechicken.lib.gui.modular.elements.GuiElement
addChild, addJeiDropTargets, addJeiExclusions, adoptChild, applyQueuedChildUpdates, blockMouseEvents, blockMouseOver, bringChildToForeground, font, getChildren, getCombinedElementDepth, getJeiDropConsumer, getModularGui, getParent, getTooltip, getTooltipDelay, hoverTime, initElement, isDescendantOf, isEnabled, isJeiDropTarget, isJeiExcluded, isMouseOver, isOpaque, isRemoved, isTooltipEnabled, jeiExclude, mc, removeChild, render, renderChild, renderOverlay, scaledScreenHeight, scaledScreenWidth, sendChildToBackground, sendChildToIndex, setEnabled, setEnabled, setEnableToolTip, setJeiDropTarget, setJeiExcluded, setOpaque, setRenderCull, setTooltip, setTooltipDelay, setZStacking, showToolTip, toString, updateMouseOver, updateScreenData, zStackingMethods inherited from class codechicken.lib.gui.modular.lib.geometry.ConstrainedGeometry
addBoundsToRect, clearConstraints, clearGeometryCache, get, getChildBounds, getEnclosingRect, getParent, getPosition, getRectangle, placeInside, placeInside, placeOutside, placeOutside, setHeight, setPos, setSize, setWidth, setXPos, setYPos, strictMode, validate, xCenter, xMax, xMin, xSize, yCenter, yMax, yMin, ySizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface codechicken.lib.gui.modular.lib.ElementEvents
charTyped, charTyped, keyPressed, keyPressed, keyReleased, keyReleased, mouseClicked, mouseClicked, mouseReleased, mouseScrolled, mouseScrolledMethods inherited from interface codechicken.lib.gui.modular.lib.geometry.GuiParent
addChild, getValueMethods inherited from interface codechicken.lib.gui.modular.lib.TooltipHandler
renderTooltip, setTooltip, setTooltip, setTooltip, setTooltipSingle, setTooltipSingle
-
Field Details
-
xMin
public int xMin -
xMax
public int xMax -
yMin
public int yMin -
yMax
public int yMax -
minSize
-
maxSize
-
onMovedCallback
-
onResizedCallback
-
positionRestraint
-
-
Constructor Details
-
GuiManipulable
-
-
Method Details
-
resetBounds
-
constrain
- Overrides:
constrainin classConstrainedGeometry<GuiManipulable>- Parameters:
param- The geometry parameter to be constrained.constraint- The constraint to apply- Returns:
- This Element.
-
onScreenInit
public void onScreenInit(net.minecraft.client.Minecraft mc, net.minecraft.client.gui.Font font, int screenWidth, int screenHeight) Description copied from interface:GuiParentCalled when the minecraft Screen is initialised or resized.- Specified by:
onScreenInitin interfaceGuiParent<GuiManipulable>- Overrides:
onScreenInitin classGuiElement<GuiManipulable>- Parameters:
mc- The Minecraft instance.font- The active font.screenWidth- The current guiScaledWidth.screenHeight- The current guiScaledHeight.
-
setResetOnUiInit
- Parameters:
resetOnUiInit- If true, element bounds will be reset on UI init. (Default: true)
-
getContentElement
- Specified by:
getContentElementin interfaceContentElement<GuiElement<?>>
-
addResizeHandles
-
addTopHandle
-
setTopHandle
-
addBottomHandle
-
setBottomHandle
-
addLeftHandle
-
setLeftHandle
-
addRightHandle
-
setRightHandle
-
addMoveHandle
-
setMoveHandle
-
getMoveHandle
You can use this to retrieve the current move handle. You are free to update the constraints on this handle, but it must be constrained relative to the content element. -
getLeftHandle
You can use this to retrieve the current left resize handle. You are free to update the constraints on this handle, but it must be constrained relative to the content element. -
getRightHandle
You can use this to retrieve the current right resize handle. You are free to update the constraints on this handle, but it must be constrained relative to the content element. -
getTopHandle
You can use this to retrieve the current top resize handle. You are free to update the constraints on this handle, but it must be constrained relative to the content element. -
getBottomHandle
You can use this to retrieve the current bottom resize handle. You are free to update the constraints on this handle, but it must be constrained relative to the content element. -
enableCursors
Enables rendering of custom mouse cursors when hovering over a draggable handle. -
setOnMovedCallback
-
setOnMovedCallback
-
setOnResizedCallback
-
setOnResizedCallback
-
setPositionRestraint
-
setMinSize
-
setMaxSize
-
getMinSize
-
getMaxSize
-
tick
public void tick(double mouseX, double mouseY) Description copied from class:GuiElementCalled every tick to update the element. Note this is called regardless of weather or not the element is actually enabled.- Overrides:
tickin classGuiElement<GuiManipulable>- Parameters:
mouseX- Current mouse X positionmouseY- Current mouse Y position
-
startDragging
public void startDragging() -
mouseMoved
public void mouseMoved(double mouseX, double mouseY) Description copied from interface:ElementEventsCalled whenever the cursor position changes. Vanillas mouseDragged is not passed through because it is redundant. All mouse drag functionality can be archived using available events.- Specified by:
mouseMovedin interfaceElementEvents- Parameters:
mouseX- new mouse X positionmouseY- new mouse Y position
-
mouseReleased
public boolean mouseReleased(double mouseX, double mouseY, int button, boolean consumed) Description copied from interface:ElementEventsRoot handler for mouseReleased event. This method will always be called for all elements even if the event has already been consumed. There are a few uses for this method, but the fast majority of mouseReleased handling should be implemented viaElementEvents.mouseReleased(double, double, int)Note: If overriding this method, do so with caution, You must either return true (if you wish to consume the event) or you must return the result of the super call.
- Specified by:
mouseReleasedin interfaceElementEvents- Parameters:
mouseX- Mouse X positionmouseY- Mouse Y positionbutton- Mouse Buttonconsumed- Will be true if this action has already been consumed.- Returns:
- true if this event has been consumed.
-
validatePosition
protected void validatePosition(boolean finished) -
onMoved
protected void onMoved(boolean finished) -
onResized
protected void onResized(boolean finished) -
isMoving
public boolean isMoving() -
isResizing
public boolean isResizing()
-