public class UISelect<T> extends UIComponent<UISelect<T>> implements java.lang.Iterable<UISelect.Option<T>>, IClipable
Modifier and Type | Class and Description |
---|---|
static class |
UISelect.Option<T>
The Class Option.
|
static class |
UISelect.SelectEvent<T>
Event fired when a
UISelect changes its selected UISelect.Option . |
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 GuiIcon |
arrowIcon
Icon used to draw the arrow.
|
protected GuiShape |
arrowShape
Shape used to draw the arrow.
|
protected int |
bgColor
Background color
|
protected int |
disabledTextColor |
protected com.google.common.base.Predicate<T> |
disablePredicate
Predicate for option disability
|
protected boolean |
expanded
Whether this
UISelect is expanded. |
protected int |
hoverBgColor
Hovered background color
|
protected int |
hoverTextColor
Hovered text color
|
protected GuiIcon |
iconsExpanded
Icon used to draw the option container.
|
protected GuiIcon |
iconsSelect
Icon used to draw this
UISelect . |
protected GuiIcon |
iconsSelectDisabled
Icon used to draw this
UISelect when disabled. |
protected com.google.common.base.Function<T,java.lang.String> |
labelFunction
Function for options label
|
protected java.lang.String |
labelPattern
Pattern to use for options labels.
|
protected int |
maxDisplayedOptions
Max number displayed options.
|
protected int |
maxExpandedWidth
Max width of the option container.
|
protected GuiShape |
optionBackground
Shape used to draw the hovered
UISelect.Option background |
protected com.google.common.base.Function<T,? extends UISelect.Option<T>> |
optionFunction
Function for option creation
|
protected com.google.common.collect.FluentIterable<UISelect.Option<T>> |
options
|
protected int |
optionsHeight
Height of displayed
UISelect.Option box |
protected GuiShape |
optionsShape
Shape used to draw the
options box |
protected int |
optionsWidth
Width of displayed
UISelect.Option box |
protected UISelect.Option<T> |
selectedOption
Currently selected option index.
|
protected int |
selectTextColor
Selected text color
|
protected int |
textColor
Text color.
|
protected boolean |
textShadow
Text shadow
|
Constructor and Description |
---|
UISelect(MalisisGui gui,
int width)
Instantiates a new
UISelect . |
UISelect(MalisisGui gui,
int width,
java.lang.Iterable<T> values)
Instantiates a new
UISelect . |
Modifier and Type | Method and Description |
---|---|
void |
drawBackground(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Called first when drawing this
UIComponent . |
void |
drawForeground(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Called last when drawing this
UIComponent . |
int |
getBgColor() |
ClipArea |
getClipArea()
Gets
ClipArea to be used for glScissor |
int |
getDisabledTextColor() |
int |
getHoverBgColor() |
int |
getHoverTextColor() |
UISelect.Option |
getOption(int y) |
UISelect.Option |
getOption(T obj)
Gets the
UISelect.Option corresponding to the object. |
protected UISelect.Option |
getOptionAt(int mouseX,
int mouseY)
Gets the
UISelect.Option at the speicfied coordinates. |
UISelect.Option |
getSelectedOption()
Gets the currently selected
UISelect.Option . |
T |
getSelectedValue()
Gets the value of the
selectedOption . |
int |
getSelectTextColor() |
int |
getTextColor() |
int |
getZIndex()
Gets the zIndex of this
UIComponent . |
boolean |
isInsideBounds(int x,
int y)
Checks if supplied coordinates are inside this
UIComponent bounds. |
boolean |
isTextShadow() |
java.util.Iterator<UISelect.Option<T>> |
iterator() |
UISelect<T> |
maxDisplayedOptions(int amount)
Sets the maximum number of options displayed when expanded.
|
boolean |
onClick(int x,
int y) |
boolean |
onKeyTyped(char keyChar,
int keyCode)
Called when a key is typed while this
UIComponent is focused or hovered. |
boolean |
onScrollWheel(int x,
int y,
int delta) |
T |
select(T obj)
Selects the
UISelect.Option for the specified value. |
T |
select(UISelect.Option<T> option)
Selects the
UISelect.Option . |
T |
selectFirst()
Selects the first
UISelect.Option of this UISelect . |
T |
selectLast()
Selects the last
UISelect.Option of this UISelect . |
T |
selectNext()
Select the
UISelect.Option after the currently selected one. |
T |
selectPrevious()
Selects the
UISelect.Option before the currently selected one. |
UISelect<T> |
setBgColor(int bgColor) |
void |
setClipContent(boolean clip)
Sets whether this
IClipable should clip or not. |
UISelect<T> |
setColors(int textColor,
int bgColor,
int hoverTextColor,
int hoverBgColor,
int selectTextColor,
int disabledTextColor,
boolean textShadow) |
UISelect<T> |
setDisabledTextColor(int disabledTextColor) |
UISelect<T> |
setDisablePredicate(com.google.common.base.Predicate<T> predicate) |
void |
setFocused(boolean focused)
Sets the
focused state of this UIComponent . |
UISelect<T> |
setHoverBgColor(int hoverBgColor) |
UISelect<T> |
setHoverTextColor(int hoverTextColor) |
UISelect<T> |
setLabelFunction(com.google.common.base.Function<T,java.lang.String> func) |
UISelect<T> |
setLabelPattern(java.lang.String labelPattern)
Sets a pattern that will be used to format the option label.
|
UISelect<T> |
setMaxExpandedWidth(int width)
Sets the max width of the option container.
|
UISelect<T> |
setOptionFunction(com.google.common.base.Function<T,? extends UISelect.Option<T>> func) |
UISelect<T> |
setOptions(java.lang.Iterable<T> values)
|
void |
setSelectedOption(T obj)
Sets the selected
UISelect.Option from its containing key. |
void |
setSelectedOption(UISelect.Option<T> option)
Sets the selected
UISelect.Option . |
UISelect<T> |
setSelectTextColor(int selectTextColor) |
UISelect<T> |
setTextColor(int textColor) |
UISelect<T> |
setTextShadow(boolean textShadow) |
boolean |
shouldClipContent()
Checks whether this
IClipable should clip or not. |
addControlComponent, componentX, componentY, draw, fireEvent, getAlpha, getAnchor, getComponentAt, getGui, getHeight, getName, getParent, getPropertyString, getRawHeight, getRawWidth, getTooltip, getWidth, getX, getY, isDisabled, isFocused, isHovered, isRelativeHeight, isRelativeWidth, isVisible, onAddedToScreen, onButtonPress, onButtonRelease, onDoubleClick, onDrag, onMouseMove, onRightClick, parentX, parentY, register, relativeX, relativeY, removeAllControlComponents, removeControlComponent, screenX, screenY, setAlpha, setAnchor, setDisabled, setHovered, setName, setParent, setPosition, setPosition, setSize, setTooltip, setTooltip, setVisible, setZIndex, toString, unregister
protected com.google.common.collect.FluentIterable<UISelect.Option<T>> options
protected UISelect.Option<T> selectedOption
protected int maxExpandedWidth
protected int maxDisplayedOptions
protected boolean expanded
UISelect
is expanded.protected int optionsWidth
UISelect.Option
boxprotected int optionsHeight
UISelect.Option
boxprotected java.lang.String labelPattern
protected com.google.common.base.Function<T,? extends UISelect.Option<T>> optionFunction
protected com.google.common.base.Function<T,java.lang.String> labelFunction
protected com.google.common.base.Predicate<T> disablePredicate
protected int textColor
protected int bgColor
protected int hoverTextColor
protected int hoverBgColor
protected int selectTextColor
protected int disabledTextColor
protected boolean textShadow
protected GuiShape arrowShape
protected GuiShape optionBackground
UISelect.Option
backgroundprotected GuiIcon iconsSelectDisabled
UISelect
when disabled.protected GuiIcon iconsExpanded
protected GuiIcon arrowIcon
public UISelect(MalisisGui gui, int width, java.lang.Iterable<T> values)
UISelect
.gui
- the guiwidth
- the widthvalues
- the valuespublic UISelect(MalisisGui gui, int width)
UISelect
.gui
- the guiwidth
- the widthpublic int getTextColor()
public int getBgColor()
public int getHoverTextColor()
public int getHoverBgColor()
public int getSelectTextColor()
public int getDisabledTextColor()
public boolean isTextShadow()
public UISelect<T> setColors(int textColor, int bgColor, int hoverTextColor, int hoverBgColor, int selectTextColor, int disabledTextColor, boolean textShadow)
public UISelect<T> setOptionFunction(com.google.common.base.Function<T,? extends UISelect.Option<T>> func)
public UISelect<T> setLabelFunction(com.google.common.base.Function<T,java.lang.String> func)
public UISelect<T> setDisablePredicate(com.google.common.base.Predicate<T> predicate)
public void setFocused(boolean focused)
UIComponent
focused
state of this UIComponent
.setFocused
in class UIComponent<UISelect<T>>
focused
- the statepublic UISelect<T> setLabelPattern(java.lang.String labelPattern)
labelPattern
- the label patternUISelect
public UISelect<T> setMaxExpandedWidth(int width)
width
- the widthUISelect
public UISelect<T> maxDisplayedOptions(int amount)
amount
- the amountUISelect
public UISelect<T> setOptions(java.lang.Iterable<T> values)
values
- the valuesUISelect
public UISelect.Option getOption(T obj)
UISelect.Option
corresponding to the object.obj
- the key of the Optionpublic UISelect.Option getOption(int y)
public void setSelectedOption(T obj)
UISelect.Option
from its containing key.obj
- the new selected optionpublic void setSelectedOption(UISelect.Option<T> option)
UISelect.Option
.option
- the new selected optionpublic UISelect.Option getSelectedOption()
UISelect.Option
.public T getSelectedValue()
selectedOption
.public T select(UISelect.Option<T> option)
UISelect.Option
.option
- the optionpublic T select(T obj)
UISelect.Option
for the specified value.obj
- the objpublic T selectFirst()
UISelect.Option
of this UISelect
.public T selectLast()
UISelect.Option
of this UISelect
.public T selectPrevious()
UISelect.Option
before the currently selected one.public T selectNext()
UISelect.Option
after the currently selected one.protected UISelect.Option getOptionAt(int mouseX, int mouseY)
UISelect.Option
at the speicfied coordinates.mouseX
- the mouse xmouseY
- the mouse ypublic boolean isInsideBounds(int x, int y)
UIComponent
UIComponent
bounds.isInsideBounds
in class UIComponent<UISelect<T>>
x
- the xy
- the ypublic int getZIndex()
UIComponent
UIComponent
.getZIndex
in class UIComponent<UISelect<T>>
public ClipArea getClipArea()
IClipable
ClipArea
to be used for glScissorgetClipArea
in interface IClipable
public void setClipContent(boolean clip)
IClipable
IClipable
should clip or not.setClipContent
in interface IClipable
clip
- the new clip contentpublic boolean shouldClipContent()
IClipable
IClipable
should clip or not.shouldClipContent
in interface IClipable
public void drawBackground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
UIComponent
UIComponent
.drawBackground
in class UIComponent<UISelect<T>>
renderer
- the renderermouseX
- the mouse xmouseY
- the mouse ypartialTick
- the partial tickpublic void drawForeground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
UIComponent
UIComponent
.drawForeground
in class UIComponent<UISelect<T>>
renderer
- the renderermouseX
- the mouse xmouseY
- the mouse ypartialTick
- the partial tickpublic boolean onClick(int x, int y)
onClick
in class UIComponent<UISelect<T>>
public boolean onScrollWheel(int x, int y, int delta)
onScrollWheel
in class UIComponent<UISelect<T>>
public boolean onKeyTyped(char keyChar, int keyCode)
UIComponent
UIComponent
is focused or hovered.onKeyTyped
in class UIComponent<UISelect<T>>
keyChar
- the key charkeyCode
- the key codepublic java.util.Iterator<UISelect.Option<T>> iterator()
iterator
in interface java.lang.Iterable<UISelect.Option<T>>