1 def measure_margin (control : Control 2 left : u32 3 right : u32 4 up : u32 5 down : u32 6 maybe_content : Option<Control> 7 width : u32 8 height : u32) = 9 let (content_width, content_height) = case maybe_content of 10 None -> (0, 0) 11 Some content -> 12 let max_w = if width == 0 then 0 else width - left - right 13 let max_h = if height > up + down 14 then height - up - down 15 else 0 16 measure_clamped content max_w max_h 17 (content.measure_width, content.measure_height) 18 19 let w = left + right + content_width 20 let h = up + down + content_height 21 22 control.measure_width = w 23 measure_height = h 24 25 def arrange_margin (control : Decorator 26 left : u32 27 right : u32 28 up : u32 29 down : u32) = 30 let width = 31 let border_width = control.width 32 if border_width < left + right 33 then 0 34 else border_width - left - right 35 36 let height = 37 let border_height = control.height 38 if border_height < up + down 39 then 0 40 else border_height - up - down 41 42 arrange_offset control width height left up down 43