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 UiNode, state: impl IntoVar<bool>) -> impl 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§
- Accessibility metadata types.
- Helper types for inspecting an UI tree.
- Widget info tree iterators.
Structs§
- A hit-test hit.
- A hit-test result.
- Info about a segment in the first or last row of an inlined widget.
- Represents a
WidgetPath
annotated with each widget’sInteractivity
. - Represents the level of interaction allowed for a widget.
- Argument for a interactivity filter function.
- Represents a builder split from the main builder that can be used in parallel and then folded back onto the main builder.
TRANSFORM_CHANGED_EVENT
args.VISIBILITY_CHANGED_EVENT
args.- Shared reference to the combined border and corner radius of a
WidgetInfo
. - Shared reference to layout size, offsets, rendered transforms and bounds of a widget.
- Represents the descendants of a widget, allows checking if widgets are descendant with O(1) time.
- Reference to a widget info in a
WidgetInfoTree
. - Widget info tree builder.
- A tree of
WidgetInfo
. - Stats over the lifetime of a widget info tree.
- Info about the inlined rows of the widget.
- Info about the input inline connecting rows of the widget.
- Full address of a widget.
Enums§
- Hit-test result on a widget relative to it’s descendants.
- Widget tree filter selected for a widget in the tree.
- Tag for the
WidgetInfo::meta
state-map.
Statics§
- Widget interactivity has changed after an info update.
- A widget global inner transform has changed after render.
- Widget visibility has changed after render.
- A window widget tree was rebuild.