Expand description
Geometry and primitive value types used across the public API.
These are the cheap, copy-friendly types that flow through every widget builder, layout method and runtime hook:
Color— RGBA in[0.0, 1.0]floats;Color::WHITE,Color::BLACK,Color::TRANSPARENTconstants and aColor::hex(r, g, b)constructor for byte literals.Rect— axis-aligned(x, y, width, height); the universal layout / hit-test currency.Point— a 2D point used by hit testing and gesture progress.Size— a(width, height)pair without an origin.Corners— per-corner radius for theContainerwidget and any other rounded surface; coerces fromf32for the uniform case.WidgetId— a stable&'static stridentifier for focus management, paired withcrate::App::take_focus_request.
Every type is Copy (or Clone) so passing them by value is the
default. The crate root re-exports them all (ltk::Color,
ltk::Rect, …) so application code rarely needs the ltk::types::
prefix.
Structs§
- An RGBA color with floating-point channels in the range
[0.0, 1.0]. - Per-corner radii for a rounded rect, ordered top-left → top-right → bottom-right → bottom-left (clockwise from top-left, matching CSS
border-radius’s long form). All four values are independent pixel radii — set any subset to0.0for a square corner, or use thetop,bottom,left,rightshortcuts for the common asymmetric cases. - A size or distance value that may be expressed in absolute pixels or relative to the rendering surface. Every widget API that used to take
f32for a size, padding, spacing or font height now takesimpl Into<Length>, so existing call sites keep compiling unchanged while new code can switch to viewport-relative units for layouts that must scale across screen sizes (portrait phone, landscape tablet, 4K desktop) without per-target tweaks. - A 2-D point in screen coordinates (pixels, top-left origin).
- An axis-aligned rectangle in screen coordinates.
- A width/height pair in pixels.
- A stable widget identifier used for focus management.
Enums§
- Pointer cursor shape, sent to the compositor via
wp_cursor_shape_v1when the pointer enters a widget that declares one. Mirrorscursor_icon::CursorIcon1:1 so the runtime can convert losslessly. Compositors that do not advertisewp_cursor_shape_v1ignore these — the user sees their default system cursor. - One of the pure relative-or-absolute modes a
Lengthcan carry. Split out soLengthitself can stayCopywhile still supporting optional clamp bounds — the recursiveClampvariant of the original sketch would have forced aBoxallocation, which on a widget tree that builds these values per frame is the wrong trade.
Functions§
- Set the reference vmin width that
Length::dpinterpretspxagainst. Call once at startup (e.g. beforecrate::run) to align the design scale to the surface mock-up the app was designed for.