# ui/uinode (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/ui/uinode/

UI node. (UINode of the original ui/uinode.js)
- Represents its area with 8 solver variables (left, right, top, bottom, width, height, derived center_x, center_y), and the user adds constraints to a LayoutSolver
  to determine those values. It registers the 4 intrinsic constraints (right == left + width, bottom == top + height, center_x == left + width / 2, center_y == top + height / 2) itself.
- User constraints are registered with add_constraint. The solver is attached with set_solver. (UISceneBase attaches the scene's solver to the UINodes in the tree by itself)
- intrinsic content size, content hugging, compression resistance, layout margins, layout margins guide are the same concepts as UIKit's APIs of the same names.
- Solver variables (left, top) are absolute positions in the coordinate system where the UI tree root is placed. If the parent is also a UINode, the child is placed offset by (left - parent left, top - parent top).
  Rotation, scale and opacity use the node's own as is.
- Usage:
  ```text
    let node_id = node_tree.create_child(parent_id, "title");
    node_tree.add_component(node_id, UINode::new());
    node_tree.with_component_mut::<UINode, _>(node_id, |ui_node, _tree| {
        ui_node.add_constraint(&ui_node.left_anchor().equal_to(screen_node.left_anchor().add(16))).unwrap();
    });
  ```
- Differences from the original:
  - In the original it is a separate node inheriting TransformNode and moves to the solver values in pushTransform. In the Rust version the only node is WorldNode, so
    it is a component attached to WorldNode, and moves the solver values to the node's position (local_position, with pivot and anchor at the top left) and content_size.
    The moves happen in the component tick and in apply_layout_in_tree (called by UISceneBase right after solving). The original reads them on every draw.
  - The original getIntrinsicContentSize gathers the values of the node's components that have that function (Text, RichText). The Rust version gathers Component::get_intrinsic_content_size.
    The original UILabel calls the node's invalidateIntrinsicContentSize when the text changes. Components in the Rust version cannot call the node's other components, so
    UINode reads the components' values again every tick (and on UISceneBase's solver attaching) and invalidates by itself if they changed.
  - Where the original throws exceptions (duplicate constraints in the solver, unsatisfiable required constraints), it returns `Result<(), LayoutError>`.
    (add_constraint, remove_constraint, set_solver, set_layout_margins, invalidate_intrinsic_content_size)
  - Anchors are functions (left_anchor) instead of the original's getter properties (leftAnchor). The axis argument is the LayoutConstraintAxis enum instead of a string, so there is no "unsupported axis" exception.
  - The layout margins guide is a UINode not in the tree, as in the original. In the Rust version this UINode holds it in a Box.

## LayoutMargins (struct) (Clone, Copy, Debug, PartialEq)

