Interface Change
- All Known Implementing Classes:
Change.State,Change.TextEdit
Every value but a text edit is interned, so a notification allocates nothing; a text edit allocates one record per edit, and not one per watcher.
This is the payload of the watcher channel (Widget.observeChanges), which
hears every change to a widget whatever moved it. The other channel is the handler — the
fluent onX slot — which is the application's one response to the user operating the
widget, and which runs only for Change.Origin.USER. The whole rule is on Change.Origin.
A change carries no payload beyond the aspect and the origin: it says what changed, and the widget says what it is now. That keeps one type instead of one per widget, keeps every aspect free of boxing, and makes the accessor the single source of truth — at the price of one obligation, which is that no widget announces a state aspect that no public accessor answers.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumWhat about the widget changed.static enumWhat moved the change, and the whole of this record's rule: The handler runs when, and only when, the user operated this widget.static final classEvery aspect but a text edit;Change.State.aspect()is neverChange.Aspect.TEXT.static final recordA text edit:Change.TextEdit.aspect()is alwaysChange.Aspect.TEXT, soaspect() == TEXTandinstanceof Change.TextEditare the same question in both directions. -
Method Summary
Modifier and TypeMethodDescriptionaspect()static Change.TextEditedit(Change.Origin origin, int offset, int removed, int inserted) A text edit, with the offsets a platform text-changed event wants.default booleanfromUser()static Changeof(Change.Aspect aspect, Change.Origin origin) The interned value for this pair.origin()
-
Method Details
-
aspect
Change.Aspect aspect()- Returns:
- what about the widget changed
-
origin
Change.Origin origin()- Returns:
- what moved it
-
fromUser
default boolean fromUser()- Returns:
- whether the user operated the widget, which is the only origin a handler runs for
-
of
The interned value for this pair. Never allocates.- Parameters:
aspect- what changed; neverChange.Aspect.TEXTorigin- what moved it- Returns:
- the one instance for the pair
- Throws:
IllegalArgumentException- forChange.Aspect.TEXT, which onlyedit(limn.scene.Change.Origin, int, int, int)can make:TEXTis the one aspect a watcher may narrow on, so it must never arrive as aChange.Stateand give that watcher aClassCastExceptionat its own site, with no diagnostic anywhere near the component that announced it
-
edit
A text edit, with the offsets a platform text-changed event wants. Allocates one record per edit, and not one per watcher.- Parameters:
origin- what moved itoffset- where the damaged range begins, in charsremoved- how many chars it replacedinserted- how many chars it inserted- Returns:
- the edit
-