Package-level declarations

Types

Link copied to clipboard
sealed interface ChildPlacement

How a node holds the children composed under it, as the node itself declares it on SwingNode.

Link copied to clipboard
class MirrorState<V> @RememberInComposition constructor(initial: V) : State<V>

Mirrors the value a widget property currently holds - a property the widget can change on its own, independently of the composition's declaration - and carries a change the composition has not answered for to the scope that declares it.

Link copied to clipboard
fun interface SlotAttachment

An attachment to a host that has its own method for holding children, such as JScrollPane.setViewportView, instead of the usual Container.add.

Link copied to clipboard
sealed interface SwingComponentNode

The node a Swing composition stores for one declared component, read off a node group of its CompositionData:

Link copied to clipboard

The receiver of the update block passed to SwingNode: the typed Swing component T is this inside set, update, init and reconcile.

Functions

Link copied to clipboard
fun <C : Component, V> SwingNodeUpdater<C>.declare(value: V, mirror: MirrorState<V>, read: C.() -> V, write: C.(V) -> Unit, onSettled: C.(V) -> Unit = {})

Declares value onto a widget property the user can also change, keeping mirror in sync with it.

fun <C : Component, V> SwingNodeUpdater<C>.declare(value: V, mirror: MirrorState<V>, read: C.() -> V, write: C.(held: V, declared: V) -> Unit, onSettled: C.(V) -> Unit = {})

Declares value onto a widget property whose write is a transition rather than an assignment: write is handed what the widget holds alongside what is declared, so it can write only the part that differs and leave what the rest of the value anchors standing - the caret inside a document, above all. The held value is the one the settlement has already read, so the write costs no second read.

Link copied to clipboard
@Composable
inline fun <T : Component> MenuNode(noinline factory: () -> T, modifier: SwingModifier = SwingModifier, crossinline update: @DisallowComposableCalls SwingNodeUpdater<T>.() -> Unit = {}, content: @Composable () -> Unit = {})

Emits one menu node into the surrounding MenuApplier composition: factory builds the backing Swing widget, update maps composition state onto it, and content supplies any nested menu items (empty for a leaf such as a single item or separator).

Link copied to clipboard
@Composable
fun <V> rememberMirrorState(initial: V): MirrorState<V>

Remembers the MirrorState a component settles a declaration through, seeded with initial - what the widget will actually hold on the first pass, which is not always what the composition declares for it: a ToolBar is always docked when it is built, whatever floating its first declaration asks for, so its seed is false rather than the declaration.

Link copied to clipboard
fun MirrorState<*>.report(onChanged: () -> Unit)

Carries to the caller a change the widget published on one channel and reports on another: onChanged runs and the settling pass follows it, as in MirrorState.report, but the value itself was mirrored through MirrorState.observed when the earlier channel carried it.

Link copied to clipboard
@Composable
inline fun <T : Component> SwingNode(noinline factory: () -> T, modifier: SwingModifier = SwingModifier, crossinline update: @DisallowComposableCalls SwingNodeUpdater<T>.() -> Unit = {}, noinline onRelease: T.() -> Unit? = null, childPlacement: ChildPlacement = ChildPlacement.Indexed)

Declares a leaf or container Swing node in the composition.

@Composable
inline fun <T : Component> SwingNode(noinline factory: () -> T, modifier: SwingModifier = SwingModifier, crossinline update: @DisallowComposableCalls SwingNodeUpdater<T>.() -> Unit = {}, noinline onRelease: T.() -> Unit? = null, childPlacement: ChildPlacement = ChildPlacement.Indexed, crossinline content: @Composable () -> Unit)

Container variant of SwingNode that hosts composable content as children.