Module info

Module info 

Source
Expand description

Widget info tree and info builder.

§Examples

The example declares a new info state for widgets and a property that sets the new state. The new state is then used in a widget.

mod custom {
    use zng::prelude_wgt::*;

    static_id! {
        static ref STATE_ID: StateId<bool>;
    }

    #[property(CONTEXT)]
    pub fn flag_state(child: impl IntoUiNode, state: impl IntoVar<bool>) -> UiNode {
        let state = state.into_var();
        match_node(child, move |_, op| match op {
            UiNodeOp::Init => {
                WIDGET.sub_var_info(&state);
            }
            UiNodeOp::Info { info } => {
                info.set_meta(*STATE_ID, state.get());
            }
            _ => {}
        })
    }

    pub trait StateExt {
        fn state(&self) -> Option<bool>;
    }
    impl StateExt for WidgetInfo {
        fn state(&self) -> Option<bool> {
            self.meta().get_clone(*STATE_ID)
        }
    }
}

Wgt! {
    custom::flag_state = true;
    widget::on_info_init = hn!(|_| {
        use custom::StateExt as _;
        let info = WIDGET.info();
        println!("state: {:?}", info.state());
    });
}

Modules§

access
Accessibility metadata types.
inspector
Helper types for inspecting an UI tree.
iter
Widget info tree iterators.

Structs§

HitInfo
A hit-test hit.
HitTestInfo
A hit-test result.
InlineSegmentInfo
Info about a segment in the first or last row of an inlined widget.
InteractionPath
Represents a WidgetPath annotated with each widget’s Interactivity.
Interactivity
Represents the level of interaction allowed for a widget.
InteractivityFilterArgs
Argument for a interactivity filter function.
ParallelBuilder
Represents a builder split from the main builder that can be used in parallel and then folded back onto the main builder.
WidgetBorderInfo
Shared reference to the combined border and corner radius of a WidgetInfo.
WidgetBoundsInfo
Shared reference to layout size, offsets, rendered transforms and bounds of a widget.
WidgetDescendantsRange
Represents the descendants of a widget, allows checking if widgets are descendant with O(1) time.
WidgetInfo
Reference to a widget info in a WidgetInfoTree.
WidgetInfoBuilder
Widget info tree builder.
WidgetInfoTree
A tree of WidgetInfo.
WidgetInfoTreeStats
Stats over the lifetime of a widget info tree.
WidgetInlineInfo
Info about the inlined rows of the widget.
WidgetInlineMeasure
Info about the input inline connecting rows of the widget.
WidgetPath
Full address of a widget.
WidgetTreeChangedArgs
WIDGET_TREE_CHANGED_EVENT args.

Enums§

RelativeHitZ
Hit-test result on a widget relative to it’s descendants.
TreeFilter
Widget tree filter selected for a widget in the tree.
WidgetInfoMeta
Tag for the WidgetInfo::meta state-map.

Statics§

WIDGET_TREE_CHANGED_EVENT
A window widget tree was rebuild.