zng_wgt_inspector/
lib.rs
1#![doc(html_favicon_url = "https://raw.githubusercontent.com/zng-ui/zng/main/examples/image/res/zng-logo-icon.png")]
2#![doc(html_logo_url = "https://raw.githubusercontent.com/zng-ui/zng/main/examples/image/res/zng-logo.png")]
3#![doc = include_str!(concat!("../", std::env!("CARGO_PKG_README")))]
9#![warn(unused_extern_crates)]
10#![warn(missing_docs)]
11
12zng_wgt::enable_widget_macros!();
13
14use zng_wgt::{ICONS, prelude::*};
15
16pub mod crash_handler;
17pub mod debug;
18
19mod live;
20
21command! {
22 pub static INSPECT_CMD = {
24 l10n!: "inspector",
25 name: "Debug Inspector",
26 info: "Inspect the window",
27 shortcut: [shortcut!(CTRL|SHIFT+'I'), shortcut!(F12)],
28 icon: wgt_fn!(|_| ICONS.get(["inspector", "screen-search-desktop"])),
29 };
30}
31
32#[property(WIDGET)]
34pub fn inspector(child: impl UiNode, mut inspector: impl UiNode) -> impl UiNode {
35 match_node(child, move |c, op| match op {
36 UiNodeOp::Measure { wm, desired_size } => {
37 *desired_size = c.measure(wm);
38 LAYOUT.with_constraints(PxConstraints2d::new_exact_size(*desired_size), || {
39 let _ = inspector.measure(wm);
40 });
41 }
42 UiNodeOp::Layout { wl, final_size } => {
43 *final_size = c.layout(wl);
44 LAYOUT.with_constraints(PxConstraints2d::new_exact_size(*final_size), || {
45 let _ = inspector.layout(wl);
46 });
47 }
48 mut op => {
49 c.op(op.reborrow());
50 inspector.op(op);
51 }
52 })
53}
54
55#[cfg(feature = "live")]
56pub fn live_inspector(can_inspect: impl IntoVar<bool>) -> impl UiNode {
62 live::inspect_node(can_inspect)
63}