
Widgets
In the Widget's perspective, the following methods are called, in this order:
- dispatchEvent (handleEvent) for every event queued by a Driver.
- preLayoutUpdate (handlePreLayoutUpdate), even if the layout is not dirty.
- Assuming the top-most Widget has a dirty layout:
- resolveDimensions (handleResolveDimensions). This calculates the ideal dimensions (width and height).
- resolvePosition. This calculates the ideal coordinates (X and Y).
- finalizeBounds. This rounds ideal dimensions and coordinates to the nearest scale-aligned whole pixels to prevent clipping artifacts.
- postLayoutUpdate (handlePostLayoutUpdate), even if the layout is not dirty.
- paint. If the Widget needs to be painted (marked as dirty), then the implementation method (handlePainting) is called, otherwise, the Widget is not painted (and neither are any of its children).
Roots
In the Root's perspective, the following methods are (normally) called, in this order:
- preLayoutUpdate, which calls update for each Driver attached to the Root, and calls preLayoutUpdate for the top-most Widget.
- resolveLayout, which calls the resolveDimensions, resolvePosition and finalizeBounds methods of the top-most Widget.
- postLayoutUpdate, which calls postLayoutUpdate for the top-most Widget.
- paint, which calls paint for the top-most Widget.
Note that DOMRoot already wraps all of these calls, in this order, in the update method.
Drivers are expected to accumulate events and, when their update method is called, dispatch those events to a relevant Root they are attached to.