Class GridLayout
-
- All Implemented Interfaces:
-
kotlin.Cloneable
public final class GridLayout extends Layout
A grid layout is a simplistic layout that places components in a grid.
It is fully automatic, meaning that all components will be sized and placed automatically, based on two flags: cellSize and contentStretch.
It is recommended to use scrolling on this layout to set a viewport size for it, and so the user can scroll through the grid.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumGridLayout.CellSizepublic enumGridLayout.ContentStretch
-
Field Summary
Fields Modifier and Type Field Description private 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 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 GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, GridLayout.CellSize cellSize, GridLayout.ContentStretch contentStretch, Gap gap, Boolean resizesChildren, Drawable drawables)GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, GridLayout.CellSize cellSize, GridLayout.ContentStretch contentStretch, Gap gap, Drawable drawables)GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, GridLayout.CellSize cellSize, GridLayout.ContentStretch contentStretch, Drawable drawables)GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, GridLayout.CellSize cellSize, Drawable drawables)GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, Drawable drawables)GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, Drawable drawables)GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Drawable drawables)GridLayout(Vec2<Unit> at, Drawable drawables)
-
Method Summary
Modifier and Type Method Description Unitsetup(Renderer renderer, PolyUI polyUI)give this a renderer reference and a PolyUI reference. UnitcalculateBounds()Calculate the position and size of this drawable. -
Methods inherited from class org.polyfrost.polyui.layout.Layout
add, add, add, background, changeColors, changeFonts, clipDrawables, 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, remove, remove, removeNow, removeNow, render, rescale, reset, scrolling, setConsumesHover, setLayout, setNeedsRedraw, setPropertyManager, setRefuseFramebuffer, setSize, setVisibleSize, 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
-
GridLayout
GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, GridLayout.CellSize cellSize, GridLayout.ContentStretch contentStretch, Gap gap, Boolean resizesChildren, Drawable drawables)
-
GridLayout
GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, GridLayout.CellSize cellSize, GridLayout.ContentStretch contentStretch, Gap gap, Drawable drawables)
-
GridLayout
GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, GridLayout.CellSize cellSize, GridLayout.ContentStretch contentStretch, Drawable drawables)
-
GridLayout
GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, GridLayout.CellSize cellSize, Drawable drawables)
-
GridLayout
GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, PropertyManager propertyManager, Drawable drawables)
-
GridLayout
GridLayout(Vec2<Unit> at, Function2<Drawable, Added, Unit> onAdded, Function2<Drawable, Removed, Unit> onRemoved, Drawable drawables)
-
-
Method Detail
-
setup
Unit setup(Renderer renderer, PolyUI polyUI)
give this a renderer reference and a PolyUI reference.
You can also use this method to do some calculations (such as text widths) that are not dependent on other sizes.
If you need a method that has access to component's sizes, see here or here (if you are operating on yourself only).
this method is called once, and only once.
-
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.
-
-
-
-