Scrollable

abstract class Scrollable(at: Vec2, size: Vec2, visibleSize: Vec2, alignment: Align, val focusable: Boolean) : Inputtable

Extensions to Component which allow it to listen to scroll events and scroll itself.

Since

1.6.0

Inheritors

Constructors

Link copied to clipboard
constructor(at: Vec2, size: Vec2, visibleSize: Vec2, alignment: Align, focusable: Boolean)

Properties

Link copied to clipboard
@ApiStatus.Internal
@get:JvmName(name = "getParentOrNull")
var _parent: Component?
Link copied to clipboard
@get:JvmName(name = "acceptsInput")
var acceptsInput: Boolean
Link copied to clipboard

The alignment properties of this component, which control global padding and how it positions it children.

Link copied to clipboard
@get:JvmName(name = "getAt")
@set:JvmName(name = "setAt")
var at: Vec2
Link copied to clipboard
Link copied to clipboard
@get:JvmName(name = "createdWithSetPosition")
val createdWithSetPosition: Boolean

Returns true if this component had a position specified at creation time.

Link copied to clipboard
@get:JvmName(name = "createdWithSetSize")
val createdWithSetSize: Boolean

Returns `true if this component had a size specified at creation time.

Link copied to clipboard
@get:JvmName(name = "isFocusable")
val focusable: Boolean
Link copied to clipboard
@get:JvmName(name = "isFocused")
var focused: Boolean

focused flag for this component. Only ever true if focusable is true.

Link copied to clipboard
Link copied to clipboard
open var height: Float
Link copied to clipboard
Link copied to clipboard
@Dispatches(event = "Mouse.Entered", when = "value > INPUT_NONE")
@Dispatches(event = "Mouse.Exited", when = "value == INPUT_NONE")
@set:ApiStatus.Internal
var inputState: Byte

The current input state of this component. Note that this value is not responsible for dispatching events such as Event.Mouse.Exited or Event.Mouse.Pressed. It is just here for tracking purposes and for your benefit.

Link copied to clipboard
open override var isEnabled: Boolean

Disabled flag for this component. Dispatches the Event.Lifetime.Disabled and Event.Lifetime.Enabled events.

Link copied to clipboard

true if this drawable has any operations.

Link copied to clipboard
@ApiStatus.Internal
var layoutFlags: Byte

Flags that store various states of this component regarding the org.polyfrost.polyui.layout.LayoutController and resizing. Currently, the following is stored here:

Link copied to clipboard
@get:JvmName(name = "isLayoutIgnored")
var layoutIgnored: Boolean

If true, this component will be ignored during the org.polyfrost.polyui.layout.LayoutController's routine of placing components. Use this if you want to specify it manually based on something else, for example.

Link copied to clipboard
open var name: String

This is the name of this component, and you can use it to get components from a layout by ID, e.g:

Link copied to clipboard
Link copied to clipboard

Padding for this component. This is used by the positioner to ensure that there is adequate space around each object in the UI.

Link copied to clipboard
@SideEffects(values = ["_parent"])
var parent: Component
Link copied to clipboard
lateinit var polyUI: PolyUI
Link copied to clipboard
@get:JvmName(name = "isPositioned")
val positioned: Boolean

Returns true if this component has been initialized to the point where it has been positioned, e.g. Event.Lifetime.Init has been dispatched, and Event.Lifetime.PostInit is about to be.

Link copied to clipboard
@get:JvmName(name = "isRawResize")
var rawResize: Boolean

This property controls weather this component resizes "raw", meaning it will not respect the aspect ratio.

Link copied to clipboard
open var renders: Boolean

Whether this component should be rendered.

Link copied to clipboard
@get:JvmName(name = "screenAt")
override var screenAt: Vec2

Return the position of this component on the screen. This is used if scrolling or a similar mechanic means that its screen position is not the same as x and y.

Link copied to clipboard
@get:JvmName(name = "isScrolling")
val scrolling: Boolean
Link copied to clipboard
@get:JvmName(name = "isScrollingX")
val scrollingX: Boolean
Link copied to clipboard
@get:JvmName(name = "isScrollingY")
val scrollingY: Boolean
Link copied to clipboard
Link copied to clipboard
@get:JvmName(name = "getSize")
@set:JvmName(name = "setSize")
var size: Vec2
Link copied to clipboard
@get:JvmName(name = "isSizeValid")
val sizeValid: Boolean

returns true if the size of this component is valid (not zero)

Link copied to clipboard
@get:JvmName(name = "getVisibleSize")
@set:JvmName(name = "setVisibleSize")
open override var visibleSize: Vec2

The visible size of this component. This is used for clipping and scrolling.

Link copied to clipboard
open var width: Float
Link copied to clipboard
@SideEffects(values = ["x", "_x", "atValid", "this.children::x"], when = "value != x")
var x: Float
Link copied to clipboard
@SideEffects(values = ["y", "_y", "atValid", "this.children::y"], when = "value != y")
var y: Float

Functions

Link copied to clipboard
open override fun accept(event: Event): Boolean

called when this component receives an event.

Link copied to clipboard
@Locking(when = "children.size != 0")
fun addChild(vararg children: Component)

fun addChild(child: Component, recalculate: Boolean = true)

the runtime equivalent of adding children to this component during the constructor.

Link copied to clipboard
fun addOperation(vararg operations: ComponentOp)

@Locking(when = "operation.verify() == true")
fun addOperation(operation: ComponentOp): Boolean

Add a ComponentOp to this component.

Link copied to clipboard
fun at(index: Int, value: Float)

Set the position of this component programmatically. use this if you don't want to hardcode x or y (for example in mirroring or flipping).

Link copied to clipboard
@JvmName(name = "calculateSize")
open fun calculateSize(): Vec2

Use this function to calculate the size of this component. DO NOT include children in this calculation!

Link copied to clipboard
@ApiStatus.Experimental
fun clearHandlers()

Clear all event handlers for this component.

Link copied to clipboard
Link copied to clipboard
@JvmName(name = "contains")
operator fun contains(point: Vec2): Boolean
operator fun contains(box: Vec4): Boolean
Link copied to clipboard

Returns a count of this component's children, including children of children.

Link copied to clipboard
open fun debugString(): String?

Override this function to add things to the debug display of this component.

Link copied to clipboard
open fun extraToString(): String?

Supply extra information to the toString representation of this object. Keep it short.

Link copied to clipboard
open override fun fixVisibleSize()
Link copied to clipboard
open operator fun get(index: Int): Component
operator fun get(id: String): Component
operator fun get(x: Float, y: Float): Component
Link copied to clipboard
fun Component.hasChildIn(x: Float, y: Float, width: Float, height: Float): Boolean
Link copied to clipboard

returns true if this component has any non-specific event handlers registered for it.

returns true if this component has any specific event handlers registered for it.

Link copied to clipboard
fun intersects(x: Float, y: Float, width: Float, height: Float): Boolean
Link copied to clipboard

Returns true if this component is a child of the specified component.

Link copied to clipboard
Link copied to clipboard

Returns true if this component is a child of the specified component, or if the component is a child of this.

Link copied to clipboard

Locate a component by its name.

Link copied to clipboard
fun <E : Event, S : Inputtable> S.on(event: E, handler: S.(E) -> Boolean): S
@JvmName(name = "addEventhandler")
inline fun <E : Event, S : Inputtable> S.on(event: E, crossinline handler: S.(E) -> Unit): S
Link copied to clipboard
fun popScroll(renderer: Renderer)
Link copied to clipboard
@Locking(when = "this.children != null")
open fun position()

Reposition all the children of this component.

Link copied to clipboard
fun pushScroll(delta: Long, renderer: Renderer): Boolean
Link copied to clipboard
open override fun recalculate()

Fully recalculate this component's size, and any of its children's positions.

Link copied to clipboard
fun remove(recalculate: Boolean = true)

Remove this component from its parent.

Link copied to clipboard
fun removeChild(index: Int, recalculate: Boolean = true)
fun removeChild(child: Component, recalculate: Boolean = true)
Link copied to clipboard
@Locking(when = "operations != null")
fun removeOperation(componentOp: ComponentOp)

Remove an operation from this drawable.

Link copied to clipboard
fun rescale(scaleX: Float, scaleY: Float)

Method that is called when the physical size of the total window area changes.

Link copied to clipboard
open override fun rescale0(scaleX: Float, scaleY: Float, withChildren: Boolean)

raw rescale method that does not check rawResize and uses the given scale factors directly.

Link copied to clipboard

reset the initial scroll position to the current position.

Link copied to clipboard
operator fun set(old: Int, new: Component)

operator fun set(old: Component, new: Component?)

Replace a child of this component with another component.

Link copied to clipboard
open override fun setup(polyUI: PolyUI): Boolean

give this a PolyUI reference.

Link copied to clipboard
fun size(index: Int, value: Float)

Set the size of this component programmatically. use this if you don't want to hardcode width or height (for example in mirroring or flipping).

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
@Locking(when = "this.shouldScroll && this.hasVisibleSize && this.visibleSize > this.size")
fun tryMakeScrolling()