vanilladocs
vanillapunch.com
API / ui/uicontrol

ui/uicontrol

UI 컨트롤. (원본 ui/uicontrol.js 의 UIControl)

  • 사용자 입력(터치)을 받는 위젯의 바탕. UIKit 의 UIControl 처럼 UIView 위에 선다.
  • 원본은 UIView 를 상속하고 이름만 바꾼다. 러스트 판은 UIView 를 품고 content, 배경색을 넘겨준다. UIButton, UISlider 가 이것을 품는다.

UI control. (UIControl of the original ui/uicontrol.js)

  • Base of widgets that take user input (touch). Sits on top of UIView like UIKit's UIControl.
  • The original inherits UIView and only changes the name. The Rust version embeds UIView and passes through content and the background color. UIButton and UISlider embed this.

UIControlstruct traits Default, Component

짝Counterpart: vanilla.js UIControl소스source

UI 컨트롤.

  • UIView 를 품고 content 노드와 배경색을 넘겨준다. 터치를 받는 위젯(UIButton, UISlider)이 이것을 품는다.

UI control.

  • Embeds UIView and passes through the content node and the background color. Widgets that take touches (UIButton, UISlider) embed this.
예제Example노드에 붙여 content 노드와 배경색 쓰기Attach to a node and use the content node and the background color
use vanilla::{Color, NodeTree, UIControl};

let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let control_id = node_tree.create_child(root_id, "control");
let control = node_tree.add_component(control_id, UIControl::new()).unwrap();
control.set_background_color("#334455");
assert!(control.get_content().is_some());
assert_eq!(control.get_background_color(), Color::from("#334455"));
assert_eq!(control.get_uiview().get_background_color(), control.get_background_color());
생성자constructorpub fn new() -> UIControl#0.3.2 부터since 0.3.2소스source

생성.

Constructor.

반환ReturnsUIControl 새 컨트롤. (content 노드는 트리에 붙일 때 만든다)New control. (the content node is created when attached to a tree)

짝Counterpart: vanilla.js UIControl.constructor

메서드methodpub fn get_uiview(&self) -> &UIView#0.3.2 부터since 0.3.2소스source

품은 뷰 반환.

Returns the embedded view.

반환Returns&UIView 품은 UIView 의 참조.Reference to the embedded UIView.

메서드methodpub fn get_uiview_mut(&mut self) -> &mut UIView#0.3.2 부터since 0.3.2소스source

품은 뷰 반환. (변경용)

Returns the embedded view. (mutable)

반환Returns&mut UIView 품은 UIView 의 바꿀 수 있는 참조.Mutable reference to the embedded UIView.

메서드methodpub fn get_content(&self) -> Option<NodeId>#0.3.2 부터since 0.3.2소스source

컨텐트 노드 핸들.

Content node handle.

반환ReturnsOption<NodeId> content 노드. 트리에 붙기 전이면 None.content node. None before being attached to a tree.

짝Counterpart: vanilla.js UIView.getContent

메서드methodpub fn set_background_color(&mut self, background_color: impl Into<Color>)#0.3.2 부터since 0.3.2소스source

배경색 설정.

Sets the background color.

background_colorimpl Into<Color>
배경색. (알파가 0 이면 칠하지 않는다)Background color. (not painted if alpha is 0)

짝Counterpart: vanilla.js UIView.setBackgroundColor

메서드methodpub fn get_background_color(&self) -> Color#0.3.2 부터since 0.3.2소스source

배경색 반환.

Returns the background color.

반환ReturnsColor 배경색. (기본은 알파 0 인 흰색)Background color. (default is white with alpha 0)

짝Counterpart: vanilla.js UIView.getBackgroundColor