vanilladocs
vanillapunch.com
API / ui

ui

UI 위젯. (원본 src/ui 의 WorldNode 노선)

  • 원본처럼 위젯 대부분은 노드가 아니라 컴포넌트다. 노드에 붙이면 자기 노드(호스트)를 위젯으로 쓴다.
  • 자식 노드(content, 스크롤바)나 짝 컴포넌트(Mask)를 만드는 위젯은 node_tree.add_component(node_id, ...) 로 붙인다. WorldNode::add_component 로 붙이면 attach_to_tree 가 불리지 않아 content 노드가 없고 터치도 켜지지 않는다.
  • 원본 UIScrollBar 는 WorldNode 를 상속한 노드다. 러스트 판은 노드 하나에 붙는 UIScrollBar 컴포넌트다.
  • UIInputField 는 엔진 글 입력 줄(core/textinput.rs)에서 키, IME, 웹 숨긴 DOM 입력의 이벤트를 받는다.
  • 원본에서 WorldNode 를 상속한 위젯(UIDropdown, UIDialog, UIToast, UISpinner, UIContextMenu)도 호스트 노드에 붙는 컴포넌트다. 붙을 때 원본 생성자처럼 호스트를 꾸미고 자식 노드를 만든다. 각 위젯의 create(node_tree, parent_id, options) 가 new + add_child 자리다.
  • UINode, 오토레이아웃(autolayout), UIScene 노선도 옮겼다. (UIDocument 는 리플렉션 대신 종류 이름 표로 옮겼다)

UI widgets. (the WorldNode line of the original src/ui)

  • As in the original, most widgets are components, not nodes. Attached to a node, they use their own node (the host) as the widget.
  • Widgets that create child nodes (content, scroll bars) or companion components (Mask) are attached with node_tree.add_component(node_id, ...). If attached with WorldNode::add_component, attach_to_tree is not called, so there is no content node and touch is not enabled.
  • The original UIScrollBar is a node inheriting WorldNode. The Rust version is a UIScrollBar component attached to a single node.
  • UIInputField receives key, IME and hidden web DOM input events from the engine text input queue (core/textinput.rs).
  • Widgets that inherit WorldNode in the original (UIDropdown, UIDialog, UIToast, UISpinner, UIContextMenu) are also components attached to a host node. When attached, they set up the host and create child nodes like the original constructors. Each widget's create(node_tree, parent_id, options) takes the place of new + add_child.
  • The UINode, auto layout (autolayout) and UIScene lines were also ported. (UIDocument was ported with a type name table instead of reflection)