Class FlexLayout
-
- All Implemented Interfaces:
-
kotlin.Cloneable
public final class FlexLayout extends Layout
A flex layout that implements all the features of the Flexbox system.
This layout is very powerful, and is used commonly in web development. If you need to know more, I would recommend checking out the link above.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumFlexLayout.Directionpublic enumFlexLayout.Wrappublic enumFlexLayout.JustifyContentpublic enumFlexLayout.AlignItemspublic enumFlexLayout.AlignContent
-
Field Summary
Fields Modifier and Type Field Description private final transient ArrayList<Drawable>flexDrawablesprivate transient PropertyManagerpropertyManagerprivate final transient Colorscolorsprivate final transient FontFamilyfontsprivate final ArrayList<Component>componentsprivate final ArrayList<Layout>childrenprivate BooleanconsumesHoverprivate transient BooleanneedsRedrawprivate BooleanrefuseFramebufferprivate transient Layoutlayoutprivate final transient ArrayList<Function1<Layout, Unit>>initCompleteHooksprivate final transient Booleandraggableprivate Vec2<Unit>visibleSizeprivate Vec2<Unit>sizeprivate final BooleanresizesChildrenprivate final transient HashMap<Event, Function2<Drawable, Event, Boolean>>eventHandlersprivate transient StringsimpleNameprivate transient Rendererrendererprivate transient PolyUIpolyUIprivate BooleanacceptsInputprivate final transient ByteinitStageprivate final transient BooleanmouseOverprivate 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 FlexLayout(Vec2<Unit> at, Unit.Percent wrap, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, FlexLayout.AlignContent contentAlign, Boolean rawResize, Boolean resizesChildren, Boolean acceptInput, Gap gap, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, FlexLayout.AlignContent contentAlign, Boolean rawResize, Boolean resizesChildren, Boolean acceptInput, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, FlexLayout.AlignContent contentAlign, Boolean rawResize, Boolean resizesChildren, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, FlexLayout.AlignContent contentAlign, Boolean rawResize, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, FlexLayout.AlignContent contentAlign, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Drawable drawables)FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Drawable drawables)FlexLayout(Vec2<Unit> at, Drawable drawables)
-
Method Summary
Modifier and Type Method Description final ArrayList<Drawable>getFlexDrawables()Unitrescale(Float scaleX, Float scaleY)Method that is called when the physical size of the total window area changes. final Unitshuffle()Shuffles the drawables in this layout. Unitadd(Drawable drawable, Integer index)adds the given component/layout to this layout. Unitremove(Integer index)Removes a component from this layout at the specified index. Unitremove(Drawable drawable)removes a component from this layout. UnitremoveNow(Integer index)Removes a component from this layout immediately. UnitremoveNow(Drawable drawable)removes a component immediately, without waiting for it to finish up. UnitcalculateBounds()Calculate the position and size of this drawable. UnitclipDrawables()This function will enable/disable rendering of drawables inside this layout based on their position and size. final UnittrySetMainSize(Float new)-
Methods inherited from class org.polyfrost.polyui.layout.Layout
add, add, background, changeColors, changeFonts, countDrawables, debugPrint, debugRender, draggable, every, get, getChildren, getColors, getComponent, getComponents, getConsumesHover, getDraggable, getFonts, getInitCompleteHooks, getLayout, getLayout, getNeedsRedraw, getOrNull, getPropertyManager, getRefuseFramebuffer, getResizesChildren, getSize, getVisibleSize, intersects, isInside, isInside, onAll, onAllLayouts, onColorsChanged, onFontsChanged, onInitComplete, reRenderIfNecessary, render, reset, scrolling, setConsumesHover, setLayout, setNeedsRedraw, setPropertyManager, setRefuseFramebuffer, setSize, setVisibleSize, setup, toString, trueX, trueY -
Methods inherited from class org.polyfrost.polyui.component.Drawable
accept, addEventHandler, addEventhandler, addOperation, animateBy, animateTo, calculateSize, canBeRemoved, clone, 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, isDynamic, moveBy, moveTo, onParentInitComplete, postRender, preRender, 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
-
FlexLayout
FlexLayout(Vec2<Unit> at, Unit.Percent wrap, Drawable drawables)
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, FlexLayout.AlignContent contentAlign, Boolean rawResize, Boolean resizesChildren, Boolean acceptInput, Gap gap, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, FlexLayout.AlignContent contentAlign, Boolean rawResize, Boolean resizesChildren, Boolean acceptInput, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, FlexLayout.AlignContent contentAlign, Boolean rawResize, Boolean resizesChildren, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, FlexLayout.AlignContent contentAlign, Boolean rawResize, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, FlexLayout.AlignContent contentAlign, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, FlexLayout.AlignItems itemAlign, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, FlexLayout.JustifyContent contentJustify, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, FlexLayout.Wrap wrapDirection, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, FlexLayout.Direction flexDirection, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Function2<Drawable, Added, Unit> onAdded, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Unit wrap, Drawable drawables)
- Parameters:
size- The size of this layout.wrap- The wrap size of this layout.
-
FlexLayout
FlexLayout(Vec2<Unit> at, Vec2<Unit> size, Drawable drawables)
- Parameters:
size- The size of this layout.
-
-
Method Detail
-
getFlexDrawables
final ArrayList<Drawable> getFlexDrawables()
-
rescale
Unit rescale(Float scaleX, Float scaleY)
Method that is called when the physical size of the total window area changes.
-
add
Unit add(Drawable drawable, Integer index)
adds the given component/layout to this layout.
this will add the drawable to the Layout.components or children list, and invoke its Added if it is present.
-
remove
Unit remove(Integer index)
Removes a component from this layout at the specified index.
- Parameters:
index- The index of the component to be removed.- Since:
0.19.2
-
remove
Unit remove(Drawable drawable)
removes a component from this layout.
this will add the component to the removal queue, and invoke its removal event function.
This removal queue is used so that component can finish up any animations they're doing before being removed.
-
removeNow
Unit removeNow(Integer index)
Removes a component from this layout immediately.
- Parameters:
index- The index of the component to be removed.- Since:
0.19.2
-
removeNow
Unit removeNow(Drawable drawable)
removes a component immediately, without waiting for it to finish up.
This is marked as internal because you should be using remove for most cases to remove a component, as it waits for it to finish and play any removal animations.
-
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.
-
clipDrawables
Unit clipDrawables()
This function will enable/disable rendering of drawables inside this layout based on their position and size.
If they lie outside the bounds of this layout, they will not be drawn to save resources.
- Since:
0.21.4
-
trySetMainSize
final Unit trySetMainSize(Float new)
-
-
-
-