# ui/autolayout/layoutpriority (vanilla-engine 0.4.0)

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

Layout priority. (LayoutPriority of the original ui/autolayout/layoutpriority.js, same concept as UIKit's UILayoutPriority)
- REQUIRED (1000): priority that must be satisfied. Becomes LayoutStrength::REQUIRED.
- DEFAULT_HIGH (750): default compression resistance (compression resistance) priority.
- DEFAULT_LOW (250): default hug priority.
- FITTING_SIZE_LEVEL (50): recommended size priority when computing the fitting size.
- Values of 1 ~ 999 become a medium tier strength through LayoutStrength::from_priority.
- The original's static fields are associated constants. The values are f64.

## LayoutPriority (struct)

Layout priority.
- A name slot holding no value. Use only the associated constants, and turn them into strengths with LayoutStrength::from_priority to give to constraints.

Example: The constraint with higher priority wins

```rust
use vanilla::{LayoutExpression, LayoutPriority, LayoutSolver, LayoutStrength, LayoutVariable};

let solver = LayoutSolver::new();
let width = LayoutVariable::new("width");
let low_strength = LayoutStrength::from_priority(LayoutPriority::DEFAULT_LOW);
let high_strength = LayoutStrength::from_priority(LayoutPriority::DEFAULT_HIGH);
solver.add_constraint(&LayoutExpression::from_variable(&width).equal_to(100).with_strength(low_strength)).unwrap();
solver.add_constraint(&LayoutExpression::from_variable(&width).equal_to(200).with_strength(high_strength)).unwrap();
solver.update_variables();
assert!((width.get_value() - 200.0).abs() < 1e-6);
```

- `pub const REQUIRED: f64 = 1000.0` (static, since 0.4.0): Priority that must be satisfied. (1000, becomes LayoutStrength::REQUIRED)
  - returns f64
- `pub const DEFAULT_HIGH: f64 = 750.0` (static, since 0.4.0): Default compression resistance (compression resistance) priority. (750)
  - returns f64
- `pub const DEFAULT_LOW: f64 = 250.0` (static, since 0.4.0): Default hug priority. (250)
  - returns f64
- `pub const FITTING_SIZE_LEVEL: f64 = 50.0` (static, since 0.4.0): Recommended size priority when computing the fitting size. (50)
  - returns f64
