The widget API makes some requirements of the call order of methods.
Should we add a tracker to enforce this (in debug builds)?
Rules
Rules (x: y → z means that after x changes/happens, y must happen before z):
init: configure → update
init: configure → size_rules
init: size_rules (x-axis) → size_rules (y-axis)
init: size_rules (y-axis) → set_rect
init, resize: set_rect → find_id
init, resize: set_rect → draw
init, data change: update → draw
size_rules: set_rect → draw (maybe?)
init: configure → nav_next (maybe?)
init: configure → handle_event (and other handlers)
Failure to respect these rules can cause issues, e.g. invalid WidgetId (due to something before configure) or out-of-range in MatrixView due to set_rect then draw before the requested re-configure.
The widget API makes some requirements of the call order of methods.
Should we add a tracker to enforce this (in debug builds)?
Rules
Rules (x: y → z means that after x changes/happens, y must happen before z):
Failure to respect these rules can cause issues, e.g. invalid
WidgetId
(due to something before configure) or out-of-range inMatrixView
due toset_rect
thendraw
before the requested re-configure
.Proposal
Add an enum like:
(Note: this omits "data change" since the widget cannot reliably detect this.)
Add a
status: WidgetStatus
field towidget_core!()
(in debug builds).Add shims around all relevant widget methods which test and update this status. Problem: we need a solution to #407.