1    def measure_clamped (control : Control
2                         w : u32
3                         h : u32) =
4        control.measure (w.min control.max_width) (h.min control.max_height)
5    
6    def measure_single_child (control : Container
7                              w : u32
8                              h : u32) =
9        let maybe_child = control.get_slice.try_single
10       if maybe_child ? Some child then
11           if not child.is_visible then
12               child.measure_width = 0
13                     measure_height = 0
14           else
15               measure_clamped child w h
16   
17       let (res_w, res_h) =
18           if control.is_resizable
19              && control.measure_width <> 0
20              && control.measure_height <> 0
21           then
22               (control.width, control.height)
23           else
24               case maybe_child of
25                   None -> (0, 0)
26                   Some child -> (child.measure_width, child.measure_height)
27   
28       control.measure_width = res_w
29               measure_height = res_h
30