Resolver Struct
This page doesn't need deliberate learning, just read to have an impression. When developing views, directly use Resolver Derive Macro is enough.
Resolver is Flor framework's internal style/layout resolver, used to manage state variants, unit conversion and calculation cache. View authors usually don't need to directly operate Resolver, instead through Resolver Derive Macro automatically generate implementation.
Overview
Resolver core responsibilities:
- Store style variants under different
ControlState - Perform unit conversion through
UnitResolver - Cache calculation results, avoid repeated calculation
- Support multi-layer style stacking (layer)
View authors only need to know: Resolver will automatically select corresponding style variant based on current view state (Normal, Hover, Focus, Active, Disabled), and calculate final result.
new_with_compute_func
new_with_compute_func is Resolver's constructor entry, needs to pass ViewId and calculation function:
Calculation function signature:
It receives unit resolver and merged style variants, returns calculated data.
Example: LayoutResolver
LayoutResolver is an instance of Resolver, used to calculate Taffy layout style:
computed_layout function and LayoutResolver type are both automatically generated by #[derive(Resolver)] derive macro. It will traverse all layout variants, call UnitResolver for unit conversion, finally generate taffy::Style.
Cache Mechanism
Resolver internally maintains cache:
cache_data: Cache calculation results byControlStatedirty: Dirty flag, used to determine whether need to recalculate
When style variant changes, cache will be cleared. Getting data will automatically trigger calculation.
View authors don't need to care about cache details, only need to know: multiple calls to get_data_clone or get_data_borrow won't repeat calculation.
Usage Method
View authors shouldn't manually create Resolver. Correct way is:
- Define style enum, for example
Layoutor custom style type - Use
#[derive(Resolver)]derive macro to automatically generateResolverimplementation - Call generated
newmethod in view constructor
See Resolver Derive Macro for details.

