Class Button
-
- All Implemented Interfaces:
-
kotlin.Cloneable
public class Button extends ContainingComponent
A button, that supports two images and a text object.
- Since:
0.17.3
-
-
Field Summary
Fields Modifier and Type Field Description private final ButtonPropertiespropertiesprivate final transient ImageleftImageprivate final transient ImagerightImageprivate final transient Texttextprivate Stringstringprivate final ArrayList<Component>childrenprivate transient PolyColor.Animatedcolorprivate transient Drawableparentprivate transient Layoutlayoutprivate transient BooleanconsumesHoverprivate Booleandisabledprivate Vec2<Unit>sizeprivate final transient HashMap<Event, Function2<Drawable, Event, Boolean>>eventHandlersprivate transient StringsimpleNameprivate transient Rendererrendererprivate transient PolyUIpolyUIprivate BooleanacceptsInputprivate final transient ByteinitStageprivate final transient BooleanmouseOverprivate transient Booleanrendersprivate Floatxprivate Floatyprivate Floatwidthprivate Floatheightprivate Booleanexistsprivate transient FloattrueXprivate transient FloattrueYprivate final Unit.TypeatTypeprivate final Unit.TypesizeTypeprivate final BooleanisDynamicprivate Doublerotationprivate DoubleskewXprivate DoubleskewYprivate FloatscaleXprivate FloatscaleYprivate Floatalphaprivate transient Floatacxprivate transient Floatacyprivate final Vec2<Unit>atprivate final BooleanrawResize
-
Constructor Summary
Constructors Constructor Description Button(ButtonProperties properties, Vec2<Unit> at, Vec2<Unit> size, PolyImage left, Translator.Text text, Unit.Pixel fontSize, PolyImage right, Boolean acceptsInput, Function1<EventDSL<Button>, Unit> events)
-
Method Summary
Modifier and Type Method Description ButtonPropertiesgetProperties()final ImagegetLeftImage()final ImagegetRightImage()final TextgetText()final StringgetString()final UnitsetString(String string)BooleanrecolorRecolorsAll()Set this to truefor the recolor function to act as recolorAll.Unitrender()Render the children of this component. UnitcalculateBounds()Calculate the position and size of this drawable. -
Methods inherited from class org.polyfrost.polyui.component.ContainingComponent
addComponents, calculateChildBounds, clipDrawables, debugRender, getChildren, isInside, onColorsChanged, onFontsChanged, onParentInitComplete, preRender, recolor, recolorAll, removeComponents, rescale, reset, setup, trueX, trueY -
Methods inherited from class org.polyfrost.polyui.component.Component
accept, addKeyframes, addOperation, canBeRemoved, draggable, every, getColor, getConsumesHover, getDisabled, getLayout, getParent, getSize, setColor, setConsumesHover, setDisabled, setLayout, setParent, setProperties, setSize, toString, wantRedraw -
Methods inherited from class org.polyfrost.polyui.component.Drawable
addEventHandler, addEventhandler, animateBy, animateTo, calculateSize, clone, debugPrint, doDynamicSize, events, fadeBy, fadeTo, getAcceptsInput, getAcx, getAcy, getAlpha, getAt, getAtType, getContainingLayout, getEventHandlers, getExists, getHeight, getInitStage, getMouseOver, getPolyUI, getRawResize, getRenderer, getRenders, getRotation, getScaleX, getScaleY, getSimpleName, getSizeType, getSkewX, getSkewY, getTrueX, getTrueY, getWidth, getX, getY, intersects, isDynamic, isInside, moveBy, moveTo, onInitComplete, postRender, removeOperation, resize, rotateBy, rotateTo, scaleBy, scaleTo, setAcceptsInput, setAcx, setAcy, setAlpha, setExists, setHeight, setPolyUI, setRenderer, setRenders, setRotation, setScaleX, setScaleY, setSimpleName, setSkewX, setSkewY, setTrueX, setTrueY, setWidth, setX, setY, skewBy, skewTo -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
Button
Button(ButtonProperties properties, Vec2<Unit> at, Vec2<Unit> size, PolyImage left, Translator.Text text, Unit.Pixel fontSize, PolyImage right, Boolean acceptsInput, Function1<EventDSL<Button>, Unit> events)
- Parameters:
properties- The properties of the button (inherits from Block).size- You can specify this if you want to have more control over the height of this component, as if it isnullit is controlled by the largest item.left- The image to be displayed on the left side of the buttontext- The text to be displayed in the buttonfontSize- The font size of the text
-
-
Method Detail
-
getProperties
ButtonProperties getProperties()
-
getLeftImage
final Image getLeftImage()
-
getRightImage
final Image getRightImage()
-
recolorRecolorsAll
Boolean recolorRecolorsAll()
Set this to
truefor the recolor function to act as recolorAll.- Since:
0.21.4
-
render
Unit render()
Render the children of this component.
you must call super.render()!
-
calculateBounds
Unit calculateBounds()
Calculate the position and size of this drawable. Make sure to call doDynamicSize in this method to avoid issues with sizing.
This method is called once the layout is populated for children and component, and when a recalculation is requested.
The value of layout's bounds will be updated after this method is called, so do not use layout's bounds as an updated value in this method.
-
-
-
-