Module inspector

Module inspector 

Source
Expand description

Debug inspection helpers.

The properties in this module can be set on a window or widget to visualize layout and render internals.

The INSPECTOR service can be used to configure the inspector window, add custom watchers. Note that you can use the cmd::INSPECT_CMD command to open the Inspector.

§Examples

The example below registers two custom live updating watchers.

window::inspector::INSPECTOR.register_watcher(|wgt, builder| {
    // watch custom info metadata
    use zng::markdown::WidgetInfoExt as _;
    let watcher = wgt.info().map(|i| formatx!("{:?}", i.anchor()));
    builder.insert("markdown.anchor", watcher);

    // watch value that can change every layout/render without info rebuild
    let watcher = wgt.render_watcher(|i| formatx!("{:?}", i.bounds_info().inline().is_some()));
    builder.insert("is_inlined", watcher);
});

The closure is called on widget selection change (in the inspector screen), the values are presented in the /* INFO */ section of the properties panel.

§Full API

See zng_wgt_inspector for the full API.

Structs§

INSPECTOR
Service that configures the live inspector.
InspectedInfo
InspectorInfo that can be placed in a variable.
InspectedTree
Represents an actively inspected widget tree.
InspectedWidget
Represents an actively inspected widget.
InspectorWatcherBuilder
Builder for INSPECTOR.register_watcher.

Enums§

InspectMode
Target of inspection properties.

Functions§

show_bounds
P Draws a border for every target widget’s outer and inner bounds.
show_center_points
P Draws a debug dot in target widget’s center point.
show_directional_query
P Draw the directional query for closest sibling of the hovered focusable widget.
show_hit_test
P Draws the inner bounds that where tested for the mouse point.
show_rows
P Draws a border over every inlined widget row in the window.