Class SwitchingLayout
-
- All Implemented Interfaces:
-
kotlin.Cloneable
public final class SwitchingLayout extends Component
A layout that is completely empty, but acts as a "handler", which moves layouts in and out of its position.
-
-
Field Summary
Fields Modifier and Type Field Description private final transient Layoutcurrentprivate final SwitchingLayoutPropertiespropertiesprivate 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 SwitchingLayout(SwitchingLayoutProperties properties, Vec2<Unit> at, Vec2<Unit> size, Boolean makesScrolling)
-
Method Summary
Modifier and Type Method Description final LayoutgetCurrent()SwitchingLayoutPropertiesgetProperties()final UnitswitchLayout(Layout new)Switches the given layout into this layout. UnitpreRender(Long deltaTimeNanos)pre-render functions, such as applying transforms. Unitrender()draw script for this drawable. UnitpostRender()Called after rendering, for functions such as removing transformations. Unitrecolor(PolyColor toColor, Animation.Type animation, Long durationNanos, Function1<Component, Unit> onFinish)Changes the color of the component to the specified color. Unitreset()Use this function to reset your drawable's PolyText if it is using one. Vec2<Unit>calculateSize()Implement this function to return the size of this drawable, if no size is specified during construction. -
Methods inherited from class org.polyfrost.polyui.component.Component
accept, addKeyframes, addOperation, calculateBounds, canBeRemoved, debugRender, draggable, every, getColor, getConsumesHover, getDisabled, getLayout, getParent, getSize, onColorsChanged, onFontsChanged, setColor, setConsumesHover, setDisabled, setLayout, setParent, setProperties, setSize, setup, toString, trueX, trueY, wantRedraw -
Methods inherited from class org.polyfrost.polyui.component.Drawable
addEventHandler, addEventhandler, animateBy, animateTo, 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, isInside, moveBy, moveTo, onInitComplete, onParentInitComplete, removeOperation, rescale, 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
-
SwitchingLayout
SwitchingLayout(SwitchingLayoutProperties properties, Vec2<Unit> at, Vec2<Unit> size, Boolean makesScrolling)
- Parameters:
size- the visible size of this layout.makesScrolling- iftrue, any layout that is switched into this will be able to scroll and not resized, otherwise, the layout will be resized to this size.
-
-
Method Detail
-
getCurrent
final Layout getCurrent()
-
getProperties
SwitchingLayoutProperties getProperties()
-
switchLayout
final Unit switchLayout(Layout new)
Switches the given layout into this layout.
-
preRender
Unit preRender(Long deltaTimeNanos)
pre-render functions, such as applying transforms. In this method, you should set needsRedraw to true if you have something to redraw for the next frame.
- Parameters:
deltaTimeNanos- the time in nanoseconds since the last frame.
-
postRender
Unit postRender()
Called after rendering, for functions such as removing transformations.
make sure to call super Drawable.postRender!
-
recolor
@Deprecated(message = "SwitchingLayouts cannot be drawn, animated, or colored") Unit recolor(PolyColor toColor, Animation.Type animation, Long durationNanos, Function1<Component, Unit> onFinish)
Changes the color of the component to the specified color. Supports animation and callback function on finish.
If the color is a Color.Gradient, this component's color will be changed to a gradient between the current color and the specified color.
If the color is a Color.Chroma, this component's color will be changed to a chroma color, keeping its current hue for consistency. Note: This will look wierd if the current color is a gradient, and the brightness, saturation and alpha are NOT animated, so will change instantly.
- Parameters:
toColor- The color to change the component to.animation- The type of animation to use.durationNanos- The duration of the animation in nanoseconds.onFinish- The callback function to execute when the color change animation finishes.- Since:
0.19.1
-
calculateSize
Vec2<Unit> calculateSize()
Implement this function to return the size of this drawable, if no size is specified during construction.
This should be so that if the drawable can determine its own size (for example, it is an image), then the size parameter in the constructor can be omitted using:
size: Vec2<org.polyfrost.polyui.unit.Unit>? = null;and this method needs to be implemented!Otherwise, the size parameter in the constructor must be specified.
-
-
-
-