public class GuiLayout
extends net.risingworld.api.gui.GuiPanel
Each GuiLayout has a specific arrangement of its children, according to the specific subclass used (GuiHorizontalLayout, GuiVerticalLayout, ...). It can have more GuiLayout's as children to achieve complex structures.
Important: due to the way Rising World plug-ins are loaded, this class (or its sub-classes) cannot 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 |
---|
GuiLayout(int flags) |
Modifier and Type | Method and Description |
---|---|
void |
addChild(net.risingworld.api.gui.GuiElement element)
Adds an inactive GuiElement (with no associated data) as a direct child
of the layout.
|
void |
addChild(net.risingworld.api.gui.GuiElement element,
java.lang.Integer id)
Adds a GuiElement with the associated id as a direct child of the layout.
|
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.
|
GuiLayout |
addNewLayoutChild(int layoutType,
int layoutFlags)
Adds a new GuiLayout as a direct child of this layout.
|
GuiLayout |
addNewTableLayoutChild(int colNum,
int rowNum,
int flags)
Adds a new GuiTableLayout as a direct child of this 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.
|
void |
hide(net.risingworld.api.objects.Player player)
Hides the layout and all its hierarchy of children removing it from the
player screen.
|
void |
layout(int minWidth,
int minHeight)
Arranges the elements inside the layout according to the layout type and settings.
|
void |
removeChild(net.risingworld.api.gui.GuiElement element)
Removes a GuiElement from the direct children of the layout.
|
void |
setMargin(int value)
Sets the margin between the contents of the layout and its edges.
|
void |
setPadding(int value)
Sets the padding (i.e.
|
void |
show(net.risingworld.api.objects.Player player)
Displays the layout on the player screen.
|
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 void layout(int minWidth, int minHeight)
minWidth
- the minimum width which the context within which the
is placed requires the layout to have; use 0 if there
no external constrains.minHeight
- the minimum height which the context within which the
is placed requires the layout to have; use 0 if there
no external constrains.public 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)
player
- the player from whose screen to remove the dialogue
box. Removing the same dialogue box from the same
player multiple times has no effect and does no harm.public void setMargin(int value)
value
- the new padding (in pixels).public void setPadding(int value)
value
- the new padding (in pixels).public void show(net.risingworld.api.objects.Player player)
player
- the player to show the layout to.public void addChild(net.risingworld.api.gui.GuiElement element)
addChild
in class net.risingworld.api.gui.GuiElement
element
- the element to add.public void addChild(net.risingworld.api.gui.GuiElement element, java.lang.Integer id)
The element will have no data in addition to its id.
If id is not null, the element is active (the player can click on it), if id is null, the element is not active.
element
- the element to add.id
- the id associated with the element; may be null for
inactive elements.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.
element
- the element to add.id
- the id associated with the element; may be null for
inactive elements.data
- the data associated with the element; may be null for
elements which need no additional data other than their id.public void removeChild(net.risingworld.api.gui.GuiElement element)
removeChild
in class net.risingworld.api.gui.GuiElement
element
- The GuiElement to removepublic GuiLayout addNewLayoutChild(int layoutType, int layoutFlags)
layoutType
- either RWGui.LAYOUT_HORIZ or RWGui.LAYOUT_VERT.layoutFlags
- one of the RWGui.LAYOUT_H_* flags ORed with one of
RWGui.LAYOUT_V_* flags; their meaning depends on the layout type
(RWGui.LAYOUT_HORIZ or RWGui.LAYOUT_VERT).public GuiLayout addNewTableLayoutChild(int colNum, int rowNum, int flags)
colNum
- the number of columns the table will haverowNum
- the number of rows the table will have.flags
- currently not used, set to 0.public java.lang.Integer getItemId(net.risingworld.api.gui.GuiElement element)
element
- the GuiElement to look for.public RWGui.Pair<java.lang.Integer,java.lang.Object> getItemData(net.risingworld.api.gui.GuiElement element)
element
- the GuiElement to look for.