1 type Canvas @mut = 2 inherit Panel 3 4 val exclude_width = List<Control>.new 5 val exclude_height = List<Control>.new 6 7 def Control.measure w h = 8 let mut canvas_width = 0 9 let mut canvas_height = 0 10 for control in items do 11 let item_width = if exclude_width.contains control 12 then Control.max_size 13 else w 14 15 measure_clamped control item_width Control.max_size 16 if not exclude_width.contains control then 17 canvas_width = canvas_width.max control.measure_width 18 19 if not exclude_height.contains control then 20 canvas_height = canvas_height.max control.measure_height 21 22 canvas_height = canvas_height.min h 23 24 measure_width = canvas_width 25 measure_height = canvas_height 26 27 def Control.arrange = 28 for control in items do 29 control.width = control.measure_width 30 height = control.measure_height 31 arrange 32