ui/uinode
UIKit 의 UIView.noIntrinsicMetric 와 같은 의미의 sentinel 값.
- getIntrinsicContentSize 의 x 또는 y 가 본 값이면 그 축은 intrinsic 선호 없음.
A sentinel value with the same meaning as UIKit's UIView.noIntrinsicMetric.
- If x or y of getIntrinsicContentSize is this value, that axis has no intrinsic preference.
UINodeextends TransformNode
UI 노드.
- 기존 WorldNode 계열과 다른 별도 노선의 UI 노드.
- 영역 정의는 솔버 변수 (left / right / top / bottom / width / height + 파생 centerX / centerY) 8 개로 표현되며, 사용자가 LayoutSolver 에 제약을 걸어 그 값들을 결정한다.
- 본 클래스는 변수 보유와 본질적 제약 (right == left + width, bottom == top + height, centerX == left + width/2, centerY == top + height/2) 4 개를 자동으로 등록한다.
- 사용자 제약은 addConstraint(constraint) 로 등록한다.
- 솔버 부착은 setSolver(solver) 로 한다. 트리에 통합 운용한다면 루트 UINode 에만 설정해두고 자식이 setSolver 를 통해 같은 인스턴스를 받도록 호출자가 관리한다.
- intrinsicContentSize / contentHuggingPriority / contentCompressionResistancePriority 는 UIKit 의 동명 API 와 동일 사상. 서브클래스가 getIntrinsicContentSize 를 override.
- layoutMargins / layoutMarginsGuide 는 UIKit 의 UIView.layoutMargins / layoutMarginsGuide 와 동일 사상. 자식 UINode 형태의 가이드를 lazy 로 노출.
UI node.
- A UI node on a separate track from the existing WorldNode family.
- The area is defined by 8 solver variables (left / right / top / bottom / width / height + derived centerX / centerY), and the user places constraints on the LayoutSolver to determine those values.
- This class holds the variables and the essential constraints (right == left + width, bottom == top + height, centerX == left + width/2, centerY == top + height/2), and registers these 4 automatically.
- User constraints are registered with addConstraint(constraint).
- The solver is attached with setSolver(solver). When operating the whole tree together, set it only on the root UINode and the caller manages it so that children receive the same instance through setSolver.
- intrinsicContentSize / contentHuggingPriority / contentCompressionResistancePriority follow the same idea as UIKit's APIs of the same name. Subclasses override getIntrinsicContentSize.
- layoutMargins / layoutMarginsGuide follow the same idea as UIKit's UIView.layoutMargins / layoutMarginsGuide. The guide, in the form of a child UINode, is exposed lazily.
import { UINode, LayoutSolver } from "./build/vanilla.js";
const solver = new LayoutSolver();
const panelNode = new UINode();
panelNode.setSolver(solver);
const panelLeftAnchor = panelNode.leftAnchor;
const panelTopAnchor = panelNode.topAnchor;
const panelWidthAnchor = panelNode.widthAnchor;
const panelHeightAnchor = panelNode.heightAnchor;
panelNode.addConstraint(panelLeftAnchor.equalTo(20));
panelNode.addConstraint(panelTopAnchor.equalTo(20));
panelNode.addConstraint(panelWidthAnchor.equalTo(400));
panelNode.addConstraint(panelHeightAnchor.equalTo(300));
panelNode.setLayoutMargins({ top: 16, left: 24, bottom: 16, right: 24 });
const marginsGuide = panelNode.getLayoutMarginsGuide();
const rowNode = new UINode();
rowNode.setSolver(solver);
const guideLeftAnchor = marginsGuide.leftAnchor;
const guideRightAnchor = marginsGuide.rightAnchor;
const guideTopAnchor = marginsGuide.topAnchor;
const rowLeftAnchor = rowNode.leftAnchor;
const rowRightAnchor = rowNode.rightAnchor;
const rowTopAnchor = rowNode.topAnchor;
const rowHeightAnchor = rowNode.heightAnchor;
rowNode.addConstraint(rowLeftAnchor.equalTo(guideLeftAnchor));
rowNode.addConstraint(rowRightAnchor.equalTo(guideRightAnchor));
rowNode.addConstraint(rowTopAnchor.equalTo(guideTopAnchor));
rowNode.addConstraint(rowHeightAnchor.equalTo(48));
solver.updateVariables();
console.log(rowNode.getLeft(), rowNode.getTop(), rowNode.getWidth(), rowNode.getHeight());noIntrinsicMetric 상수 노출. (UIKit 의 UIView.noIntrinsicMetric)
Exposes the noIntrinsicMetric constant. (UIKit's UIView.noIntrinsicMetric)
좌측 앵커 식 반환. (UIKit 의 leftAnchor 와 같은 사상)
- 사용자 제약 작성 시 호출, 새 LayoutExpression 인스턴스를 매 호출마다 반환. add / subtract / multiply / divide 가 불변이라 매번 새로 만들어도 안전.
Returns the left anchor expression. (same idea as UIKit's leftAnchor)
- Called when writing user constraints, returns a new LayoutExpression instance on every call. add / subtract / multiply / divide are immutable, so creating a new one each time is safe.
반환ReturnsLayoutExpression 왼쪽 변수 하나로 된 새 식.A new expression of the left variable alone.
짝Counterpart: vanilla-engine UINode.left_anchor
우측 앵커 식 반환. (UIKit 의 rightAnchor 와 같은 사상)
Returns the right anchor expression. (same idea as UIKit's rightAnchor)
반환ReturnsLayoutExpression 오른쪽 변수 하나로 된 새 식.A new expression of the right variable alone.
짝Counterpart: vanilla-engine UINode.right_anchor
상단 앵커 식 반환. (UIKit 의 topAnchor 와 같은 사상)
Returns the top anchor expression. (same idea as UIKit's topAnchor)
반환ReturnsLayoutExpression 위 변수 하나로 된 새 식.A new expression of the top variable alone.
짝Counterpart: vanilla-engine UINode.top_anchor
하단 앵커 식 반환. (UIKit 의 bottomAnchor 와 같은 사상)
Returns the bottom anchor expression. (same idea as UIKit's bottomAnchor)
반환ReturnsLayoutExpression 아래 변수 하나로 된 새 식.A new expression of the bottom variable alone.
짝Counterpart: vanilla-engine UINode.bottom_anchor
너비 앵커 식 반환. (UIKit 의 widthAnchor 와 같은 사상)
Returns the width anchor expression. (same idea as UIKit's widthAnchor)
반환ReturnsLayoutExpression 너비 변수 하나로 된 새 식.A new expression of the width variable alone.
짝Counterpart: vanilla-engine UINode.width_anchor
높이 앵커 식 반환. (UIKit 의 heightAnchor 와 같은 사상)
Returns the height anchor expression. (same idea as UIKit's heightAnchor)
반환ReturnsLayoutExpression 높이 변수 하나로 된 새 식.A new expression of the height variable alone.
짝Counterpart: vanilla-engine UINode.height_anchor
가로 중심 앵커 식 반환. (UIKit 의 centerXAnchor 와 같은 사상)
Returns the horizontal center anchor expression. (same idea as UIKit's centerXAnchor)
반환ReturnsLayoutExpression 가로 중심 변수 하나로 된 새 식.A new expression of the horizontal center variable alone.
짝Counterpart: vanilla-engine UINode.center_x_anchor
세로 중심 앵커 식 반환. (UIKit 의 centerYAnchor 와 같은 사상)
Returns the vertical center anchor expression. (same idea as UIKit's centerYAnchor)
반환ReturnsLayoutExpression 세로 중심 변수 하나로 된 새 식.A new expression of the vertical center variable alone.
짝Counterpart: vanilla-engine UINode.center_y_anchor
시작 앵커 식 반환. (UIKit 의 leadingAnchor 와 같은 사상)
- LTR 환경에서는 leftAnchor 와 동일. RTL 미지원이라 항상 leftAnchor 를 반환.
Returns the leading anchor expression. (same idea as UIKit's leadingAnchor)
- Same as leftAnchor in LTR environments. RTL is not supported, so it always returns leftAnchor.
반환ReturnsLayoutExpression leftAnchor 와 같은 식.Same expression as leftAnchor.
짝Counterpart: vanilla-engine UINode.leading_anchor
끝 앵커 식 반환. (UIKit 의 trailingAnchor 와 같은 사상)
- LTR 환경에서는 rightAnchor 와 동일. RTL 미지원이라 항상 rightAnchor 를 반환.
Returns the trailing anchor expression. (same idea as UIKit's trailingAnchor)
- Same as rightAnchor in LTR environments. RTL is not supported, so it always returns rightAnchor.
반환ReturnsLayoutExpression rightAnchor 와 같은 식.Same expression as rightAnchor.
짝Counterpart: vanilla-engine UINode.trailing_anchor
첫 번째 baseline 앵커 식 반환. (UIKit 의 firstBaselineAnchor 와 같은 사상)
- 텍스트 컨텐트가 없는 일반 UINode 는 topAnchor 와 동일.
- UILabel 등 텍스트 노드는 서브클래스가 override 해 ascent 보정.
Returns the first baseline anchor expression. (same idea as UIKit's firstBaselineAnchor)
- For a plain UINode without text content, same as topAnchor.
- Text nodes such as UILabel are overridden by subclasses to adjust for ascent.
반환ReturnsLayoutExpression topAnchor 와 같은 식. (하위 클래스가 바꿀 수 있다)Same expression as topAnchor. (subclasses may override it)
짝Counterpart: vanilla-engine UINode.first_baseline_anchor
마지막 baseline 앵커 식 반환. (UIKit 의 lastBaselineAnchor 와 같은 사상)
- 텍스트 컨텐트가 없는 일반 UINode 는 bottomAnchor 와 동일.
- UILabel 등 텍스트 노드는 서브클래스가 override 해 descent 보정.
Returns the last baseline anchor expression. (same idea as UIKit's lastBaselineAnchor)
- For a plain UINode without text content, same as bottomAnchor.
- Text nodes such as UILabel are overridden by subclasses to adjust for descent.
반환ReturnsLayoutExpression bottomAnchor 와 같은 식. (하위 클래스가 바꿀 수 있다)Same expression as bottomAnchor. (subclasses may override it)
짝Counterpart: vanilla-engine UINode.last_baseline_anchor
출력 상태 시작.
- 솔버 변수 (left / top) 는 UI 트리 루트가 속한 좌표계 기준의 절대 위치로 간주된다. (UIKit 의 anchor 가 window 좌표계 기준인 것과 동일한 사상)
- 부모도 UINode 라면 부모가 이미 (parentLeft, parentTop) 만큼 변환을 적용해 두었으므로 자식은 (left - parentLeft, top - parentTop) 만큼 추가 이동만 해야 한다.
- 회전 / 스케일 / 투명도는 기존 TransformNode 의 멤버를 그대로 사용한다. (UINode 의 영역 자체는 솔버 변수로 결정되므로 setLocalPosition 은 사용하지 않는다)
Begins the draw state.
- Solver variables (left / top) are treated as absolute positions in the coordinate system of the UI tree root. (the same idea as UIKit's anchors being based on the window coordinate system)
- If the parent is also a UINode, the parent has already applied a (parentLeft, parentTop) transform, so the child only translates additionally by (left - parentLeft, top - parentTop).
- Rotation / scale / alpha use the existing TransformNode members as is. (the UINode's area itself is determined by solver variables, so setLocalPosition is not used)
- graphicGraphic
- 그래픽. (null 이면 아무것도 하지 않는다)Graphics. (does nothing if null)
하위 트리 그리기 경계를 부모의 내용 좌표로 옮기기. (오버라이드: pushTransform 과 같이 솔버가 푼 왼쪽 위로 옮기고 회전, 배율, 기준점 없음)
- 부모가 UINode 면 부모의 왼쪽 위에서 잰 자리, 아니면 솔버의 좌표 그대로.
- pushTransform 이나 자리, 크기, 회전, 배율 읽기를 덮어쓴 노드는 어디에 놓이는지 모르므로 false.
- 솔버가 푼 자리와 크기가 바뀌면(LayoutSolver.updateVariables) 이 노드의 경계를 다시 셈한다.
Moves subtree draw bounds into the parent's content coordinates. (Override: like pushTransform, moves to the solver's top-left with rotation and scale, no pivot)
- Measured from the parent's top-left if the parent is a UINode, otherwise the solver's coordinates as is.
- A node that overrides pushTransform or the position, size, rotation or scale getters has unknown placement and returns false.
- When the solver's position or size changes (LayoutSolver.updateVariables), this node's bounds are recalculated.
- rectRect
- 옮길 경계. (이 노드의 내용 좌표, 부모의 내용 좌표로 바뀐 경계 상자를 적는다)The bounds to move. (In this node's content coordinates; the bounding box in the parent's content coordinates is written back)
반환Returnsboolean 놓이는 곳을 알면 참.True if where the node is placed is known.
import { UINode, LayoutSolver, Rect } from "./build/vanilla.js";
const solver = new LayoutSolver();
const rowNode = new UINode();
rowNode.setSolver(solver);
rowNode.addConstraint(rowNode.leftAnchor.equalTo(20));
rowNode.addConstraint(rowNode.topAnchor.equalTo(40));
rowNode.addConstraint(rowNode.widthAnchor.equalTo(100));
rowNode.addConstraint(rowNode.heightAnchor.equalTo(30));
solver.updateVariables();
const drawBounds = Rect.create(0, 0, 100, 30);
rowNode.transformDrawBoundsToParent(drawBounds);
console.log(drawBounds.position.x, drawBounds.position.y);컨텐트 사이즈 반환. (솔버가 풀어낸 width / height)
- WorldNode 의 getContentSize 와 동일 시그니처. Mask 등 컴포넌트가 그대로 사용 가능.
Returns the content size. (width / height solved by the solver)
- Same signature as WorldNode's getContentSize. Components such as Mask can use it as is.
반환ReturnsVector2 솔버가 푼 너비와 높이.Width and height solved by the solver.
짝Counterpart: vanilla-engine UINode.get_content_size
본질 제약 4 개 생성.
- right == left + width
- bottom == top + height
- centerX == left + width/2
- centerY == top + height/2
Creates the 4 essential constraints.
- right == left + width
- bottom == top + height
- centerX == left + width/2
- centerY == top + height/2
반환ReturnsLayoutConstraint[] 본질 제약 4 개. (솔버에 넣지 않고 돌려준다)The 4 intrinsic constraints. (returned without adding them to the solver)
짝Counterpart: vanilla-engine UINode.build_intrinsic_constraints
intrinsic content size 기반 제약 (hug / compression resistance) 4 개 생성.
- 축마다 intrinsic 값이 NO_INTRINSIC_METRIC (-1) 이면 그 축의 제약은 생성하지 않는다.
- hug: widthAnchor.lessThanOrEqualTo(intrinsicWidth) @ huggingPriority
- compression: widthAnchor.greaterThanOrEqualTo(intrinsicWidth) @ compressionResistancePriority
Creates the 4 constraints based on the intrinsic content size (hug / compression resistance).
- On each axis, if the intrinsic value is NO_INTRINSIC_METRIC (-1), that axis's constraints are not created.
- hug: widthAnchor.lessThanOrEqualTo(intrinsicWidth) @ huggingPriority
- compression: widthAnchor.greaterThanOrEqualTo(intrinsicWidth) @ compressionResistancePriority
반환ReturnsLayoutConstraint[] 내재 크기 제약 목록. (축마다 둘, 내재 크기가 없는 축은 빠진다, 솔버에 넣지 않고 돌려준다)List of intrinsic size constraints. (two per axis, axes without an intrinsic size are left out, returned without adding them to the solver)
짝Counterpart: vanilla-engine UINode.build_intrinsic_size_constraints
본 노드의 intrinsic content size 반환. 서브클래스가 override.
- x 또는 y 가 NO_INTRINSIC_METRIC (-1) 이면 그 축은 intrinsic 선호 없음.
- 기본 구현은 부착된 컴포넌트 중 getIntrinsicContentSize 를 가진 것들의 값을 max 로 합산해 반환. (Text 등 컴포넌트가 자동으로 기여)
Returns this node's intrinsic content size. Subclasses override it.
- If x or y is NO_INTRINSIC_METRIC (-1), that axis has no intrinsic preference.
- The default implementation takes the attached components that have getIntrinsicContentSize, combines their values with max and returns it. (components such as Text contribute automatically)
반환ReturnsVector2 내재 크기. (축마다 컴포넌트 값 가운데 가장 큰 것, 없는 축은 -1)Intrinsic size. (the largest component value per axis, -1 for axes without one)
짝Counterpart: vanilla-engine UINode.get_intrinsic_content_size
intrinsic content size 무효화. UIKit 의 invalidateIntrinsicContentSize 와 동일.
- 솔버에서 기존 intrinsicSize 제약을 제거하고 새 값으로 다시 등록한다.
- 텍스트 / 이미지 등 컨텐트가 바뀌어 intrinsic size 가 달라졌을 때 호출.
Invalidates the intrinsic content size. Same as UIKit's invalidateIntrinsicContentSize.
- Removes the existing intrinsicSize constraints from the solver and registers them again with the new values.
- Call when content such as text / image changes and the intrinsic size differs.
짝Counterpart: vanilla-engine UINode.invalidate_intrinsic_content_size
content hugging 우선순위 반환. (UIKit 의 contentHuggingPriority(for:))
Returns the content hugging priority. (UIKit's contentHuggingPriority(for:))
- axisstring
- 축. (LayoutConstraintAxis 의 값, 그 밖이면 예외를 던진다)Axis. (a LayoutConstraintAxis value, throws otherwise)
반환Returnsnumber 그 축의 content hugging 우선순위. (기본 LayoutPriority.defaultLow)Content hugging priority of that axis. (default LayoutPriority.defaultLow)
짝Counterpart: vanilla-engine UINode.get_content_hugging_priority
content hugging 우선순위 설정. (UIKit 의 setContentHuggingPriority(_:for:))
- intrinsicSize 제약을 즉시 갱신.
Sets the content hugging priority. (UIKit's setContentHuggingPriority(_:for:))
- Updates the intrinsicSize constraints immediately.
- prioritynumber
- 우선순위. (1 ~ 1000, LayoutPriority 의 값을 쓸 수 있다)Priority. (1 ~ 1000, LayoutPriority values can be used)
- axisstring
- 축. (LayoutConstraintAxis 의 값, 그 밖이면 예외를 던진다)Axis. (a LayoutConstraintAxis value, throws otherwise)
짝Counterpart: vanilla-engine UINode.set_content_hugging_priority
content compression resistance 우선순위 반환. (UIKit 의 contentCompressionResistancePriority(for:))
Returns the content compression resistance priority. (UIKit's contentCompressionResistancePriority(for:))
- axisstring
- 축. (LayoutConstraintAxis 의 값, 그 밖이면 예외를 던진다)Axis. (a LayoutConstraintAxis value, throws otherwise)
반환Returnsnumber 그 축의 압축 저항 우선순위. (기본 LayoutPriority.defaultHigh)Compression resistance priority of that axis. (default LayoutPriority.defaultHigh)
짝Counterpart: vanilla-engine UINode.get_content_compression_resistance_priority
content compression resistance 우선순위 설정. (UIKit 의 setContentCompressionResistancePriority(_:for:))
- intrinsicSize 제약을 즉시 갱신.
Sets the content compression resistance priority. (UIKit's setContentCompressionResistancePriority(_:for:))
- Updates the intrinsicSize constraints immediately.
- prioritynumber
- 우선순위. (1 ~ 1000, LayoutPriority 의 값을 쓸 수 있다)Priority. (1 ~ 1000, LayoutPriority values can be used)
- axisstring
- 축. (LayoutConstraintAxis 의 값, 그 밖이면 예외를 던진다)Axis. (a LayoutConstraintAxis value, throws otherwise)
짝Counterpart: vanilla-engine UINode.set_content_compression_resistance_priority
layoutMargins 반환. (UIKit 의 UIView.layoutMargins)
Returns layoutMargins. (UIKit's UIView.layoutMargins)
반환Returns{ top: number, left: number, bottom: number, right: number } 레이아웃 여백의 사본. (기본 사방 8)A copy of the layout margins. (default 8 on every side)
짝Counterpart: vanilla-engine UINode.get_layout_margins
layoutMargins 설정. (UIKit 의 UIView.layoutMargins setter)
- layoutMarginsGuide 가 이미 생성됐다면 가이드 제약을 즉시 갱신.
Sets layoutMargins. (UIKit's UIView.layoutMargins setter)
- If layoutMarginsGuide has already been created, updates the guide constraints immediately.
- layoutMargins{ top: number, left: number, bottom: number, right: number }
- 위, 왼쪽, 아래, 오른쪽 여백. (값을 복사해 담는다)Top, left, bottom and right margins. (the values are copied)
짝Counterpart: vanilla-engine UINode.set_layout_margins
layoutMarginsGuide 반환. (UIKit 의 UIView.layoutMarginsGuide)
- 처음 호출 시 lazy 로 가이드 UINode 를 생성하고 4 개의 마진 제약을 솔버에 등록.
- 가이드는 트리에 들어가지 않아 렌더링되지 않으며, anchor 만 사용된다.
Returns layoutMarginsGuide. (UIKit's UIView.layoutMarginsGuide)
- On the first call, lazily creates the guide UINode and registers 4 margin constraints with the solver.
- The guide is not added to the tree so it is not rendered; only its anchors are used.
반환ReturnsUINode 여백만큼 안쪽으로 들어간 가이드 UINode.Guide UINode inset by the margins.
짝Counterpart: vanilla-engine UINode.get_layout_margins_guide
layoutMarginsGuide 의 마진 제약 (4 개) 재구축.
- 기존 마진 제약을 솔버에서 제거하고 현재 #layoutMargins 값으로 다시 구축 후 재등록.
Rebuilds the layoutMarginsGuide margin constraints (4).
- Removes the existing margin constraints from the solver, rebuilds them with the current #layoutMargins value and registers them again.
짝Counterpart: vanilla-engine UINode.rebuild_layout_margins_guide_constraints
솔버 설정 / 변경 / 해제.
- 기존 솔버에서 본 노드의 모든 제약을 제거한 뒤, 새 솔버에 다시 등록한다.
- layoutMarginsGuide 가 이미 존재하면 그 가이드와 가이드 제약도 함께 이전 / 신규 솔버로 옮긴다.
- solver 가 null 이면 모두 해제만 한다.
Sets / changes / clears the solver.
- Removes all of this node's constraints from the existing solver, then registers them again with the new solver.
- If layoutMarginsGuide already exists, that guide and its constraints are also moved from the old / to the new solver.
- If solver is null, only clears everything.
- solverLayoutSolver | null
- 붙일 솔버. (null 이면 지금 솔버에서 떼기만 한다)Solver to attach. (if null, only detaches from the current solver)
짝Counterpart: vanilla-engine UINode.set_solver
솔버 반환.
Returns the solver.
반환ReturnsLayoutSolver | null 붙은 솔버. (없으면 null)The attached solver. (null if none)
짝Counterpart: vanilla-engine UINode.get_solver
사용자 제약 추가. 솔버에 즉시 등록.
- 솔버가 받지 않으면(이미 더한 제약, 모순 제약) 오류를 던지고 목록에도 남기지 않는다.
Add a user constraint. Registers it with the solver right away.
- If the solver does not accept it (a constraint already added, a contradictory constraint), throws and does not keep it in the list.
- constraintLayoutConstraint
- 더할 제약. (솔버가 받지 않으면 오류를 던진다)Constraint to add. (throws if the solver does not accept it)
짝Counterpart: vanilla-engine UINode.add_constraint
import { UINode, LayoutSolver, LayoutStrength } from "./build/vanilla.js";
const solver = new LayoutSolver();
const node = new UINode();
node.setSolver(solver);
const leftAnchor = node.leftAnchor;
const topAnchor = node.topAnchor;
const widthAnchor = node.widthAnchor;
const heightAnchor = node.heightAnchor;
node.addConstraint(leftAnchor.equalTo(0));
node.addConstraint(topAnchor.equalTo(0));
node.addConstraint(heightAnchor.equalTo(40));
const preferredWidthConstraint = widthAnchor.equalTo(300).withStrength(LayoutStrength.weak);
const maximumWidthConstraint = widthAnchor.lessThanOrEqualTo(200);
node.addConstraint(preferredWidthConstraint);
node.addConstraint(maximumWidthConstraint);
solver.updateVariables();
console.log(node.getWidth());
node.removeConstraint(maximumWidthConstraint);
solver.updateVariables();
console.log(node.getWidth());사용자 제약 제거. 솔버에서도 제거.
Removes a user constraint. Also removed from the solver.
- constraintLayoutConstraint
- 뺄 제약. (더하지 않은 제약이면 아무것도 하지 않는다)Constraint to remove. (does nothing if it was not added)
짝Counterpart: vanilla-engine UINode.remove_constraint
등록된 사용자 제약 목록 반환. (사본)
Returns the list of registered user constraints. (copy)
반환ReturnsLayoutConstraint[] 사용자 제약 목록의 사본.A copy of the user constraint list.
짝Counterpart: vanilla-engine UINode.get_constraints
좌측 변수 반환. (식 외 용도로 raw LayoutVariable 이 필요할 때)
Returns the left variable. (when a raw LayoutVariable is needed for purposes other than expressions)
반환ReturnsLayoutVariable 왼쪽 변수.Left variable.
짝Counterpart: vanilla-engine UINode.get_left_variable
우측 변수 반환.
Returns the right variable.
반환ReturnsLayoutVariable 오른쪽 변수.Right variable.
짝Counterpart: vanilla-engine UINode.get_right_variable
상단 변수 반환.
Returns the top variable.
반환ReturnsLayoutVariable 위 변수.Top variable.
짝Counterpart: vanilla-engine UINode.get_top_variable
하단 변수 반환.
Returns the bottom variable.
반환ReturnsLayoutVariable 아래 변수.Bottom variable.
짝Counterpart: vanilla-engine UINode.get_bottom_variable
너비 변수 반환.
Returns the width variable.
반환ReturnsLayoutVariable 너비 변수.Width variable.
짝Counterpart: vanilla-engine UINode.get_width_variable
높이 변수 반환.
Returns the height variable.
반환ReturnsLayoutVariable 높이 변수.Height variable.
짝Counterpart: vanilla-engine UINode.get_height_variable
가로 중심 변수 반환.
Returns the horizontal center variable.
반환ReturnsLayoutVariable 가로 중심 변수.Horizontal center variable.
짝Counterpart: vanilla-engine UINode.get_center_x_variable
세로 중심 변수 반환.
Returns the vertical center variable.
반환ReturnsLayoutVariable 세로 중심 변수.Vertical center variable.
짝Counterpart: vanilla-engine UINode.get_center_y_variable
좌측 위치 반환. (LayoutSolver.updateVariables 호출 후 유효)
Returns the left position. (valid after LayoutSolver.updateVariables is called)
반환Returnsnumber 솔버가 푼 왼쪽 위치. (UI 트리 루트의 좌표계)Left position solved by the solver. (coordinate system of the UI tree root)
짝Counterpart: vanilla-engine UINode.get_left
우측 위치 반환.
Returns the right position.
반환Returnsnumber 솔버가 푼 오른쪽 위치. (UI 트리 루트의 좌표계)Right position solved by the solver. (coordinate system of the UI tree root)
짝Counterpart: vanilla-engine UINode.get_right
상단 위치 반환.
Returns the top position.
반환Returnsnumber 솔버가 푼 위쪽 위치. (UI 트리 루트의 좌표계)Top position solved by the solver. (coordinate system of the UI tree root)
짝Counterpart: vanilla-engine UINode.get_top
하단 위치 반환.
Returns the bottom position.
반환Returnsnumber 솔버가 푼 아래쪽 위치. (UI 트리 루트의 좌표계)Bottom position solved by the solver. (coordinate system of the UI tree root)
짝Counterpart: vanilla-engine UINode.get_bottom
너비 반환.
Returns the width.
반환Returnsnumber 솔버가 푼 너비.Width solved by the solver.
짝Counterpart: vanilla-engine UINode.get_width
높이 반환.
Returns the height.
반환Returnsnumber 솔버가 푼 높이.Height solved by the solver.
짝Counterpart: vanilla-engine UINode.get_height
가로 중심 위치 반환.
Returns the horizontal center position.
반환Returnsnumber 솔버가 푼 가로 중심 위치. (UI 트리 루트의 좌표계)Horizontal center position solved by the solver. (coordinate system of the UI tree root)
짝Counterpart: vanilla-engine UINode.get_center_x
세로 중심 위치 반환.
Returns the vertical center position.
반환Returnsnumber 솔버가 푼 세로 중심 위치. (UI 트리 루트의 좌표계)Vertical center position solved by the solver. (coordinate system of the UI tree root)
짝Counterpart: vanilla-engine UINode.get_center_y
터치 인터랙션 활성화 설정. (WorldNode 와 같다)
Set touch interaction. (same as WorldNode)
- isInteractableboolean
- 참이면 TouchRaycaster 가 이 노드를 맞힌다. (UIButton 이 붙으면 켠다)If true, TouchRaycaster hits this node. (turned on when a UIButton is attached)
터치 인터랙션 활성화 여부 반환.
Returns whether touch interaction is enabled.
반환Returnsboolean 누를 수 있으면 참.True if interactable.
이 노드의 로컬 자리 → 뷰 좌표.
- pushTransform 이 거는 이동(솔버의 left, top, 부모가 UINode 면 부모의 left, top 을 뺀 값), 회전, 배율을 부모들까지 거슬러 올라가며 건다.
- UINode 가 아닌 부모는 그 노드의 자식 좌표계로 본다. (피봇이 있는 WorldNode 는 내용 영역의 왼쪽 위가 원점)
Local position on this node to view coordinates.
- Applies the translation that pushTransform applies (the solver's left and top, minus the parent's left and top if the parent is a UINode), rotation and scale, walking up through the parents.
- A parent that is not a UINode is treated as that node's child coordinate system. (for a WorldNode with a pivot, the top left of the content area is the origin)
- localPositionVector2
- 이 노드의 로컬 자리. (내용 영역의 왼쪽 위가 원점)Local position on this node. (the top left of the content area is the origin)
반환ReturnsVector2 뷰 좌표의 자리.Position in view coordinates.
실제 화면에 그려지는 영역 반환. (OBB, WorldNode 와 같은 꼴)
Return the area actually drawn on screen. (OBB, the same form as WorldNode)
반환ReturnsVector2[] 네 귀퉁이. (왼쪽 위, 오른쪽 위, 오른쪽 아래, 왼쪽 아래 차례, 뷰 좌표)The four corners. (top-left, top-right, bottom-right, bottom-left, in view coordinates)
자리가 노드 안인지. (getWorldCorners 로 잰다, WorldNode 와 같다)
Whether a position is inside the node. (measured with getWorldCorners, same as WorldNode)
- viewPositionVector2
- 볼 뷰 좌표.View coordinates to test.
반환Returnsboolean 네 귀퉁이 안이면 참. (null 이면 거짓)True if inside the four corners. (false if null)
import { UINode, UIButton, LayoutSolver, Vector2 } from "./build/vanilla.js";
const solver = new LayoutSolver();
const buttonNode = new UINode();
buttonNode.setSolver(solver);
buttonNode.addConstraint(buttonNode.leftAnchor.equalTo(40));
buttonNode.addConstraint(buttonNode.topAnchor.equalTo(20));
buttonNode.addConstraint(buttonNode.widthAnchor.equalTo(120));
buttonNode.addConstraint(buttonNode.heightAnchor.equalTo(48));
solver.updateVariables();
const button = buttonNode.addComponent(UIButton);
let clickCount = 0;
button.setClickEvent(() => {
++clickCount;
return true;
});
buttonNode.touchPress(Vector2.create(60, 40));
buttonNode.touchRelease(Vector2.create(60, 40));
console.log(buttonNode.isInteractable(), buttonNode.contains(Vector2.create(60, 40)), buttonNode.contains(Vector2.create(10, 10)), clickCount);터치 누름. (TouchRaycaster 가 부른다, 컴포넌트에 넘긴다)
Touch press. (called by TouchRaycaster, passed to the components)
- viewInputPositionVector2
- 뷰 좌표의 입력 위치.Input position in view coordinates.
터치 이동. (TouchRaycaster 가 부른다, 컴포넌트에 넘긴다)
Touch move. (called by TouchRaycaster, passed to the components)
- viewInputPositionVector2
- 뷰 좌표의 입력 위치.Input position in view coordinates.
터치 뗌. (TouchRaycaster 가 부른다, 컴포넌트에 넘긴다)
Touch release. (called by TouchRaycaster, passed to the components)
- viewInputPositionVector2
- 뷰 좌표의 입력 위치.Input position in view coordinates.
터치 취소. (TouchRaycaster 가 부른다, 컴포넌트에 넘긴다)
Touch cancel. (called by TouchRaycaster, passed to the components)
- viewInputPositionVector2
- 뷰 좌표의 입력 위치.Input position in view coordinates.