vanilladocs
vanillapunch.com
API / ui/uiscrollview

ui/uiscrollview

스크롤 뷰. (원본 ui/uiscrollview.js 의 UIScrollView, ScrollMode)

  • 호스트 content_size 를 보이는 영역으로 쓰고, content 노드를 끌거나 휠을 굴려 움직인다. 스크롤 오프셋 = content 노드의 로컬 위치.
  • 원본처럼 호스트에 Mask 를 붙여(require) content 를 자르고, 호스트를 interactable 로 켠다. node_tree.add_component(node_id, UIScrollView::new()) 로 붙인다.
  • 스크롤바(UIScrollBar 가 붙은 노드)는 원본 코드처럼 호스트의 자식(content 의 형제)으로 만든다.
  • 휠: 원본 TouchRaycaster.touchWheel → UIScrollView.wheel 길. 엔진이 터치 아래 노드부터 부모 쪽으로 wheel 을 묻고, 이 컴포넌트가 받아 쓴다.
  • 원본과 다른 것:
  • 원본은 set_scroll_offset / set_scroll_content_size / setShows...ScrollBar 에서 바로 노드를 바꾼다. 러스트 판의 씬 코드는 컴포넌트만 쥐고 있어 값을 정해 두고 다음 tick 에 content 노드와 스크롤바 노드에 반영한다. 같은 프레임에 바로 옮기려면 UIScrollView::set_scroll_offset_in_tree 를 쓴다.
  • 그래서 get_vertical_scroll_bar / get_horizontal_scroll_bar 는 보이기로 정한 뒤 첫 tick 이 지나야 노드 핸들을 돌려준다. 원본처럼 그 자리에서 스크롤바 노드를 만들고 켜려면 UIScrollView::set_shows_vertical_scroll_bar_in_tree(가로는 horizontal)를 쓴다. (만든 노드 핸들을 돌려준다)
  • 보이는 영역 크기(호스트 content_size)는 붙을 때와 tick / 터치 / 휠 때 읽어 둔다. 씬 코드에서 정한 오프셋은 다음 tick 에 새 크기로 다시 자른다.
  • 드래그를 위 스크롤 뷰로 넘기는 손짓(원본 TouchRecognizer)은 ui/touchrecognizer.rs 에 따로 있다. 씬이 골라 쓴다.
  • 원본 그대로인 버릇: 콘텐트가 영역 안에 들어와 스스로 꺼진(자동 숨김) 스크롤바 노드는 tick 이 돌지 않아 저절로 다시 켜지지 않는다. setShows...ScrollBar(true) 를 다시 부르면 켜진다.

Scroll view. (UIScrollView, ScrollMode of the original ui/uiscrollview.js)

  • Uses the host's content_size as the visible area and moves the content node by dragging or rolling the wheel. Scroll offset = local position of the content node.
  • As in the original, attaches a Mask to the host (require) to clip the content, and turns the host interactable. Attach with node_tree.add_component(node_id, UIScrollView::new()).
  • Scroll bars (nodes with UIScrollBar attached) are created as children of the host (siblings of content) as in the original code.
  • Wheel: the original TouchRaycaster.touchWheel → UIScrollView.wheel path. The engine asks for wheel from the node under the touch toward its parents, and this component consumes it.
  • Differences from the original:
  • The original changes nodes right away in set_scroll_offset / set_scroll_content_size / setShows...ScrollBar. Scene code in the Rust version holds only the component, so it sets the values and applies them to the content node and scroll bar nodes on the next tick. To move right away in the same frame, use UIScrollView::set_scroll_offset_in_tree.
  • So get_vertical_scroll_bar / get_horizontal_scroll_bar return a node handle only after the first tick following setting them to show. To create and turn on the scroll bar node on the spot as in the original, use UIScrollView::set_shows_vertical_scroll_bar_in_tree (horizontal for horizontal). (returns the created node handle)
  • The visible area size (host content_size) is read on attach and on tick / touch / wheel. An offset set from scene code is reclamped to the new size on the next tick.
  • The gesture that hands a drag over to the scroll view above (the original TouchRecognizer) is separate, in ui/touchrecognizer.rs. The scene chooses to use it.
  • A quirk kept from the original: a scroll bar node that turned itself off (auto hide) because the content fits in the area does not tick, so it does not turn back on by itself. Calling setShows...ScrollBar(true) again turns it on.

