public class GuiVerticalLayout extends GuiLayout
Children are added and removed with the usual addChild(GuiElement) and removeChild(GuiElement) methods.
A maximum number of visible items can be set (default is unlimited), then the layout will only show as many items; if there are more items an up arrow button and a down arrow button allow to scroll the full item list. Note: For this to work correctly, all items shall have the same height; if different items have different height, the layout is likely to turn out wrong.
The layout sets the font size of GuiLabel's, the border thickness and the background of GuiTextField's as well as the clickable status of all children when each child is added to the layout. These properties, as well as other visual properties, can be changed after adding the child.
The layout also sets the pivot position of each child on adding it; changing it is possible, but it is likely to disrupt the proper child placement within the layout.
The layout sets the position of each child each time the layout() is called. Setting those position manually has no effect.
Important: due to the way Rising World plug-ins are loaded, this class cannot be instantiated or used in any way from within the onEnable() method of a plug-in, as it is impossible to be sure that, at that moment, the RWGui plug-in has already been loaded.
The first moment one can be sure that all plug-ins have been loaded, and it is safe to use this class, is when (or after) the first player connects to the server (either dedicated or local).
Constructor and Description |
---|
GuiVerticalLayout(int flags)
Creates an empty vertical layout.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(net.risingworld.api.gui.GuiElement element,
java.lang.Integer id,
java.lang.Object data)
Adds a GuiElement with the associated id and data as a direct child of
the layout.
|
void |
free()
Releases the resources used by the layout and all its descending
hierarchy of children.
|
RWGui.Pair<java.lang.Integer,java.lang.Object> |
getItemData(net.risingworld.api.gui.GuiElement element)
Returns the id and data pair associated with element, if element is one
of the children of the layout (recursively); or null otherwise.
|
java.lang.Integer |
getItemId(net.risingworld.api.gui.GuiElement element)
Returns the id associated with element, if element is one of the
children of the layout (recursively); or null otherwise.
|
int |
getMaxVisibleRows()
Returns the current maximum number of visible items.
|
void |
hide(net.risingworld.api.objects.Player player)
Hides the layout and all its hierarchy of children removing it from the
player screen.
|
void |
removeChild(net.risingworld.api.gui.GuiElement element)
Removes a GuiElement from the direct children of the layout.
|
int |
removeChild(int itemIndex)
Removes the itemIndex-th direct child of the layout.
|
void |
setMaxVisibleRows(int newMaxVisibleRows)
Sets the maximum number of visible items.
|
void |
show(net.risingworld.api.objects.Player player)
Displays the layout on the player screen.
|
addChild, addChild, addNewLayoutChild, addNewTableLayoutChild, getChildFromId, layout, setMargin, setPadding
destroy, equals, getAlpha, getBorderColor, getBorderThickness, getColor, getHeight, getHoverColor, getID, getParent, getParentID, getPivot, getPositionX, getPositionY, getWidth, hashCode, isRelativeBorderThickness, isRelativePosition, isRelativeSize, isVisible, refresh, removeFromParent, setAlpha, setBorderColor, setBorderColor, setBorderThickness, setColor, setColor, setPivot, setPosition, setSize, setVisible
public GuiVerticalLayout(int flags)
flags
- one of .LAYOUT_V_TOP, .LAYOUT_V_MIDDLE and .LAYOUT_V_BOTTOM
or .LAYOUT_V_SPARSE to control the vertical distribution of
children ORed with one of RWGui.LAYOUT_H_LEFT,
.LAYOUT_H_CENTRE or .LAYOUT_H_RIGHT to control the vertical
alignment.public void setMaxVisibleRows(int newMaxVisibleRows)
newMaxVisibleRows
- the new maximum number of visible items.public int getMaxVisibleRows()
public java.lang.Integer getItemId(net.risingworld.api.gui.GuiElement element)
public RWGui.Pair<java.lang.Integer,java.lang.Object> getItemData(net.risingworld.api.gui.GuiElement element)
getItemData
in class GuiLayout
element
- the GuiElement to look for.public void addChild(net.risingworld.api.gui.GuiElement element, java.lang.Integer id, java.lang.Object data)
If id is not null, the element is active (the player can click on it), if id is null, the element is not active.
public void removeChild(net.risingworld.api.gui.GuiElement element)
removeChild
in class GuiLayout
element
- The GuiElement to removepublic int removeChild(int itemIndex)
element
- The GuiElement to removepublic void free()
It is necessary to call this method only for the top layout of hierarchy and only if it not part of a managed element (like GuiDialogueBox).
public void hide(net.risingworld.api.objects.Player player)
public void show(net.risingworld.api.objects.Player player)