1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
use freya::prelude::*;
use freya_core::integration::NodeId;
use crate::hooks::use_node_info;
#[derive(PartialEq)]
pub struct NodeInspectorComputedLayout {
pub node_id: NodeId,
pub window_id: u64,
}
impl Render for NodeInspectorComputedLayout {
fn render(&self) -> impl IntoElement {
let Some(node) = use_node_info(self.node_id, self.window_id) else {
return rect().into_element();
};
let inner_area = format!(
"{}x{}",
node.inner_area.width().round(),
node.inner_area.height().round()
);
let area = format!(
"{}x{}",
node.area.width().round(),
node.area.height().round()
);
let paddings = node.state.layout.padding;
let margins = node.state.layout.margin;
ScrollView::new()
.show_scrollbar(true)
.child(
rect()
.padding(20.)
.cross_align(Alignment::center())
.width(Size::fill())
.child(
rect()
.width(Size::fill())
.max_width(Size::px(300.))
.child(
label()
.height(Size::px(25.))
.text(format!("Area: {area}"))
)
.child(
rect()
.width(Size::fill())
.height(Size::px(250.))
.main_align(Alignment::center())
.cross_align(Alignment::center())
.background((197, 46, 139))
.content(Content::Flex)
.corner_radius(CornerRadius::new_all(5.))
.child(
// Top margin
TooltipContainer::new(Tooltip::new("Top margin"))
.child(
label()
.text_align(TextAlign::Center)
.width(Size::px(25.))
.height(Size::px(25.))
.text(format!("{}", margins.top()))
)
)
.child(
rect()
.direction(Direction::Horizontal)
.height(Size::flex(1.))
.width(Size::fill())
.cross_align(Alignment::center())
.content(Content::Flex)
.child(
// Left margin
TooltipContainer::new(Tooltip::new("Left margin"))
.child(
label()
.text_align(TextAlign::Center)
.width(Size::px(25.))
.height(Size::px(25.))
.text(format!("{}", margins.left()))
)
)
.child(
rect()
.width(Size::flex(1.))
.height(Size::fill())
.content(Content::Flex)
.cross_align(Alignment::Center)
.background((71, 180, 240))
.corner_radius(CornerRadius::new_all(5.))
.child(
// Top padding
TooltipContainer::new(Tooltip::new("Top padding"))
.child(
label()
.text_align(TextAlign::Center)
.width(Size::px(25.))
.height(Size::px(25.))
.text(format!("{}", paddings.top()))
)
)
.child(
rect()
.direction(Direction::Horizontal)
.height(Size::flex(1.))
.content(Content::Flex)
.cross_align(Alignment::center())
.child(
// Left padding
TooltipContainer::new(Tooltip::new("Left padding"))
.child(
label()
.text_align(TextAlign::Center)
.width(Size::px(25.))
.height(Size::px(25.))
.text(format!("{}", paddings.left()))
)
)
.child(
rect()
.width(Size::flex(1.))
.height(Size::fill())
.main_align(Alignment::center())
.cross_align(Alignment::center())
.background((40, 40, 40))
.corner_radius(CornerRadius::new_all(5.))
.child(
TooltipContainer::new(Tooltip::new("Inner area"))
.child(
label()
.text(inner_area.clone())
)
)
)
.child(
// Right padding
TooltipContainer::new(Tooltip::new("Right padding"))
.child(
label()
.text_align(TextAlign::Center)
.width(Size::px(25.))
.height(Size::px(25.))
.text(format!("{}", paddings.right()))
)
)
)
.child(
// Bottom padding
TooltipContainer::new(Tooltip::new("Bottom padding"))
.child(
label()
.text_align(TextAlign::Center)
.width(Size::px(25.))
.height(Size::px(25.))
.text(format!("{}", paddings.bottom()))
)
)
)
.child(
// Right margin
TooltipContainer::new(Tooltip::new("Right margin"))
.child(
label()
.text_align(TextAlign::Center)
.width(Size::px(25.))
.height(Size::px(25.))
.text(format!("{}", margins.right()))
)
)
)
.child(
// Bottom margin
TooltipContainer::new(Tooltip::new("Bottom margin"))
.child(
label()
.text_align(TextAlign::Center)
.width(Size::px(25.))
.height(Size::px(25.))
.text(format!("{}", margins.bottom())),
)
)
)
)
)
.into()
}
}