UIScrollViewstruct traits Default, Component

짝Counterpart: vanilla.js UIScrollView소스source

스크롤 뷰.

  • 호스트 content_size 가 보이는 영역이고, content 노드에 붙인 자식들이 오프셋만큼 움직인다. 오프셋은 0 에서 (보이는 크기 - 콘텐트 크기) 사이다.

Scroll view.

  • The host's content_size is the visible area, and children attached to the content node move by the offset. The offset is between 0 and (visible size - content size).
예제Example세로로 긴 목록을 담고 끝까지 내리기Hold a vertically long list and scroll to the end
use vanilla::{Engine, EngineConfiguration, NodeTree, Pivot, UIScrollView, Vector2};

let engine = Engine::new(EngineConfiguration::new());
let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let scroll_id = node_tree.create_child(root_id, "scroll");
node_tree[scroll_id].set_pivot(Pivot::TOP_LEFT);
node_tree[scroll_id].set_content_size(Vector2::create(200.0, 100.0));
let scroll_view = node_tree.add_component(scroll_id, UIScrollView::new()).expect("scroll view");
scroll_view.set_scroll_content_size(Vector2::create(200.0, 400.0));
let content_id = scroll_view.get_content().expect("content");
for index in 0..10 {
	let item_id = node_tree.create_child(content_id, "item");
	node_tree[item_id].set_pivot(Pivot::TOP_LEFT);
	node_tree[item_id].set_rect(0.0, index as f64 * 40.0, 200.0, 40.0);
}

let scroll_view = node_tree[scroll_id].get_component_mut::<UIScrollView>().expect("scroll view");
scroll_view.set_scroll_offset(Vector2::create(0.0, -1000.0));
assert_eq!(scroll_view.get_scroll_offset(), Vector2::create(0.0, -300.0));
node_tree.tick(&engine, 0.016);
assert_eq!(node_tree[content_id].get_local_position(), Vector2::create(0.0, -300.0));
assert_eq!(node_tree[content_id].get_content_size(), Vector2::create(200.0, 400.0));
생성자constructorpub fn new() -> UIScrollView#0.3.2 부터since 0.3.2소스source

생성.

  • 노드에 붙일 때는 node_tree.add_component 를 쓴다. (붙을 때 content 노드와 Mask 를 만들고 interactable 을 켠다)

Constructor.

  • Use node_tree.add_component to attach it to a node. (on attach, creates the content node and the Mask and turns interactable on)

반환ReturnsUIScrollView 가로 세로 모두 켜진, 오프셋 0, 클램프 모드의 새 스크롤 뷰. (스크롤바 없음, 배경 투명)New scroll view with both horizontal and vertical on, offset 0, clamp mode. (no scroll bars, transparent background)

짝Counterpart: vanilla.js UIScrollView.constructor

정적staticpub fn set_scroll_offset_in_tree(node_tree: &mut NodeTree, scroll_node_id: NodeId, offset: Vector2) -> bool#0.3.2 부터since 0.3.2소스source

트리 안에서 오프셋을 정하고 content 노드를 바로 옮긴다. (스크롤 뷰가 없거나 지금 꺼내져 있으면 false)

  • 스크롤바가 끌 때, 그리고 씬 코드가 같은 프레임에 바로 옮기고 싶을 때 쓴다.

Sets the offset within the tree and moves the content node right away. (false if there is no scroll view or it is currently taken out)

  • Used when a scroll bar is dragged, and when scene code wants to move it right away in the same frame.
