zng_wgt_size_offset/
actual.rs1use zng_wgt::prelude::*;
2
3#[property(WIDGET_INNER - 1)]
5pub fn actual_size(child: impl IntoUiNode, size: impl IntoVar<DipSize>) -> UiNode {
6 let size = size.into_var();
7 match_node(child, move |c, op| {
8 if let UiNodeOp::Layout { wl, final_size } = op {
9 *final_size = c.layout(wl);
10 let f = LAYOUT.scale_factor();
11 let s = WIDGET.bounds().inner_size().to_dip(f);
13 if size.get() != s {
14 size.set(s);
16 }
17 }
18 })
19}
20
21#[property(LAYOUT)]
23pub fn actual_width(child: impl IntoUiNode, width: impl IntoVar<Dip>) -> UiNode {
24 let width = width.into_var();
25 match_node(child, move |c, op| {
26 if let UiNodeOp::Layout { wl, final_size } = op {
27 *final_size = c.layout(wl);
28 let f = LAYOUT.scale_factor();
29 let w = WIDGET.bounds().inner_size().width.to_dip(f);
30 if width.get() != w {
31 width.set(w);
32 }
33 }
34 })
35}
36
37#[property(LAYOUT)]
39pub fn actual_height(child: impl IntoUiNode, height: impl IntoVar<Dip>) -> UiNode {
40 let height = height.into_var();
41 match_node(child, move |c, op| {
42 if let UiNodeOp::Layout { wl, final_size } = op {
43 *final_size = c.layout(wl);
44 let f = LAYOUT.scale_factor();
45 let h = WIDGET.bounds().inner_size().height.to_dip(f);
46 if height.get() != h {
47 height.set(h);
48 }
49 }
50 })
51}
52
53#[property(LAYOUT)]
55pub fn actual_size_px(child: impl IntoUiNode, size: impl IntoVar<PxSize>) -> UiNode {
56 let size = size.into_var();
57 match_node(child, move |c, op| {
58 if let UiNodeOp::Layout { wl, final_size } = op {
59 *final_size = c.layout(wl);
60 let s = WIDGET.bounds().inner_size();
61 if size.get() != s {
62 size.set(s);
63 }
64 }
65 })
66}
67
68#[property(LAYOUT)]
70pub fn actual_width_px(child: impl IntoUiNode, width: impl IntoVar<Px>) -> UiNode {
71 let width = width.into_var();
72 match_node(child, move |c, op| {
73 if let UiNodeOp::Layout { wl, final_size } = op {
74 *final_size = c.layout(wl);
75 let w = WIDGET.bounds().inner_size().width;
76 if width.get() != w {
77 width.set(w);
78 }
79 }
80 })
81}
82
83#[property(LAYOUT)]
85pub fn actual_height_px(child: impl IntoUiNode, height: impl IntoVar<Px>) -> UiNode {
86 let height = height.into_var();
87 match_node(child, move |c, op| {
88 if let UiNodeOp::Layout { wl, final_size } = op {
89 *final_size = c.layout(wl);
90 let h = WIDGET.bounds().inner_size().height;
91 if height.get() != h {
92 height.set(h);
93 }
94 }
95 })
96}
97
98#[property(LAYOUT)]
100pub fn actual_transform(child: impl IntoUiNode, transform: impl IntoVar<PxTransform>) -> UiNode {
101 let transform = transform.into_var();
102 match_node(child, move |c, op| match &op {
103 UiNodeOp::Render { .. } | UiNodeOp::RenderUpdate { .. } => {
104 c.op(op);
105 let t = WIDGET.info().bounds_info().inner_transform();
106 if transform.get() != t {
107 transform.set(t);
108 }
109 }
110 _ => {}
111 })
112}
113
114#[property(LAYOUT)]
116pub fn actual_bounds(child: impl IntoUiNode, bounds: impl IntoVar<PxRect>) -> UiNode {
117 let bounds = bounds.into_var();
118 match_node(child, move |c, op| match &op {
119 UiNodeOp::Render { .. } | UiNodeOp::RenderUpdate { .. } => {
120 c.op(op);
121 let t = WIDGET.info().bounds_info().inner_bounds();
122 if bounds.get() != t {
123 bounds.set(t);
124 }
125 }
126 _ => {}
127 })
128}