DecorationModifierNode

A modifier node that is one step of its component's decoration, at the node's position in the modifier: it wraps every step declared after it and the component's own painting, and is wrapped by every step declared before it.

The element creating it must be additive, since that is what gives the node its position among the other steps; a node whose element is not additive is refused as it attaches. A child declares that element through decoration.

The library gathers outsets and isOpaque after each modifier pass that attaches, detaches, moves or writes a step, so an element's update needs no call for them. Decoration nodes automatically invalidate their component's declared-node consumer after an element update. A node with fixed metadata can opt out and own its repaint, as DrawModifierNode does. A node that changes one of them between passes calls invalidateDecoration. A change that only affects paint is a component.repaint(). The outsets a step reserves reach the component's insets under a Foundation container. Under any other parent only the part of them the component's PaintOutsets value leaves in layout does, none by default.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
val coroutineScope: CoroutineScope
Link copied to clipboard
Link copied to clipboard
open val isOpaque: Boolean

Whether painting through this decorator still covers every pixel of the area it is given; true by default.

Link copied to clipboard
open val outsets: Insets

How far this decorator paints past the content's box; nothing by default, and never negative.

Link copied to clipboard
open override val shouldAutoInvalidate: Boolean

An element update may change the metadata its component gathers from the declared decoration nodes.

Functions

Link copied to clipboard

Gathers the component's decoration again, after this step's outsets or isOpaque changed between modifier passes, and repaints it. An element's update needs no call. Does nothing while the node is not attached.

Link copied to clipboard
open fun needsPaintBounds(width: Int, height: Int): Boolean

Whether this decorator needs the component's paint bounds worked out, through paintBounds, while no visible child has an edge past the layout bounds and no decorator has outsets; true by default. A child with an edge past the layout bounds, or a decorator with outsets, has them worked out whatever this answers. Return false only when this decorator, in a box of width by height, cannot enlarge a box-sized content's paint bounds beyond its outsets.

Link copied to clipboard
override fun onAttach()

Refuses an element that is not additive. An element naming Decoratable as its target type is refused before this node is created; otherwise this node is refused if the component is not a Decoratable.

Link copied to clipboard
override fun onDetach()

Runs onRemovedFromDecoration. The component is handed the decoration without this step once the modifier pass ends.

Link copied to clipboard
open fun onReset()
Link copied to clipboard
abstract fun paint(graphics: Graphics2D, width: Int, height: Int, content: (Graphics2D, Int, Int) -> Unit)

Paints this decoration and, at the point of its own choosing, the content inside it.

Link copied to clipboard
open fun paintBounds(content: Shape, width: Int, height: Int): Shape

The area this decorator and its content can paint, in a box of width by height. The default includes the box and the content's bounds, grown by outsets. Override this when painting, clipping, or transforming content changes that area. The returned shape reserves paint space, not a clip. It also decides hit testing past the layout bounds: a press there reaches a child only where the paint bounds of a one-pixel content at the point cover the point.

Link copied to clipboard