T
- type of UIContainerpublic class UIContainer<T extends UIContainer> extends UIComponent<T> implements IClipable, IScrollable, ICloseable
UIContainer
are the base for components holding other components.ITransformable.Alpha, ITransformable.Brightness, ITransformable.Color, ITransformable.Position<T>, ITransformable.Rotate, ITransformable.Scale, ITransformable.Size<T>, ITransformable.Translate
Modifier and Type | Field and Description |
---|---|
protected boolean |
clipContent
Determines whether this
UIContainer should clip its contents to its drawn area. |
protected java.util.Set<UIComponent> |
components
List of
UIComponent inside this UIContainer . |
protected int |
contentHeight
Height of the contents of this
UIContainer . |
protected int |
contentWidth
Width of the contents of this
UIContainer . |
protected int |
horizontalPadding
Horizontal padding to apply to this
UIContainer . |
protected UILabel |
titleLabel
Label for the title of this
UIContainer . |
protected int |
verticalPadding
Vertical padding to apply to this
UIContainer . |
protected int |
xOffset
X Offset for the contents of this
UIContainer from 0 to 1. |
protected int |
yOffset
Y Offset for the contents of this
UIContainer from 0 to 1. |
Constructor and Description |
---|
UIContainer(MalisisGui gui)
Default constructor, creates the components list.
|
UIContainer(MalisisGui gui,
int width,
int height)
Instantiates a new
UIContainer . |
UIContainer(MalisisGui gui,
java.lang.String title)
Instantiates a new
UIContainer . |
UIContainer(MalisisGui gui,
java.lang.String title,
int width,
int height)
Instantiates a new
UIContainer . |
Modifier and Type | Method and Description |
---|---|
void |
add(UIComponent... components)
Adds components to this
UIContainer . |
void |
calculateContentSize()
Calculates content size.
|
int |
componentX(UIComponent component)
Gets the relative position of the specified
UIComponent inside this UIContainer . |
int |
componentY(UIComponent component)
Gets the relative position of the specified
UIComponent inside this UIContainer . |
void |
drawBackground(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Draws the background.
|
void |
drawForeground(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Draws the foreground.
|
ClipArea |
getClipArea()
Gets the
ClipArea . |
UIComponent |
getComponentAt(int x,
int y)
Gets the component at the specified coordinates.
|
int |
getContentHeight() |
int |
getContentWidth() |
int |
getHorizontalPadding()
Gets the horizontal padding.
|
float |
getOffsetX() |
float |
getOffsetY() |
float |
getScrollStep() |
java.lang.String |
getTitle()
Gets the title.
|
int |
getVerticalPadding()
Gets the vertical padding.
|
void |
onAddedToScreen()
Called when this
UIComponent is added to screen. |
void |
onClose() |
void |
onComponentSpaceChange(SpaceChangeEvent event)
Called when a child
UIComponent gets its size or position changed |
void |
onComponentStateChange(StateChangeEvent.VisibleStateChange event)
Called when a child
UIComponent gets its visibility changed |
void |
onContentUpdate()
Called when this
UIComponent gets its content updated. |
void |
remove(UIComponent component)
Removes the component from this
UIContainer . |
void |
removeAll()
Removes all the components from this
UIContainer . |
void |
setClipContent(boolean clipContent)
Sets whether this
UIContainer should clip its contents |
T |
setDisabled(boolean disabled)
Sets the disabled.
|
void |
setOffsetX(float offsetX,
int delta) |
void |
setOffsetY(float offsetY,
int delta) |
void |
setPadding(int horizontal,
int vertical)
Set the padding for this
UIContainer . |
UIContainer |
setTitle(java.lang.String title)
Sets the title for
UIContainer . |
T |
setVisible(boolean visible)
Sets the visible.
|
boolean |
shouldClipContent()
Checks whether this
UIContainer should clip its contents |
addControlComponent, draw, fireEvent, getAlpha, getAnchor, getGui, getHeight, getName, getParent, getPropertyString, getRawHeight, getRawWidth, getTooltip, getWidth, getX, getY, getZIndex, isDisabled, isFocused, isHovered, isInsideBounds, isRelativeHeight, isRelativeWidth, isVisible, onButtonPress, onButtonRelease, onClick, onDoubleClick, onDrag, onKeyTyped, onMouseMove, onRightClick, onScrollWheel, parentX, parentY, register, relativeX, relativeY, removeAllControlComponents, removeControlComponent, screenX, screenY, setAlpha, setAnchor, setFocused, setHovered, setName, setParent, setPosition, setPosition, setSize, setTooltip, setTooltip, setZIndex, toString, unregister
protected final java.util.Set<UIComponent> components
UIComponent
inside this UIContainer
.protected int horizontalPadding
UIContainer
.protected int verticalPadding
UIContainer
.protected UILabel titleLabel
UIContainer
.protected boolean clipContent
UIContainer
should clip its contents to its drawn area.protected int contentWidth
UIContainer
.protected int contentHeight
UIContainer
.protected int xOffset
UIContainer
from 0 to 1.protected int yOffset
UIContainer
from 0 to 1.public UIContainer(MalisisGui gui)
gui
- the guipublic UIContainer(MalisisGui gui, java.lang.String title)
UIContainer
.gui
- the guititle
- the titlepublic UIContainer(MalisisGui gui, int width, int height)
UIContainer
.gui
- the guiwidth
- the widthheight
- the heightpublic UIContainer(MalisisGui gui, java.lang.String title, int width, int height)
UIContainer
.gui
- the guititle
- the titlewidth
- the widthheight
- the heightpublic T setVisible(boolean visible)
setVisible
in class UIComponent<T extends UIContainer>
visible
- the visiblepublic T setDisabled(boolean disabled)
setDisabled
in class UIComponent<T extends UIContainer>
disabled
- the disabledpublic void setPadding(int horizontal, int vertical)
UIContainer
.horizontal
- the horizontalvertical
- the verticalpublic int getHorizontalPadding()
getHorizontalPadding
in interface IScrollable
UIContainer
.public int getVerticalPadding()
getVerticalPadding
in interface IScrollable
UIContainer
.public UIContainer setTitle(java.lang.String title)
title
- the titlepublic java.lang.String getTitle()
UIContainer
.public int componentX(UIComponent component)
UIComponent
inside this UIContainer
.componentX
in class UIComponent<T extends UIContainer>
component
- the componentpublic int componentY(UIComponent component)
UIComponent
inside this UIContainer
.componentY
in class UIComponent<T extends UIContainer>
component
- the componentpublic UIComponent getComponentAt(int x, int y)
getComponentAt
in class UIComponent<T extends UIContainer>
x
- the xy
- the yUIContainer
, this UIContainer
if none, or null if outside its bounds.public void onContentUpdate()
UIComponent
gets its content updated.public void calculateContentSize()
public ClipArea getClipArea()
ClipArea
.getClipArea
in interface IClipable
public void setClipContent(boolean clipContent)
UIContainer
should clip its contentssetClipContent
in interface IClipable
clipContent
- if true, clip contentspublic boolean shouldClipContent()
UIContainer
should clip its contentsshouldClipContent
in interface IClipable
public int getContentWidth()
getContentWidth
in interface IScrollable
public int getContentHeight()
getContentHeight
in interface IScrollable
public float getOffsetX()
getOffsetX
in interface IScrollable
public void setOffsetX(float offsetX, int delta)
setOffsetX
in interface IScrollable
public float getOffsetY()
getOffsetY
in interface IScrollable
public void setOffsetY(float offsetY, int delta)
setOffsetY
in interface IScrollable
public float getScrollStep()
getScrollStep
in interface IScrollable
public void add(UIComponent... components)
UIContainer
.components
- the componentspublic void remove(UIComponent component)
UIContainer
.component
- the componentpublic void removeAll()
UIContainer
. Does not remove control componentspublic void onAddedToScreen()
UIComponent
UIComponent
is added to screen.SpaceChangeEvent.SizeChangeEvent
is this component size is relative.onAddedToScreen
in class UIComponent<T extends UIContainer>
public void onClose()
onClose
in interface ICloseable
public void drawBackground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
drawBackground
in class UIComponent<T extends UIContainer>
renderer
- the renderermouseX
- the mouse xmouseY
- the mouse ypartialTick
- the partial tickpublic void drawForeground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
drawForeground
in class UIComponent<T extends UIContainer>
renderer
- the renderermouseX
- the mouse xmouseY
- the mouse ypartialTick
- the partial tickpublic void onComponentStateChange(StateChangeEvent.VisibleStateChange event)
UIComponent
gets its visibility changedevent
- the eventpublic void onComponentSpaceChange(SpaceChangeEvent event)
UIComponent
gets its size or position changedevent
- the event