1 type TextBlock 2 let materials : Materials @auto 3 4 val is_multicolor = color@atom.map { _ == Vector3 1 1 1 } 5 val text_memory@atom = 6 (text@atom, font@atom, max_text_width@atom, is_rgba@atom, is_multicolor) 7 |> to_atom 8 |> map { self (text, font, max_w, is_rgba, is_multicolor) -> 9 string_mesh/create text font max_w is_rgba is_multicolor 10 self.allow_commands { fail } } 11 12 val memory@atom = text_memory@atom.map { Some _.memory } 13 val links@atom = text_memory@atom.map { _.links } 14 text_memory@atom.bind { offsets = _.offsets } |> push_token 15 16 val drawable = Drawable 17 mesh = Mesh.from_memory memory@atom 18 19 maybe_drawable = drawable 20 21 (font@atom, is_rgba@atom) 22 |> to_atom 23 |> bind { self (font, is_rgba) -> 24 self.drawable.material = if is_rgba 25 then self.materials.text_rgba font 26 else self.materials.text font } 27 |> push_token 28 29 color@atom.bind { drawable.color = _ } |> push_token 30 31 def Control.measure w h = 32 max_text_width = w 33 let res_w = text_memory.width 34 let res_h = text_memory.height 35 36 measure_width = res_w 37 measure_height = res_h 38