Class GuiScrolling
- All Implemented Interfaces:
ContentElement<GuiElement<?>>,ElementEvents,GuiParent<GuiScrolling>,TooltipHandler<GuiScrolling>
GuiScrolling
But its GeoParam.WIDTH and GeoParam.HEIGHT constraints can be set by the user,
Or they can be set to dynamically adjust to the child elements added to it.
The bounds of the GuiScrolling represent the "view window"
When scrolling up/down, left/right the Content Element is effectively just moving around behind the view window
and everything outside the view window is scissored off.
Any events that occur outside the view window are not propagated to scroll element.
Calls to GuiElement.isMouseOver() from an area of an element that is outside the view window will return false.
Elements that are completely outside the view window will not be rendered at all for efficiency.
Created by brandon3055 on 01/09/2023
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanThis is made available primarily for debugging purposes where it can be useful to see what's going on behind the scenes.Fields inherited from class codechicken.lib.gui.modular.elements.GuiElement
hoverTime, initialized -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanblockMouseOver(GuiElement<?> element, double mouseX, double mouseY) Allows an element to override theGuiElement.isMouseOver()method of its children.GuiElement<?> Retrieves the content element that holds all the scrolling elements.doublehiddenSize(Axis axis) voidinstallContainerElement(GuiElement<?> element) This allows you to install a custom container element.protected booleanrenderChild(GuiElement<?> child, GuiRender render, double mouseX, double mouseY, float partialTicks) scrollState(Axis axis) static GuiScrolling.ScrollWindowsimpleScrollWindow(@NotNull GuiParent<?> parent, boolean verticalScrollBar, boolean horizontalScrollBar) voidtick(double mouseX, double mouseY) Called every tick to update the element.doubleMethods inherited from class codechicken.lib.gui.modular.elements.GuiElement
addChild, addJeiDropTargets, addJeiExclusions, adoptChild, applyQueuedChildUpdates, blockMouseEvents, bringChildToForeground, font, getChildren, getCombinedElementDepth, getJeiDropConsumer, getModularGui, getParent, getTooltip, getTooltipDelay, hoverTime, initElement, isDescendantOf, isEnabled, isJeiDropTarget, isJeiExcluded, isMouseOver, isOpaque, isRemoved, isTooltipEnabled, jeiExclude, mc, onScreenInit, removeChild, render, 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, constrain, 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, mouseMoved, mouseReleased, 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
-
enableScissor
public boolean enableScissorThis is made available primarily for debugging purposes where it can be useful to see what's going on behind the scenes.
-
-
Constructor Details
-
GuiScrolling
- Parameters:
parent- parentGuiParent.
-
-
Method Details
-
getContentElement
Retrieves the content element that holds all the scrolling elements. You must add all of your scrolling content to this element. Scrolling content must also be constrained relative to this element.The
GeoParam.TOPandGeoParam.LEFTconstraints for this element are set by theGuiScrollingand must not be overridden. These are used to control the 'scrolling' of the element.By default, the
GeoParam.WIDTHandGeoParam.HEIGHT(and therefor also BOTTOM, RIGHT) are dynamically constrained to match the outer bounds of the scrolling elements. So attempting to constrain the content to any of these dynamic parameters would result in a stack overflow. You can however override the WIDTH and HEIGHT constraints if you wish. This can be useful if you wish to create something like a fixed width scrolling list where the width of each scrolling element is bound to the width of the list.The most important thing to note, Especially when manually constraining the WIDTH and HEIGHT of the content element, All scrolling elements must be withing the bounds of the content element. Anything outside the content element's bounds will not be visible.
- Specified by:
getContentElementin interfaceContentElement<GuiElement<?>>- Returns:
- The content element.
-
installContainerElement
This allows you to install a custom container element. The elements constraints will automatically be set by this method.After calling this method you may override the container element WIDTH and HEIGHT constraints as described in the documentation for
getContentElement()But you must not touch the TOP or LEFT constraints.Important thing to note, By default the container element is preinstalled before any children can be added, meaning any children added to the
GuiScrollingwill render on top of the scrolling content. As this method allows you to set a new child as the container element, any children added before the new content element, will render under the content element.- Parameters:
element- The new container element.
-
scrollState
- Returns:
- a
SliderStatethat can be used to get or control the scroll position of the specified axis.
-
totalSize
- Returns:
- the total content size / length for the given axis
-
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<GuiScrolling>- Parameters:
mouseX- Current mouse X positionmouseY- Current mouse Y position
-
blockMouseOver
Description copied from interface:GuiParentAllows an element to override theGuiElement.isMouseOver()method of its children. This is primarily used for things like scroll elements where mouseover interactions need to be blocked outside the view area.- Specified by:
blockMouseOverin interfaceGuiParent<GuiScrolling>- Overrides:
blockMouseOverin classGuiElement<GuiScrolling>- Parameters:
element- The element on which isMouseOver is getting called.- Returns:
- true if mouse-over interaction should be blocked for this child element.
-
renderChild
protected boolean renderChild(GuiElement<?> child, GuiRender render, double mouseX, double mouseY, float partialTicks) - Overrides:
renderChildin classGuiElement<GuiScrolling>
-
simpleScrollWindow
public static GuiScrolling.ScrollWindow simpleScrollWindow(@NotNull @NotNull GuiParent<?> parent, boolean verticalScrollBar, boolean horizontalScrollBar)
-