Document

Represents a document with a hierarchical structure of elements, styles, and layout capabilities. The Document class manages the layout and styling system by utilizing a Layouter and an observable list of stylesheets.

Features include:

  • The ability to manage styles through a list of StyleSheet objects.

  • Automatic tracking of changes to stylesheets to ensure layout updates are performed when necessary.

  • Support for laying out the document body based on computed styles from the provided stylesheets.

  • A controllable lifecycle to clean up resources when the document is no longer in use.

Implements AutoCloseable to ensure that resources such as controlManager, styleSheets, and body are cleaned up appropriately.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
var body: Body
Link copied to clipboard
Link copied to clipboard

The elements that were laid out again in the last layout, with their descendants, when not everything was laid out; null when everything was

Link copied to clipboard

true when the whole layout has to be computed again, like when the window is resized

Link copied to clipboard
Link copied to clipboard

the elements that asked for their layout to be computed again, see Element.requestLayout

Link copied to clipboard

What the media queries of the style sheets are evaluated against; when it changes in a way that changes which style sheets apply, the styles are computed again

Link copied to clipboard

Functions

Link copied to clipboard
fun Document.body(init: Body.() -> Unit): Body
Link copied to clipboard
open override fun close()
Link copied to clipboard
fun layout(adjustStyles: () -> Boolean = { false }): Boolean

Computes the styles that can have changed, and the layout when it can have changed. adjustStyles changes the computed styles before the layout, like transitions and animations do, and gives true when it changed properties that lay out.