node_tree&mut NodeTree
스크롤 뷰가 든 노드 트리.Node tree that holds the scroll view.
scroll_node_idNodeId
UIScrollView 가 붙은 노드.Node with a UIScrollView attached.
offsetVector2
새 오프셋. (픽셀, 그 노드의 지금 content_size 로 보이는 영역을 다시 읽어 범위로 자른다)New offset. (pixels, rereads the visible area from that node's current content_size and clamps to the range)

반환Returnsbool 정했으면 true. 노드가 없거나 UIScrollView 가 없으면(그 컴포넌트의 tick 중처럼 꺼내져 있을 때도) false.true if set. false if the node does not exist or has no UIScrollView (also when that component is taken out, as during its tick).

예제Examplecontent 노드를 그 자리에서 옮기기Move the content node on the spot
use vanilla::{NodeTree, Pivot, UIScrollView, Vector2};

let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let scroll_id = node_tree.create_child(root_id, "scroll");
node_tree[scroll_id].set_pivot(Pivot::TOP_LEFT);
node_tree[scroll_id].set_content_size(Vector2::create(200.0, 100.0));
let scroll_view = node_tree.add_component(scroll_id, UIScrollView::new()).expect("scroll view");
scroll_view.set_scroll_content_size(Vector2::create(200.0, 400.0));
let content_id = scroll_view.get_content().expect("content");

assert!(UIScrollView::set_scroll_offset_in_tree(&mut node_tree, scroll_id, Vector2::create(0.0, -80.0)));
assert_eq!(node_tree[content_id].get_local_position(), Vector2::create(0.0, -80.0));
assert!(!UIScrollView::set_scroll_offset_in_tree(&mut node_tree, root_id, Vector2::zero()));
정적staticpub fn set_shows_vertical_scroll_bar_in_tree(node_tree: &mut NodeTree, scroll_node_id: NodeId, shows: bool) -> Option<NodeId>#0.4.0 부터since 0.4.0소스source

세로 스크롤바 보이기 설정을 그 자리에서 노드에 건다. (원본 setShowsVerticalScrollBar 처럼 없으면 호스트의 자식으로 만들고 켜거나 끈다, 스크롤바 노드 핸들)

Applies the vertical scroll bar show setting to the node on the spot. (like the original setShowsVerticalScrollBar, creates it as a child of the host if missing and turns it on or off, scroll bar node handle)

node_tree&mut NodeTree
스크롤 뷰가 든 노드 트리.Node tree that holds the scroll view.
scroll_node_idNodeId
UIScrollView 가 붙은 노드.Node with a UIScrollView attached.
showsbool
true 면 만들어 켜고 false 면 있는 노드를 끈다.If true, creates and turns it on, if false, turns off the existing node.

반환ReturnsOption<NodeId> 세로 스크롤바 노드. 노드나 UIScrollView 가 없으면 None. 끄는데 아직 만든 노드가 없어도 None.Vertical scroll bar node. None if there is no node or UIScrollView. Also None when turning off and no node has been created yet.

예제Exampletick 없이 바로 만들고 끄기Create and turn off right away without a tick
use vanilla::{NodeTree, Pivot, UIScrollBar, UIScrollView, Vector2};

let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let scroll_id = node_tree.create_child(root_id, "scroll");
node_tree[scroll_id].set_pivot(Pivot::TOP_LEFT);
node_tree[scroll_id].set_content_size(Vector2::create(200.0, 100.0));
node_tree.add_component(scroll_id, UIScrollView::new());

let scroll_bar_id = UIScrollView::set_shows_vertical_scroll_bar_in_tree(&mut node_tree, scroll_id, true).expect("scroll bar");
assert_eq!(node_tree.get_parent_id(scroll_bar_id), Some(scroll_id));
assert!(node_tree[scroll_bar_id].get_component::<UIScrollBar>().is_some());
assert!(node_tree[scroll_bar_id].is_active());

assert_eq!(UIScrollView::set_shows_vertical_scroll_bar_in_tree(&mut node_tree, scroll_id, false), Some(scroll_bar_id));
assert!(!node_tree[scroll_bar_id].is_active());
assert!(UIScrollView::set_shows_horizontal_scroll_bar_in_tree(&mut node_tree, scroll_id, false).is_none());
정적staticpub fn set_shows_horizontal_scroll_bar_in_tree(node_tree: &mut NodeTree, scroll_node_id: NodeId, shows: bool) -> Option<NodeId>#0.4.0 부터since 0.4.0소스source

가로 스크롤바 보이기 설정을 그 자리에서 노드에 건다. (원본 setShowsHorizontalScrollBar)

  • 세로와 같은 꼴이다. (없으면 호스트의 자식으로 만들고 켜거나 끈다)

Applies the horizontal scroll bar show setting to the node on the spot. (original setShowsHorizontalScrollBar)

  • Same form as vertical. (creates it as a child of the host if missing and turns it on or off)
node_tree&mut NodeTree
스크롤 뷰가 든 노드 트리.Node tree that holds the scroll view.
scroll_node_idNodeId
UIScrollView 가 붙은 노드.Node with a UIScrollView attached.
showsbool
true 면 만들어 켜고 false 면 있는 노드를 끈다.If true, creates and turns it on, if false, turns off the existing node.

반환ReturnsOption<NodeId> 가로 스크롤바 노드. 노드나 UIScrollView 가 없으면 None. 끄는데 아직 만든 노드가 없어도 None.Horizontal scroll bar node. None if there is no node or UIScrollView. Also None when turning off and no node has been created yet.

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

품은 뷰 반환.

Returns the embedded view.

반환Returns&UIView 배경색과 content 노드를 든 품은 뷰.Embedded view holding the background color and the content node.

메서드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 품은 뷰의 가변 참조.Mutable reference to the embedded view.

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

컨텐트 노드 핸들. (스크롤할 자식 노드를 여기에 붙인다)

Content node handle. (attach child nodes to scroll here)

반환ReturnsOption<NodeId> content 노드. 트리에 붙기(node_tree.add_component) 전에는 None.content node. None before being attached to a tree (node_tree.add_component).

짝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>
보이는 영역의 바탕색. (기본 투명 (1, 1, 1, 0), 투명이면 그리지 않는다)Background color of the visible area. (default transparent (1, 1, 1, 0), not drawn if transparent)

짝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 배경색.Background color.

짝Counterpart: vanilla.js UIView.getBackgroundColor

메서드methodpub fn apply_scroll_offset(&mut self, offset: Vector2)#0.3.2 부터since 0.3.2소스source

오프셋 적용. (범위로 자른다. content 노드는 다음 반영 때 옮긴다)

  • set_scroll_offset 과 달리 다음 tick 에 다시 자르지 않는다. (지금 읽어 둔 보이는 영역 크기로만 자른다)

Applies the offset. (clamped to the range. the content node is moved on the next apply)

  • Unlike set_scroll_offset, it is not reclamped on the next tick. (clamped only with the currently read visible area size)
offsetVector2
새 오프셋. (픽셀, content 노드의 로컬 위치. x 는 (보이는 너비 - 콘텐트 너비) ~ 0, y 도 같은 꼴로 자른다. 끈 축은 0)New offset. (pixels, the local position of the content node. x is clamped to (visible width - content width) ~ 0, y likewise. 0 on a disabled axis)

짝Counterpart: vanilla.js UIScrollView.applyScrollOffset

메서드methodpub fn set_scroll_offset(&mut self, offset: Vector2)#0.3.2 부터since 0.3.2소스source

오프셋 설정. (씬 코드용. 다음 tick 에 그때의 영역 크기로 다시 잘라 content 를 옮긴다)

Sets the offset. (for scene code. on the next tick, reclamped to the area size at that time and the content is moved)

offsetVector2
새 오프셋. (픽셀, 아래로 내리면 y 가 음수. 지금 영역 크기로 바로 한 번 자른다)New offset. (pixels, y is negative when scrolled down. clamped once right away to the current area size)

짝Counterpart: vanilla.js UIScrollView.setScrollOffset

예제Example정한 오프셋은 바로 잘리고 content 는 다음 tick 에 옮겨진다The set offset is clamped right away and the content is moved on the next tick
use vanilla::{Engine, EngineConfiguration, NodeTree, Pivot, UIScrollView, Vector2};

let engine = Engine::new(EngineConfiguration::new());
let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let scroll_id = node_tree.create_child(root_id, "scroll");
node_tree[scroll_id].set_pivot(Pivot::TOP_LEFT);
node_tree[scroll_id].set_content_size(Vector2::create(200.0, 100.0));
let scroll_view = node_tree.add_component(scroll_id, UIScrollView::new()).expect("scroll view");
scroll_view.set_scroll_content_size(Vector2::create(200.0, 400.0));
let content_id = scroll_view.get_content().expect("content");

scroll_view.set_scroll_offset(Vector2::create(-50.0, -120.0));
assert_eq!(scroll_view.get_scroll_offset(), Vector2::create(0.0, -120.0));
assert_eq!(node_tree[content_id].get_local_position(), Vector2::zero());
node_tree.tick(&engine, 0.016);
assert_eq!(node_tree[content_id].get_local_position(), Vector2::create(0.0, -120.0));
메서드methodpub fn get_scroll_offset(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

오프셋 반환. (content 노드의 로컬 위치, 아래로 스크롤하면 y 가 음수)

Returns the offset. (local position of the content node, y is negative when scrolled down)

반환ReturnsVector2 지금 오프셋. (픽셀, 0 이하)Current offset. (pixels, 0 or less)

짝Counterpart: vanilla.js UIScrollView.getScrollOffset

메서드methodpub fn set_horizontal(&mut self, is_horizontal: bool)#0.3.2 부터since 0.3.2소스source

가로 스크롤 켜기 설정.

Sets whether horizontal scrolling is on.

is_horizontalbool
true 면 가로로 끌고 굴릴 수 있다. (기본 true) false 면 오프셋 x 를 0 으로 자른다.If true, it can be dragged and rolled horizontally. (default true) If false, offset x is clamped to 0.

짝Counterpart: vanilla.js UIScrollView.setHorizontal

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

가로 스크롤 켜짐 여부.

Whether horizontal scrolling is on.

반환Returnsbool 가로 스크롤이 켜져 있으면 true.true if horizontal scrolling is on.

짝Counterpart: vanilla.js UIScrollView.isHorizontal

메서드methodpub fn set_vertical(&mut self, is_vertical: bool)#0.3.2 부터since 0.3.2소스source

세로 스크롤 켜기 설정.

Sets whether vertical scrolling is on.

is_verticalbool
true 면 세로로 끌고 굴릴 수 있다. (기본 true) false 면 오프셋 y 를 0 으로 자른다.If true, it can be dragged and rolled vertically. (default true) If false, offset y is clamped to 0.

짝Counterpart: vanilla.js UIScrollView.setVertical

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

세로 스크롤 켜짐 여부.

Whether vertical scrolling is on.

반환Returnsbool 세로 스크롤이 켜져 있으면 true.true if vertical scrolling is on.

짝Counterpart: vanilla.js UIScrollView.isVertical

메서드methodpub fn set_passes_cross_axis_drag(&mut self, passes_cross_axis_drag: bool)#0.3.2 부터since 0.3.2소스source

스크롤하지 않는 축으로 끄는 손가락을 누른 노드에 남길지 설정. (기본 false, TouchRecognizer 가 읽는다)

Sets whether a finger dragging along the non-scrolling axis is left to the pressed node. (default false, read by TouchRecognizer)

passes_cross_axis_dragbool
true 면 한 축만 켠 스크롤 뷰가 다른 축 방향 드래그를 가져가지 않는다. (is_scroll_drag)If true, a scroll view with only one axis on does not take drags along the other axis. (is_scroll_drag)

짝Counterpart: vanilla.js UIScrollView.setPassesCrossAxisDrag

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

스크롤하지 않는 축으로 끄는 손가락을 누른 노드에 남기는지.

Whether a finger dragging along the non-scrolling axis is left to the pressed node.

반환Returnsbool 남기는 옵션이 켜져 있으면 true.true if the leave option is on.

짝Counterpart: vanilla.js UIScrollView.isPassingCrossAxisDrag

메서드methodpub fn is_scroll_drag(&self, delta_x: f64, delta_y: f64) -> bool#0.3.2 부터since 0.3.2소스source

끈 방향이 이 뷰가 가져갈 드래그인지. (스크롤하지 않는 축의 드래그를 남기는 옵션을 켰을 때만 가려낸다)

Whether the drag direction is a drag this view should take. (only distinguishes when the option to leave drags on the non-scrolling axis is on)

delta_xf64
끈 거리 x. (픽셀, 부호는 보지 않는다)Drag distance x. (pixels, the sign is ignored)
delta_yf64
끈 거리 y. (픽셀, 부호는 보지 않는다)Drag distance y. (pixels, the sign is ignored)

반환Returnsbool 가져갈 드래그면 true. 옵션이 꺼져 있거나 두 축이 다 켜져 있으면 늘 true. 세로만 켰으면 |y| >= |x| 일 때, 가로만 켰으면 |x| >= |y| 일 때 true. 두 축이 다 꺼져 있으면 false.true if it is a drag to take. Always true if the option is off or both axes are on. With only vertical on, true when |y| >= |x|, with only horizontal on, true when |x| >= |y|. false if both axes are off.

짝Counterpart: vanilla.js UIScrollView.isScrollDrag

예제Example세로 목록이 가로 드래그를 남기기A vertical list leaving horizontal drags alone
use vanilla::UIScrollView;

let mut scroll_view = UIScrollView::new();
scroll_view.set_horizontal(false);
assert!(scroll_view.is_scroll_drag(30.0, 2.0));

scroll_view.set_passes_cross_axis_drag(true);
assert!(!scroll_view.is_scroll_drag(30.0, 2.0));
assert!(scroll_view.is_scroll_drag(2.0, -30.0));
메서드methodpub fn set_drag_sensitivity(&mut self, drag_sensitivity: f64)#0.3.2 부터since 0.3.2소스source

드래그 반영량 배율 설정. (1 = 기본, 2 = 두 배 빠르게)

Sets the drag amount scale. (1 = default, 2 = twice as fast)

drag_sensitivityf64
끈 거리에 곱할 배율. (기본 1)Scale to multiply the drag distance by. (default 1)

짝Counterpart: vanilla.js UIScrollView.setDragSensitivity

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

드래그 반영량 배율 반환.

Returns the drag amount multiplier.

반환Returnsf64 드래그 배율.Drag scale.

짝Counterpart: vanilla.js UIScrollView.getDragSensitivity

메서드methodpub fn set_scroll_mode(&mut self, scroll_mode: ScrollMode)#0.3.2 부터since 0.3.2소스source

스크롤 모드 설정.

Sets the scroll mode.

scroll_modeScrollMode
경계 처리 모드. (기본 ScrollMode::Clamp)Boundary handling mode. (default ScrollMode::Clamp)

짝Counterpart: vanilla.js UIScrollView.setScrollMode

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

스크롤 모드 반환.

Returns the scroll mode.

반환ReturnsScrollMode 지금 스크롤 모드.Current scroll mode.

짝Counterpart: vanilla.js UIScrollView.getScrollMode

메서드methodpub fn set_scroll_content_size(&mut self, scroll_content_size: Vector2)#0.3.2 부터since 0.3.2소스source

스크롤 콘텐츠 크기 설정. (보이는 영역보다 커야 스크롤된다. content 노드 크기는 다음 tick 에 맞춘다)

Sets the scroll content size. (must be larger than the visible area to scroll. the content node size is fitted on the next tick)

scroll_content_sizeVector2
스크롤할 콘텐트 전체 크기. (픽셀, 기본 (0, 0))Total size of the content to scroll. (pixels, default (0, 0))

짝Counterpart: vanilla.js UIScrollView.setScrollContentSize

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

스크롤 콘텐츠 크기 반환.

Returns the scroll content size.

반환ReturnsVector2 콘텐트 전체 크기. (픽셀)Total content size. (pixels)

짝Counterpart: vanilla.js UIScrollView.getScrollContentSize

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

드래그 중인지.

Whether it is dragging.

반환Returnsbool 눌러 끄는 중이면 true. (떼거나 취소하면 false)true while pressing and dragging. (false after release or cancel)

짝Counterpart: vanilla.js UIScrollView.isDragging

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

지금 스크롤 속도 반환.

Returns the current scroll velocity.

반환ReturnsVector2 스크롤 속도. (픽셀/초) 탄성 모드에서만 셈하고, 클램프 모드는 누를 때 0 으로 비운 뒤 그대로다.Scroll velocity. (pixels/second) Calculated only in elastic mode, and in clamp mode it is reset to 0 on press and stays there.

짝Counterpart: vanilla.js UIScrollView.getScrollVelocity

메서드methodpub fn set_shows_vertical_scroll_bar(&mut self, shows: bool)#0.3.2 부터since 0.3.2소스source

세로 스크롤바 보이기 설정. (true 면 다음 tick 에 호스트의 자식으로 만들어 켠다)

Sets showing the vertical scroll bar. (if true, creates it as a child of the host and turns it on at the next tick)

showsbool
true 면 보이고 false 면 이미 만든 스크롤바 노드를 끈다. (기본 false)If true, shows it, if false, turns off the already created scroll bar node. (default false)

짝Counterpart: vanilla.js UIScrollView.setShowsVerticalScrollBar

예제Example첫 tick 뒤에 생기는 세로 스크롤바A vertical scroll bar that appears after the first tick
use vanilla::{Engine, EngineConfiguration, NodeTree, Pivot, UIScrollView, Vector2};

let engine = Engine::new(EngineConfiguration::new());
let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let scroll_id = node_tree.create_child(root_id, "scroll");
node_tree[scroll_id].set_pivot(Pivot::TOP_LEFT);
node_tree[scroll_id].set_content_size(Vector2::create(200.0, 100.0));
let scroll_view = node_tree.add_component(scroll_id, UIScrollView::new()).expect("scroll view");
scroll_view.set_scroll_content_size(Vector2::create(200.0, 400.0));
scroll_view.set_shows_vertical_scroll_bar(true);
assert!(scroll_view.get_vertical_scroll_bar().is_none());

node_tree.tick(&engine, 0.016);
let scroll_view = node_tree[scroll_id].get_component::<UIScrollView>().expect("scroll view");
let scroll_bar_id = scroll_view.get_vertical_scroll_bar().expect("scroll bar");
assert_eq!(scroll_view.get_inner_content_size(), Vector2::create(176.0, 100.0));
assert_eq!(node_tree[scroll_bar_id].get_content_size(), Vector2::create(12.0, 88.0));
메서드methodpub fn set_shows_horizontal_scroll_bar(&mut self, shows: bool)#0.3.2 부터since 0.3.2소스source

가로 스크롤바 보이기 설정.

  • 세로와 같은 꼴이다. (true 면 다음 tick 에 호스트의 자식으로 만들어 켠다)

Sets showing the horizontal scroll bar.

  • Same form as vertical. (if true, creates it as a child of the host and turns it on at the next tick)
showsbool
true 면 보이고 false 면 이미 만든 스크롤바 노드를 끈다. (기본 false)If true, shows it, if false, turns off the already created scroll bar node. (default false)

짝Counterpart: vanilla.js UIScrollView.setShowsHorizontalScrollBar

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

세로 스크롤바 노드 핸들. (꾸밀 때 node_tree[id].get_component_mut::<UIScrollBar>())

Vertical scroll bar node handle. (node_tree[id].get_component_mut::<UIScrollBar>() to customize)

반환ReturnsOption<NodeId> 세로 스크롤바 노드. 아직 만들지 않았으면 None. (set_shows_vertical_scroll_bar 뒤 첫 tick 이 지나야 생긴다)Vertical scroll bar node. None if not created yet. (appears after the first tick following set_shows_vertical_scroll_bar)

짝Counterpart: vanilla.js UIScrollView.getVerticalScrollBar

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

가로 스크롤바 노드 핸들.

Horizontal scroll bar node handle.

반환ReturnsOption<NodeId> 가로 스크롤바 노드. 아직 만들지 않았으면 None.Horizontal scroll bar node. None if not created yet.

짝Counterpart: vanilla.js UIScrollView.getHorizontalScrollBar

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

세로 스크롤바가 차지하는 폭. (보이는 중일 때만)

Width taken by the vertical scroll bar. (only while shown)

반환Returnsf64 보이기로 정했고 노드가 있으면 24 (두께 12 + 여백 6 의 두 배, 픽셀), 아니면 0.24 if set to show and the node exists (twice thickness 12 + margin 6, pixels), otherwise 0.

짝Counterpart: vanilla.js UIScrollView.getVerticalScrollBarReservedWidth

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

가로 스크롤바가 차지하는 높이. (보이는 중일 때만)

Height taken by the horizontal scroll bar. (only while shown)

반환Returnsf64 보이기로 정했고 노드가 있으면 24 (두께 12 + 여백 6 의 두 배, 픽셀), 아니면 0.24 if set to show and the node exists (twice thickness 12 + margin 6, pixels), otherwise 0.

짝Counterpart: vanilla.js UIScrollView.getHorizontalScrollBarReservedHeight

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

스크롤바를 뺀, 콘텐트가 그려질 수 있는 보이는 영역 크기.

Visible area size where content can be drawn, excluding the scroll bars.

반환ReturnsVector2 보이는 영역에서 스크롤바 자리를 뺀 크기. (픽셀, 0 아래로 내려가지 않는다. 보이는 영역은 붙을 때와 tick, 터치, 휠 때 읽어 둔 값)Size of the visible area minus the scroll bar space. (pixels, never below 0. the visible area is the value read on attach and on tick, touch, wheel)

짝Counterpart: vanilla.js UIScrollView.getInnerContentSize

메서드methodpub fn set_wheel_scroll_scale(&mut self, wheel_scroll_scale: f64)#0.3.2 부터since 0.3.2소스source

휠 스크롤 배율 설정.

Sets the wheel scroll multiplier.

wheel_scroll_scalef64
휠 값에 곱할 배율. (기본 1)Scale to multiply the wheel value by. (default 1)

짝Counterpart: vanilla.js UIScrollView.setWheelScrollScale

ScrollModeenum traits Clone, Copy, Debug, PartialEq, Eq

짝Counterpart: vanilla.js ScrollMode소스source

스크롤 모드.

Scroll mode.

이름Name설명Description
Clamp경계를 넘지 않는 기본 모드.Default mode that does not go past the bounds.
Elastic경계를 넘으면 저항이 생기고, 놓으면 스프링처럼 튕겨 돌아온다.Going past the bounds adds resistance, and on release it bounces back like a spring.