1#![doc(html_favicon_url = "https://zng-ui.github.io/res/zng-logo-icon.png")]
2#![doc(html_logo_url = "https://zng-ui.github.io/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
21#[cfg(feature = "live")]
22pub use crate::live::data_model::{INSPECTOR, InspectedInfo, InspectedTree, InspectedWidget, InspectorWatcherBuilder, WeakInspectedTree};
23
24command! {
25 pub static INSPECT_CMD = {
27 l10n!: "inspector",
28 name: "Debug Inspector",
29 info: "Inspect the window",
30 shortcut: [shortcut!(CTRL | SHIFT + 'I'), shortcut!(F12)],
31 icon: wgt_fn!(|_| ICONS.get(["inspector", "screen-search-desktop"])),
32 };
33}
34
35#[property(WIDGET)]
37pub fn inspector(child: impl IntoUiNode, inspector: impl IntoUiNode) -> UiNode {
38 match_node(ui_vec![child, inspector], move |c, op| match op {
39 UiNodeOp::Measure { wm, desired_size } => {
40 c.delegated();
41 let children = c.node_impl::<UiVec>();
42 *desired_size = children[0].measure(wm);
43 LAYOUT.with_constraints(PxConstraints2d::new_exact_size(*desired_size), || {
44 let _ = children[1].measure(wm);
45 });
46 }
47 UiNodeOp::Layout { wl, final_size } => {
48 c.delegated();
49 let children = c.node_impl::<UiVec>();
50 *final_size = children[0].layout(wl);
51 LAYOUT.with_constraints(PxConstraints2d::new_exact_size(*final_size), || {
52 let _ = children[1].layout(wl);
53 });
54 }
55 _ => {}
56 })
57}
58
59#[cfg(feature = "live")]
60pub fn live_inspector(can_inspect: impl IntoVar<bool>) -> UiNode {
66 live::inspect_node(can_inspect)
67}