Layout margins. (UIKit's UIView.layoutMargins, original { top, left, bottom, right })
- The argument order of the creating function is top, left, bottom, right.

Example: Creating margins and the UINode default margins

```rust
use vanilla::{LayoutMargins, UINode};

let margins = LayoutMargins::create(4.0, 12.0, 4.0, 12.0);
assert_eq!(margins.top, 4.0);
assert_eq!(margins.left, 12.0);
assert_eq!(UINode::new().get_layout_margins(), LayoutMargins::create(8.0, 8.0, 8.0, 8.0));
```

- `pub top: f64` (field, since 0.4.0): Top margin. (pixels)
  - returns f64
- `pub left: f64` (field, since 0.4.0): Left margin. (pixels)
  - returns f64
- `pub bottom: f64` (field, since 0.4.0): Bottom margin. (pixels)
  - returns f64
- `pub right: f64` (field, since 0.4.0): Right margin. (pixels)
  - returns f64
- `pub fn create(top: f64, left: f64, bottom: f64, right: f64) -> LayoutMargins` (static, since 0.4.0): Constructor.
  - `top` f64: Top margin. (pixels)
  - `left` f64: Left margin. (pixels)
  - `bottom` f64: Bottom margin. (pixels)
  - `right` f64: Right margin. (pixels)
  - returns LayoutMargins: New margins.

## UINode (struct) (Default, Component)

UI node.
- A component attached to a node. Holds 8 solver variables and 4 intrinsic constraints, and remembers user constraints to add them to the solver.

Example: A title band placed 16 pixels inside the screen guide

```rust
use vanilla::{LayoutSolver, NodeTree, UINode, Vector2};

let solver = LayoutSolver::new();
let mut screen_node = UINode::new();
screen_node.set_solver(Some(solver.clone())).unwrap();
screen_node.add_constraint(&screen_node.left_anchor().equal_to(0)).unwrap();
screen_node.add_constraint(&screen_node.top_anchor().equal_to(0)).unwrap();
screen_node.add_constraint(&screen_node.width_anchor().equal_to(800)).unwrap();
screen_node.add_constraint(&screen_node.height_anchor().equal_to(600)).unwrap();

let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let title_id = node_tree.create_child(root_id, "title");
node_tree.add_component(title_id, UINode::new());
node_tree.with_component_mut::<UINode, _>(title_id, |title, _tree| {
	title.set_solver(Some(solver.clone())).unwrap();
	title.add_constraint(&title.left_anchor().equal_to(screen_node.left_anchor().add(16))).unwrap();
	title.add_constraint(&title.top_anchor().equal_to(screen_node.top_anchor().add(16))).unwrap();
	title.add_constraint(&title.right_anchor().equal_to(screen_node.right_anchor().subtract(16))).unwrap();
	title.add_constraint(&title.height_anchor().equal_to(48)).unwrap();
});
solver.update_variables();
UINode::apply_layout_in_tree(&mut node_tree, root_id);
assert_eq!(node_tree[title_id].get_local_position(), Vector2::create(16.0, 16.0));
assert_eq!(node_tree[title_id].get_content_size(), Vector2::create(768.0, 48.0));
```

- `pub fn new() -> UINode` (constructor, since 0.4.0): Constructor. (creates the 4 intrinsic constraints, hug 250, compression resistance 750, margins 8)
  - returns UINode: A new UI node without a solver. (the intrinsic constraints are built in advance and added when a solver is attached)
- `pub fn get_content_size(&self) -> Vector2` (method, since 0.4.0): Returns the content size. (width, height solved by the solver)
  - returns Vector2: f64 values of (width, height). (correct after update_variables)
- `pub fn build_intrinsic_constraints(&self) -> Vec<LayoutConstraint>` (method, since 0.4.0): Creates the 4 intrinsic constraints.
  - right == left + width, bottom == top + height, center_x == left + width / 2, center_y == top + height / 2
  - returns Vec<LayoutConstraint>: The 4 intrinsic constraints. (newly created on every call, so not the same constraints as those added to the solver)
- `pub fn build_intrinsic_size_constraints(&self) -> Vec<LayoutConstraint>` (method, since 0.4.0): Creates intrinsic content size based constraints (hug, compression resistance). (an axis whose value is NO_INTRINSIC_METRIC is not created)
  - hug: width <= intrinsic_width @ hugging, compression: width >= intrinsic_width @ compression resistance
  - returns Vec<LayoutConstraint>: Two constraints, hug and compression resistance, for each axis with a preference, 0 ~ 4 in total. (newly created constraints)
- `pub fn get_intrinsic_content_size(&self) -> Vector2` (method, since 0.4.0): Returns the intrinsic content size. (the larger of the node components' values, the last read value. No preference on an axis that is NO_INTRINSIC_METRIC)
  - returns Vector2: The last read intrinsic content size. (initially NO_INTRINSIC_METRIC on both axes)
- `pub fn collect_intrinsic_content_size(node: &WorldNode) -> Vector2` (static, since 0.4.0): Gathers the intrinsic content size of the node's components. (the original getIntrinsicContentSize default implementation, static)
  - `node` &WorldNode: Node whose components to look at.
  - returns Vector2: The components' get_intrinsic_content_size gathered by the larger value on each axis. (NO_INTRINSIC_METRIC if none have a preference or there are no components)
- `pub fn set_intrinsic_content_size(&mut self, intrinsic_content_size: Vector2) -> Result<(), LayoutError>` (method, since 0.4.0): Changes the intrinsic content size and adds the constraints again if it changed. (UISceneBase and tick read it from the node components and call this)
  - `intrinsic_content_size` Vector2: New intrinsic content size. (pixels, no preference on an axis that is NO_INTRINSIC_METRIC)
  - returns Result<(), LayoutError>: Ok(()). Does nothing if the value is the same. The LayoutError if removing the old constraints from the solver or adding the new ones fails.

  Example: Without other constraints, width and height follow the natural size

  ```rust
  use vanilla::{LayoutSolver, UINode, Vector2};
  
  let solver = LayoutSolver::new();
  let mut label = UINode::new();
  label.set_solver(Some(solver.clone())).unwrap();
  label.add_constraint(&label.left_anchor().equal_to(10)).unwrap();
  label.add_constraint(&label.top_anchor().equal_to(5)).unwrap();
  label.set_intrinsic_content_size(Vector2::create(120.0, 30.0)).unwrap();
  solver.update_variables();
  assert!((label.get_width() - 120.0).abs() < 0.001);
  assert!((label.get_height() - 30.0).abs() < 0.001);
  ```

- `pub fn invalidate_intrinsic_content_size(&mut self) -> Result<(), LayoutError>` (method, since 0.4.0): Invalidates the intrinsic content size. (UIKit's invalidateIntrinsicContentSize, removes the solver's old constraints and adds them again with the new value)
  - returns Result<(), LayoutError>: Ok(()). Without a solver, only rebuilds the constraints. The LayoutError if removing the old constraints from the solver or adding the new ones fails.
- `pub fn get_content_hugging_priority(&self, axis: LayoutConstraintAxis) -> f64` (method, since 0.4.0): Returns the content hugging priority. (UIKit's contentHuggingPriority(for:))
  - `axis` LayoutConstraintAxis: Axis to check.
  - returns f64: Hug priority of that axis. (default 250)
- `pub fn set_content_hugging_priority(&mut self, priority: f64, axis: LayoutConstraintAxis) -> Result<(), LayoutError>` (method, since 0.4.0): Sets the content hugging priority. (adds the intrinsic size constraints again right away)
  - `priority` f64: Hug priority. (UIKit-style 1 ~ 1000, becomes a strength through LayoutStrength::from_priority)
  - `axis` LayoutConstraintAxis: Axis to change.
  - returns Result<(), LayoutError>: Ok(()). The LayoutError if adding the intrinsic size constraints again fails.

  Example: Raising hug above the desired width (priority 500) shrinks it to the natural width

  ```rust
  use vanilla::{LayoutConstraintAxis, LayoutSolver, LayoutStrength, UINode, Vector2};
  
  let solver = LayoutSolver::new();
  let mut label = UINode::new();
  label.set_solver(Some(solver.clone())).unwrap();
  label.add_constraint(&label.left_anchor().equal_to(0)).unwrap();
  label.add_constraint(&label.top_anchor().equal_to(0)).unwrap();
  label.set_intrinsic_content_size(Vector2::create(120.0, 30.0)).unwrap();
  label.add_constraint(&label.width_anchor().equal_to(200).with_strength(LayoutStrength::from_priority(500.0))).unwrap();
  solver.update_variables();
  assert!((label.get_width() - 200.0).abs() < 0.001);
  
  label.set_content_hugging_priority(600.0, LayoutConstraintAxis::Horizontal).unwrap();
  solver.update_variables();
  assert!((label.get_width() - 120.0).abs() < 0.001);
  ```

- `pub fn get_content_compression_resistance_priority(&self, axis: LayoutConstraintAxis) -> f64` (method, since 0.4.0): Returns the content compression resistance priority.
  - `axis` LayoutConstraintAxis: Axis to check.
  - returns f64: Compression resistance priority of that axis. (default 750)
- `pub fn set_content_compression_resistance_priority(&mut self, priority: f64, axis: LayoutConstraintAxis) -> Result<(), LayoutError>` (method, since 0.4.0): Sets the content compression resistance priority. (adds the intrinsic size constraints again right away)
  - `priority` f64: Compression resistance priority. (UIKit-style 1 ~ 1000, becomes a strength through LayoutStrength::from_priority)
  - `axis` LayoutConstraintAxis: Axis to change.
  - returns Result<(), LayoutError>: Ok(()). The LayoutError if adding the intrinsic size constraints again fails.
- `pub fn get_layout_margins(&self) -> LayoutMargins` (method, since 0.4.0): Returns the layout margins. (UIKit's UIView.layoutMargins)
  - returns LayoutMargins: Margins. (default 8 on all four sides)
- `pub fn set_layout_margins(&mut self, layout_margins: LayoutMargins) -> Result<(), LayoutError>` (method, since 0.4.0): Sets the layout margins. (if the guide already exists, adds the guide constraints again right away)
  - `layout_margins` LayoutMargins: New margins.
  - returns Result<(), LayoutError>: Ok(()). If the guide does not exist yet, only changes the value. The LayoutError if adding the guide constraints again fails.
- `pub fn get_layout_margins_guide(&mut self) -> &UINode` (method, since 0.4.0): Returns the layout margins guide. (UIKit's UIView.layoutMarginsGuide, created on the first call with 4 margin constraints added)
  - The guide is not in the tree, so it is not drawn and only its anchors are used. If the margin constraints conflict with the solver, the guide is created but those constraints are not added.
  - returns &UINode: Reference to the margins guide UINode. (only its anchors and variables are used)

  Example: Margins guide of a 300 x 200 panel

  ```rust
  use vanilla::{LayoutMargins, LayoutSolver, UINode};
  
  let solver = LayoutSolver::new();
  let mut panel = UINode::new();
  panel.set_solver(Some(solver.clone())).unwrap();
  panel.add_constraint(&panel.left_anchor().equal_to(0)).unwrap();
  panel.add_constraint(&panel.top_anchor().equal_to(0)).unwrap();
  panel.add_constraint(&panel.width_anchor().equal_to(300)).unwrap();
  panel.add_constraint(&panel.height_anchor().equal_to(200)).unwrap();
  panel.set_layout_margins(LayoutMargins::create(10.0, 20.0, 10.0, 20.0)).unwrap();
  let guide_left = panel.get_layout_margins_guide().get_left_variable().clone();
  let guide_right = panel.get_layout_margins_guide().get_right_variable().clone();
  solver.update_variables();
  assert!((guide_left.get_value() - 20.0).abs() < 1e-6);
  assert!((guide_right.get_value() - 280.0).abs() < 1e-6);
  ```

- `pub fn rebuild_layout_margins_guide_constraints(&mut self) -> Result<(), LayoutError>` (method, since 0.4.0): Rebuilds the 4 margin constraints of the layout margins guide. (removes the old constraints, builds them with the current margins and adds them again)
  - returns Result<(), LayoutError>: Ok(()). Does nothing if there is no guide. The LayoutError if removing the old constraints from the solver or adding the new ones fails.
- `pub fn set_solver(&mut self, solver: Option<LayoutSolver>) -> Result<(), LayoutError>` (method, since 0.4.0): Sets, changes or clears the solver. (removes all this node's constraints from the old solver and adds them again to the new solver, moving the guide along too. None only removes)
  - `solver` Option<LayoutSolver>: Solver to attach. (give a cheap handle clone) None only detaches from the old solver.
  - returns Result<(), LayoutError>: Ok(()). The LayoutError if removing constraints from the old solver or adding them to the new solver fails.

  Example: Attaching a solver adds the remembered constraints, detaching removes them

  ```rust
  use vanilla::{LayoutSolver, UINode};
  
  let solver = LayoutSolver::new();
  let mut ui_node = UINode::new();
  let width_constraint = ui_node.width_anchor().equal_to(100);
  ui_node.add_constraint(&width_constraint).unwrap();
  assert!(!solver.has_constraint(&width_constraint));
  ui_node.set_solver(Some(solver.clone())).unwrap();
  assert!(solver.has_constraint(&width_constraint));
  ui_node.set_solver(None).unwrap();
  assert!(!solver.has_constraint(&width_constraint));
  assert!(ui_node.get_solver().is_none());
  ```

- `pub fn get_solver(&self) -> Option<&LayoutSolver>` (method, since 0.4.0): Returns the solver.
  - returns Option<&LayoutSolver>: The attached solver. None if none.
- `pub fn add_constraint(&mut self, constraint: &LayoutConstraint) -> Result<(), LayoutError>` (method, since 0.4.0): Adds a user constraint. (adds it right away if there is a solver)
  - If the solver does not accept it (a constraint already added, a contradictory constraint), returns that error and does not keep it in the list either.
  - `constraint` &LayoutConstraint: Constraint to add. (a handle clone is kept in the user constraint list and moved over when the solver changes)
  - returns Result<(), LayoutError>: Ok(()). The LayoutError if adding to the solver fails. (it stays in the user constraint list even on failure)
- `pub fn remove_constraint(&mut self, constraint: &LayoutConstraint) -> Result<(), LayoutError>` (method, since 0.4.0): Removes a user constraint. (also removes it from the solver)
  - `constraint` &LayoutConstraint: Constraint to remove. (the added handle or its clone)
  - returns Result<(), LayoutError>: Ok(()). Ok even if not in the list or not added to the solver. The LayoutError if removing from the solver fails.
- `pub fn get_constraints(&self) -> Vec<LayoutConstraint>` (method, since 0.4.0): List of registered user constraints. (copy)
  - returns Vec<LayoutConstraint>: Copy of the user constraint list. (handle clones, so the same constraints as those added to the solver)
- `pub fn get_left_variable(&self) -> &LayoutVariable` (method, since 0.4.0): Returns the left variable. (when a variable is needed outside an expression)
  - returns &LayoutVariable: Reference to the left variable handle.
- `pub fn get_right_variable(&self) -> &LayoutVariable` (method, since 0.4.0): Returns the right variable.
  - returns &LayoutVariable: Reference to the right variable handle.
- `pub fn get_top_variable(&self) -> &LayoutVariable` (method, since 0.4.0): Returns the top variable.
  - returns &LayoutVariable: Reference to the top variable handle.
- `pub fn get_bottom_variable(&self) -> &LayoutVariable` (method, since 0.4.0): Returns the bottom variable.
  - returns &LayoutVariable: Reference to the bottom variable handle.
- `pub fn get_width_variable(&self) -> &LayoutVariable` (method, since 0.4.0): Returns the width variable.
  - returns &LayoutVariable: Reference to the width variable handle.
- `pub fn get_height_variable(&self) -> &LayoutVariable` (method, since 0.4.0): Returns the height variable.
  - returns &LayoutVariable: Reference to the height variable handle.
- `pub fn get_center_x_variable(&self) -> &LayoutVariable` (method, since 0.4.0): Returns the horizontal center variable.
  - returns &LayoutVariable: Reference to the horizontal center variable handle.
- `pub fn get_center_y_variable(&self) -> &LayoutVariable` (method, since 0.4.0): Returns the vertical center variable.
  - returns &LayoutVariable: Reference to the vertical center variable handle.
- `pub fn left_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Left anchor expression. (UIKit's leftAnchor, a new expression on every call)
  - returns LayoutExpression: Expression 1 * left variable.
- `pub fn right_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Right anchor expression.
  - returns LayoutExpression: Expression 1 * right variable. (new expression)
- `pub fn top_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Top anchor expression.
  - returns LayoutExpression: Expression 1 * top variable. (new expression)
- `pub fn bottom_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Bottom anchor expression.
  - returns LayoutExpression: Expression 1 * bottom variable. (new expression)
- `pub fn width_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Width anchor expression.
  - returns LayoutExpression: Expression 1 * width variable. (new expression)
- `pub fn height_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Height anchor expression.
  - returns LayoutExpression: Expression 1 * height variable. (new expression)
- `pub fn center_x_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Horizontal center anchor expression.
  - returns LayoutExpression: Expression 1 * horizontal center variable. (new expression)
- `pub fn center_y_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Vertical center anchor expression.
  - returns LayoutExpression: Expression 1 * vertical center variable. (new expression)
- `pub fn leading_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Leading anchor expression. (UIKit's leadingAnchor, always left_anchor since right-to-left is not handled, as in the original)
  - returns LayoutExpression: Same expression as left_anchor.
- `pub fn trailing_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Trailing anchor expression. (UIKit's trailingAnchor, always right_anchor)
  - returns LayoutExpression: Same expression as right_anchor.
- `pub fn first_baseline_anchor(&self) -> LayoutExpression` (method, since 0.4.0): First baseline anchor expression. (top_anchor for nodes without text)
  - returns LayoutExpression: Same expression as top_anchor.
- `pub fn last_baseline_anchor(&self) -> LayoutExpression` (method, since 0.4.0): Last baseline anchor expression. (bottom_anchor for nodes without text)
  - returns LayoutExpression: Same expression as bottom_anchor.
- `pub fn get_left(&self) -> f64` (method, since 0.4.0): Left position. (correct after LayoutSolver::update_variables)
  - returns f64: Current value of the left variable. (absolute position in the UI tree root coordinate system, pixels)
- `pub fn get_right(&self) -> f64` (method, since 0.4.0): Right position.
  - returns f64: Current value of the right variable. (absolute position, pixels)
- `pub fn get_top(&self) -> f64` (method, since 0.4.0): Top position.
  - returns f64: Current value of the top variable. (absolute position, pixels)
- `pub fn get_bottom(&self) -> f64` (method, since 0.4.0): Bottom position.
  - returns f64: Current value of the bottom variable. (absolute position, pixels)
- `pub fn get_width(&self) -> f64` (method, since 0.4.0): Width.
  - returns f64: Current value of the width variable. (pixels)
- `pub fn get_height(&self) -> f64` (method, since 0.4.0): Height.
  - returns f64: Current value of the height variable. (pixels)
- `pub fn get_center_x(&self) -> f64` (method, since 0.4.0): Horizontal center position.
  - returns f64: Current value of the horizontal center variable. (absolute position, pixels)
- `pub fn get_center_y(&self) -> f64` (method, since 0.4.0): Vertical center position.
  - returns f64: Current value of the vertical center variable. (absolute position, pixels)
- `pub fn apply_layout_in_tree(node_tree: &mut NodeTree, node_id: NodeId)` (static, since 0.4.0): Moves the solver values of all UINodes under the node onto the nodes. (called by UISceneBase right after solving, static)
  - `node_tree` &mut NodeTree: Tree holding the node.
  - `node_id` NodeId: Node to start moving from. (this node and all nodes under it)
- `pub fn attach_pending_in_tree(node_tree: &mut NodeTree, node_id: NodeId, solver: &LayoutSolver)` (static, since 0.4.0): Attaches the solver to UINodes under the node that have no solver, and reads the intrinsic content size again. (called by UISceneBase every tick, original attachPendingUINodes)
  - `node_tree` &mut NodeTree: Tree holding the node.
  - `node_id` NodeId: Node to start searching from. (this node and all nodes under it)
  - `solver` &LayoutSolver: Solver to attach to UINodes without a solver. (errors from attaching or adding the intrinsic content size again are discarded)

  Example: Attaching a solver later to a node that only had constraints added without a solver, and laying it out

  ```rust
  use vanilla::{LayoutSolver, NodeTree, UINode, Vector2};
  
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let box_id = node_tree.create_child(root_id, "box");
  node_tree.add_component(box_id, UINode::new());
  node_tree.with_component_mut::<UINode, _>(box_id, |ui_node, _tree| {
  	ui_node.add_constraint(&ui_node.left_anchor().equal_to(10)).unwrap();
  	ui_node.add_constraint(&ui_node.top_anchor().equal_to(20)).unwrap();
  	ui_node.add_constraint(&ui_node.width_anchor().equal_to(30)).unwrap();
  	ui_node.add_constraint(&ui_node.height_anchor().equal_to(40)).unwrap();
  });
  let solver = LayoutSolver::new();
  UINode::attach_pending_in_tree(&mut node_tree, root_id, &solver);
  solver.update_variables();
  UINode::apply_layout_in_tree(&mut node_tree, root_id);
  assert_eq!(node_tree[box_id].get_local_position(), Vector2::create(10.0, 20.0));
  assert_eq!(node_tree[box_id].get_content_size(), Vector2::create(30.0, 40.0));
  ```

## Functions and constants

- `pub const NO_INTRINSIC_METRIC: f64 = -1.0` (field, since 0.4.0): Value meaning there is no intrinsic preference. (UIKit's UIView.noIntrinsicMetric, original UINode.noIntrinsicMetric)
  - returns f64
