struct
UI::DesignTokens::DeviceMetrics
- UI::DesignTokens::DeviceMetrics
- Struct
- Value
- Object
Overview
A snapshot of the device's runtime layout metrics.
Renderers populate this at render time by calling the appropriate OS API:
iOS: UIScreen.main.bounds + view.safeAreaInsets + UITraitCollection macOS: NSScreen.mainScreen.frame + NSWindow size class web: window.innerWidth + window.innerHeight + media query
The Crystal-side screen author NEVER constructs one of these
directly; they call DeviceMetrics.current (which delegates to the
active renderer's runtime query) and read the semantic values.
Defined in:
ui/design_tokens.crConstructors
-
.current : DeviceMetrics
Returns the current renderer-provided metrics snapshot.
- .new(screen_width_pt : Float64, screen_height_pt : Float64, safe_area_top_pt : Float64, safe_area_bottom_pt : Float64, safe_area_leading_pt : Float64, safe_area_trailing_pt : Float64, horizontal_size_class : SizeClass, vertical_size_class : SizeClass)
Class Method Summary
-
.reset_provider : Nil
Reset the installed provider to the spec-time fallback.
Instance Method Summary
- #clone
-
#compact_horizontal? : Bool
trueon iPhone portrait, an iPad Slide Over panel, a narrow macOS window. - #compact_vertical? : Bool
- #content_height_pt : Float64
-
#content_width_pt : Float64
The content rectangle (frame minus safe-area insets).
- #copy_with(screen_width_pt _screen_width_pt = @screen_width_pt, screen_height_pt _screen_height_pt = @screen_height_pt, safe_area_top_pt _safe_area_top_pt = @safe_area_top_pt, safe_area_bottom_pt _safe_area_bottom_pt = @safe_area_bottom_pt, safe_area_leading_pt _safe_area_leading_pt = @safe_area_leading_pt, safe_area_trailing_pt _safe_area_trailing_pt = @safe_area_trailing_pt, horizontal_size_class _horizontal_size_class = @horizontal_size_class, vertical_size_class _vertical_size_class = @vertical_size_class)
- #horizontal_size_class : SizeClass
- #regular_horizontal? : Bool
- #regular_vertical? : Bool
- #safe_area_bottom_pt : Float64
- #safe_area_leading_pt : Float64
- #safe_area_top_pt : Float64
- #safe_area_trailing_pt : Float64
- #screen_height_pt : Float64
- #screen_width_pt : Float64
- #vertical_size_class : SizeClass
Constructor Detail
Returns the current renderer-provided metrics snapshot.
Convenience that delegates to Device.current.
Class Method Detail
Instance Method Detail
true on iPhone portrait, an iPad Slide Over panel, a narrow
macOS window. Authors branch layout on this to switch a 2-column
split to a stacked single column.
The content rectangle (frame minus safe-area insets). Use this when laying out a sticky header / bottom action bar that must respect the Dynamic Island + home indicator.