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 measure_clamped content max_w (height - up - down) 14 (content.measure_width, content.measure_height) 15 16 let w = left + right + content_width 17 let h = up + down + content_height 18 19 control.measure_width = w 20 measure_height = h 21 22 def arrange_margin (control : Decorator 23 left : u32 24 right : u32 25 up : u32 26 down : u32) = 27 let width = 28 let border_width = control.width 29 if border_width < left + right 30 then 0 31 else border_width - left - right 32 33 let height = 34 let border_height = control.height 35 if border_height < up + down 36 then 0 37 else border_height - up - down 38 39 arrange_offset control width height left up down 40