1 type Drawer 2 def draw_ui (transform : Matrix4) (control : Control) : Unit = 3 let m = if control.global_position == Vector3@zero 4 then transform 5 else let v = control.global_position 6 matrix/translate v.x v.y v.z 7 8 let mut did_save_scissors = false 9 if control.is_popup then 10 save_scissors 11 did_save_scissors = true 12 13 let mut did_push_scissor = false 14 if control is TextBox 15 || control is MultilineTextBox 16 || control is Scroller 17 || control is ScissorControl 18 then 19 let global_pos = control.global_position 20 let x = global_pos.x.max 0 21 let y = global_pos.y.max 0 22 let w = control.width as f32 + global_pos.x - x |> as<u32> 23 let h = control.height as f32 + global_pos.y - y |> as<u32> 24 push_scissor (Rect2D.create x.as<i32> y.as<i32> w h) 25 did_push_scissor = true 26 27 if control.maybe_drawable ? Some drawable then 28 create_object_if_not_present drawable 29 Field/Object 30 let object = drawable.field_objects[Field/Object] 31 object.transform = m 32 material = drawable.material 33 scissor = scissor_intersection 34 35 if drawable.color ? Some color then 36 object.color = color.with_w 1 37 38 renderer.add ui_camera object 39 40 if control is Container then 41 for item in control.get_slice do 42 if item.is_visible then 43 draw_ui m item 44 45 if did_push_scissor then 46 pop_scissor 47 48 if did_save_scissors then 49 restore_scissors 50 51 def update (dt : f32) (controls : List<Control>) = 52 renderer.clear 53 54 for control in controls do 55 draw_ui Matrix4.identity control 56 57 renderer/render renderers dt 58 vulkan.command_buffer.scissor Rect2D@zero 59 60 end@ drawer 61