Skip to main content

Crate cranpose_ui

Crate cranpose_ui 

Source
Expand description

High level UI primitives built on top of the Compose core runtime.

Re-exports§

pub use bring_into_view::BringIntoViewResponder;
pub use bring_into_view::local_bring_into_view_responder;
pub use bring_into_view::scroll_delta_to_reveal;
pub use density::Density;
pub use density::DensityMeasureScope;
pub use density::density;
pub use density::local_density;
pub use draggable::DragDeltaHandler;
pub use draggable::DraggableState;
pub use draggable::rememberDraggableState;
pub use focus_manager::FocusManager;
pub use focus_manager::local_focus_manager;
pub use focus_manager::request_focus_from_platform;
pub use focus_order::FocusEntry;
pub use focus_order::collect_focus_order;
pub use focus_order::focus_order_len;
pub use focus_order::set_focus_order;
pub use font_scale::FontScaleCurve;
pub use font_scale::MAX_FONT_SCALE_KNOTS;
pub use layout::LayoutAllocationDebugStats;
pub use layout::LayoutBox;
pub use layout::LayoutEngine;
pub use layout::LayoutMeasurements;
pub use layout::LayoutNodeData;
pub use layout::LayoutNodeKind;
pub use layout::LayoutTree;
pub use layout::MeasureLayoutOptions;
pub use layout::SemanticsAction;
pub use layout::SemanticsCallback;
pub use layout::SemanticsNode;
pub use layout::SemanticsRole;
pub use layout::SemanticsTree;
pub use layout::build_layout_tree_from_applier;
pub use layout::build_semantics_tree_from_applier;
pub use layout::build_semantics_tree_from_layout_tree;
pub use layout::measure_layout;
pub use layout::measure_layout_with_options;
pub use layout::tree_needs_layout;
pub use layout::tree_needs_semantics;
pub use layout_direction::LayoutDirection;
pub use layout_direction::ProvideLayoutDirection;
pub use layout_direction::layout_direction;
pub use layout_direction::local_layout_direction;
pub use lazy_item::ProvideLazyItemKey;
pub use lazy_item::lazy_item_key;
pub use lazy_item::local_lazy_item_key;
pub use modal::ModalRegistration;
pub use modal::clear_modals;
pub use modal::dispatch_modal_back;
pub use modal::local_modal_depth;
pub use modal::modal_depth;
pub use nine_patch::NinePatchInsets;
pub use nine_patch::PatchFill;
pub use nine_patch::PatchQuad;
pub use nine_patch::nine_patch_quads;
pub use nine_patch::tile_count;
pub use nine_patch::tile_quads;
pub use primitives::AnimatedVisibility;
pub use primitives::BasicText;
pub use primitives::BasicTextField;
pub use primitives::BasicTextFieldDecorated;
pub use primitives::BasicTextFieldDecorationScope;
pub use primitives::BasicTextFieldOptions;
pub use primitives::BasicTextFieldWithOptions;
pub use primitives::BasicTextWithOptions;
pub use primitives::BitmapPainter;
pub use primitives::BitmapRegionPainter;
pub use primitives::Box;
pub use primitives::BoxScope;
pub use primitives::BoxSpec;
pub use primitives::BoxWithConstraints;
pub use primitives::BoxWithConstraintsScope;
pub use primitives::BoxWithConstraintsScopeImpl;
pub use primitives::Button;
pub use primitives::ButtonSpec;
pub use primitives::Canvas;
pub use primitives::Column;
pub use primitives::ColumnSpec;
pub use primitives::ContentScale;
pub use primitives::Crossfade;
pub use primitives::DEFAULT_ALPHA;
pub use primitives::EnterTransition;
pub use primitives::ExitTransition;
pub use primitives::ForEach;
pub use primitives::Image;
pub use primitives::Layout;
pub use primitives::Painter;
pub use primitives::Row;
pub use primitives::RowSpec;
pub use primitives::Spacer;
pub use primitives::SubcomposeLayout;
pub use primitives::SvgPainter;
pub use primitives::SvgPainterError;
pub use primitives::Text;
pub use primitives::TextWithOptions;
pub use primitives::fade_in;
pub use primitives::fade_out;
pub use primitives::rememberSvg;
pub use primitives::slide_in_vertically;
pub use primitives::slide_out_vertically;
pub use safe_area::WindowInsets;
pub use safe_area::local_ime_insets;
pub use safe_area::local_safe_area_insets;
pub use safe_area::window_insets;
pub use scroll::ScrollElement;
pub use scroll::ScrollMetrics;
pub use scroll::ScrollNode;
pub use scroll::ScrollSettlePolicy;
pub use scroll::ScrollState;
pub use scrollbar::ThumbBounds;
pub use scrollbar::ThumbGeometry;
pub use scrollbar::content_delta_for_thumb_drag;
pub use scrollbar::thumb_geometry;
pub use text::LinkAnnotation;
pub use text::ParagraphStyle;
pub use text::PlatformParagraphStyle;
pub use text::PlatformSpanStyle;
pub use text::PlatformTextStyle;
pub use text::PreparedTextLayout;
pub use text::SpanStyle;
pub use text::StringAnnotation;
pub use text::TextDrawStyle;
pub use text::TextLayoutOptions;
pub use text::TextLayoutResult;
pub use text::TextLinePrefixWidths;
pub use text::TextMeasurer;
pub use text::TextMetrics;
pub use text::TextOptions;
pub use text::TextOverflow;
pub use text::TextShaping;
pub use text::TextStyle;
pub use text::get_cursor_x_for_offset;
pub use text::get_offset_for_position;
pub use text::layout_text;
pub use text::measure_text;
pub use text::measure_text_for_node;
pub use text::measure_text_with_options;
pub use text::measure_text_with_options_for_node;
pub use text::prepare_text_layout;
pub use text::prepare_text_layout_for_node;
pub use text::set_text_measurer;
pub use text_field_focus::ImeEditorState;
pub use text_field_focus::has_focused_field;
pub use text_input_session::PlatformTextInputHandler;
pub use widgets::clickable_text::ClickableText;
pub use widgets::lazy_list::LazyColumn;
pub use widgets::lazy_list::LazyColumnSpec;
pub use widgets::lazy_list::LazyRow;
pub use widgets::lazy_list::LazyRowSpec;
pub use widgets::linked_text::LinkedText;
pub use widgets::popup::dismiss_top_popup;
pub use widgets::popup::dismissable_popup_open;
pub use widgets::slider::Slider;
pub use widgets::slider::SliderOrientation;
pub use widgets::slider::SliderScope;
pub use widgets::slider::SliderSpec;
pub use widgets::swipe_to_dismiss::SwipeDismissDirection;
pub use widgets::swipe_to_dismiss::SwipeDismissSide;
pub use widgets::swipe_to_dismiss::SwipeDismissState;
pub use widgets::swipe_to_dismiss::SwipeToDismiss;
pub use widgets::swipe_to_dismiss::SwipeToDismissBox;
pub use widgets::swipe_to_dismiss::SwipeToDismissSpec;
pub use widgets::swipe_to_dismiss::rememberSwipeDismissState;
pub use widgets::text_selection_menu::local_on_light_surface;
pub use zoom::ZoomState;

Modules§

announce
bring_into_view
Bring-a-focused-field’s-caret-into-view above the soft keyboard.
clipboard_session
Platform clipboard session: an OS clipboard read/write bridge for in-tree UI.
density
Integral layout, the way Compose does it.
draggable
General drag state, for controls that are dragged but do not scroll.
fling_animation
Fling animation driver for scroll containers.
focus_manager
focus_order
font_scale
The system font-size setting, as the curve it is and not the multiplier it looks like.
layout
layout_direction
Which way the interface reads.
lazy_item
The identity of the lazy-list item currently being composed.
modal
The stack of modal surfaces that are open right now.
nine_patch
Filling a box with an image that is bigger, or smaller, than the box.
round_scaling_list
Placing list rows the way a round watch scales them.
round_scroll_indicator
The curved scroll indicator a round watch puts at 3 o’clock.
safe_area
Platform safe-area insets exposed to composition.
scroll
Scroll state and node implementation for cranpose.
scrollbar
Where a scrollbar’s thumb sits and how long it is.
text
text_field_focus
Focus manager for text fields.
text_input_session
Platform text-input session: soft-keyboard visibility hooks.
text_layout_result
Text layout result with cached glyph positions.
text_selection
Native-grade text selection primitives for BasicTextField.
widgets
UI Widget components
zoom
Pinch-to-zoom / pan state and the Modifier::zoomable gesture modifier.

Macros§

rememberScrollState
Creates a remembered ScrollState.

Structs§

Alignment
Alignment across both axes used for positioning content within a box.
AlphaElement
Element that creates and updates alpha nodes.
AlphaNode
Node that applies alpha transparency to its content.
BackgroundElement
Element that creates and updates background nodes.
BackgroundNode
Node that draws a background behind its content.
BlurredEdgeTreatment
Controls blur behavior outside source bounds.
CanvasSemanticsNode
A semantics node for content that is drawn rather than laid out.
ClickableElement
Element that creates and updates clickable nodes.
ClickableNode
CollectionInfo
How far a container has scrolled along one axis and how far it can go.
Color
Composition
Constraints
Constraints used during layout measurement.
CornerRadii
CornerShapeElement
Element that creates and updates corner shape nodes.
CornerShapeNode
Node that tracks the latest rounded corner shape.
Dp
Density-independent pixels: a layout length that reads the same on every device regardless of its pixel density.
DpOffset
Density-independent offset for shadows.
DrawCacheBuilder
EdgeInsets
Padding values for each edge of a rectangle.
FillElement
Element that creates and updates fill nodes.
FillNode
Node that fills the maximum available space in one or both dimensions.
FocusRequester
A handle an app holds to move focus onto a node imperatively.
FractionalOffsetElement
Element that creates and updates fractional offset nodes.
FractionalOffsetNode
Node that offsets its content by a fraction of its own measured size.
GlassMaterial
Visual parameters for Modifier::glass_material.
GraphicsLayer
HeadlessRenderer
A lightweight renderer that walks the layout tree and materialises paint commands.
ImageBitmap
Immutable RGBA image data used by UI primitives and render backends.
KeyEvent
A keyboard input event.
LayoutNode
LazyItems
A run of lazy items: how many, and optionally how they are identified and reused.
LazyListItemInfo
Information about a single visible item in a lazy list.
LazyListLayoutInfo
Information about the currently visible items in a lazy list.
LazyListState
State object for lazy list scroll position tracking.
MeasureResult
Result of a measurement operation.
Modifier
A modifier chain that can be applied to composable elements.
ModifierChainTraceGuard
RAII guard returned when installing a modifier chain trace subscriber.
ModifierLocalKey
Type-safe key referencing a modifier local value.
ModifierLocalReadScope
Lightweight read scope surfaced to modifier local consumers.
ModifierNodeSlices
Snapshot of modifier node slices that impact draw and pointer subsystems.
ModifierNodeSlicesDebugStats
Modifiers
Keyboard modifier keys held during an input sample.
MutableInteractionSource
NodeCapabilities
Capability flags indicating which specialized traits a modifier node implements.
NodeState
Runtime state tracked for every ModifierNode.
OffsetElement
Element that creates and updates offset nodes.
OffsetNode
Node that offsets its content by a fixed (x, y) amount.
PaddingElement
Element that creates and updates padding nodes.
PaddingNode
Node that adds padding around its content.
Placeable
Result of running a measurement pass for a single child.
Placement
Placement information for a measured child.
Point
PointerEvent
Pointer event with consumption tracking for gesture disambiguation.
PointerInputScope
PressInteractionCancel
PressInteractionPress
PressInteractionRelease
ProgressBarRangeInfo
The value a control holds inside a range, for a slider, a dial or a progress bar.
RecordedRenderScene
A collection of render operations for a composed scene.
Rect
ResolvedBackground
ResolvedModifiers
RotaryInputModifierNode
Modifier node that forwards rotary scroll events to an app handler.
RotaryScrollEvent
A rotary scroll event produced by a Wear OS crown or rotating bezel.
RoundedCornerShape
RuntimeShader
A custom WGSL shader effect, analogous to Android’s RuntimeShader.
ScrollAxisRange
This is Compose’s ScrollAxisRange (verticalScrollAxisRange, horizontalScrollAxisRange). A lazy list has no whole extent to give, so it reports the first visible item as the value and one more than that as the end while it can still scroll; a reader only needs to know whether it can page on.
SemanticsConfiguration
Semantics configuration for accessibility.
SemanticsCustomAction
A screen-reader action that is not a click, e.g. Compose’s customActions = listOf(CustomAccessibilityAction("Pause") { … }).
SemanticsRequester
A handle an app holds to say that what its semantics recorder would report has changed.
SemanticsScrollBy
What a container does when a screen reader pages it, e.g. TalkBack’s scroll forward action or an accesskit scroll down. The two deltas are in layout pixels; the answer says whether anything moved.
SemanticsSetProgress
What a control does when a screen reader moves its value, e.g. a VoiceOver swipe up or a TalkBack set-progress action.
SemanticsSetText
What a text field does when a screen reader or a voice tool hands it new text. This is Compose’s SemanticsActions.SetText; the answer says whether the field took the text.
Shadow
Static shadow configuration.
ShadowScope
Pixel-space shadow scope used by block-based APIs.
Size
SizeElement
Element that creates and updates size nodes.
SizeNode
Node that enforces size constraints on its content.
SnapshotState
Cheap copyable mutable view of a state cell.
SubcomposeLayoutNode
Node responsible for orchestrating measure-time subcomposition.
SubcomposeMeasureScopeImpl
Concrete implementation of SubcomposeMeasureScope.
TestApplierGuard
TestComposition
In-memory composition helper used by tests.
TextFieldBuffer
A mutable text buffer that can be edited.
TextFieldElement
Element that creates and updates TextFieldModifierNode instances.
TextFieldModifierNode
TextFieldState
Observable state holder for text field content.
TextFieldValue
Immutable snapshot of text field content.
TextModifierElement
Element that creates and updates TextModifierNode instances.
TextModifierNode
Node that stores text content and handles measurement, drawing, and semantics.
TextRange
Represents a range in text, used for cursor position and selection.
TransformOrigin

Enums§

BlendMode
Blend mode used for draw primitives.
Brush
ColorFilter
Simple image color filter model.
CompositingStrategy
DrawCommand
FillDirection
Direction for fill modifiers (horizontal, vertical, or both).
FocusDirection
Focus direction for navigation.
FocusRequestError
Why FocusRequester::request_focus could not move focus.
HorizontalAlignment
Alignment along the horizontal axis.
ImageSampling
Texture sampling mode for image primitives.
Interaction
IntrinsicSize
Specifies how to size a component based on its intrinsic measurements.
KeyCode
Physical key codes for keyboard input.
KeyEventType
Type of keyboard event.
LayerShape
LinearArrangement
Arrangement strategy matching Jetpack Compose’s linear arrangements.
LiveRegionMode
How urgently a screen reader reads a node whose text changed on its own.
PaintLayer
Layer that a paint operation targets within the rendering pipeline.
PointerEventKind
PointerSource
The kind of physical device that produced a pointer event.
PressInteraction
RenderEffect
A render effect applied to a graphics layer’s rendered content.
RenderOp
A rendered operation emitted by the headless renderer.
SemanticsWidgetRole
What kind of control a node is, as screen readers announce it.
TextFieldLineLimits
Line limit configuration for text fields.
VerticalAlignment
Alignment along the vertical axis.

Constants§

MAX_FONT_SCALE
Largest system font scale honoured. Android’s own accessibility slider tops out at 2.0.
MIN_FONT_SCALE
Smallest system font scale honoured; below this, text stops being readable as text.

Traits§

Arrangement
Trait implemented by arrangement strategies that distribute children on an axis.
DelegatableNode
Provides traversal helpers that mirror Jetpack Compose’s DelegatableNode contract.
LazyListScope
Receiver scope for lazy list content definition.
Measurable
Object capable of measuring a layout child and exposing intrinsic sizes.
ModifierNode
Core trait implemented by modifier nodes.
ModifierNodeElement
Strongly typed modifier elements that can create and update nodes while exposing equality/hash/inspector contracts that mirror Jetpack Compose.
SubcomposeLayoutScope
Base trait for measurement scopes.
SubcomposeMeasureScope
Public trait exposed to measure policies for subcomposition.

Functions§

active_focus_target
Returns the currently active focus target, if any.
clean_slot_skip_count
Number of subcompose measure passes on this thread that reused a retained slot without a compose walk. Diagnostic surface for tests and telemetry; see SubcomposeMeasureScope::subcompose for when a slot may skip.
clear_focus_invalidations
Clears all pending focus invalidations without processing them.
collect_is_pressed_as_state
Free-function form of MutableInteractionSource::collectIsPressedAsState.
collect_modifier_slices
Collects modifier node slices directly from a reconciled ModifierNodeChain.
collect_semantics_from_modifier
Collects semantics by instantiating a temporary modifier chain from a Modifier.
collect_slices_from_modifier
Collects modifier node slices by instantiating a temporary node chain from a Modifier.
command_draw_scope
The scope every framework-run draw command records into: sized by the consumer, measuring text with the app’s fonts.
command_draw_scope_reusing
command_draw_scope recording into storage the consumer already owns — the retained-recorder path where a command’s buffer keeps its capacity across frames.
current_density
Returns the current density scale factor (logical px per dp).
current_font_scale
Returns the system font scale — the multiplier the user chose in the platform’s font-size setting, 1.0 when they left it alone.
current_font_scale_curve
Returns the conversion the platform performs for a size in Sp.
execute_draw_commands
format_layout_tree
Returns a formatted string representation of the layout tree
format_modifier_chain
Formats the modifier chain using inspector data.
format_render_scene
Returns a formatted string representation of the render scene
format_screen_summary
Returns a compact summary of what’s on screen (counts by type).
has_pending_focus_invalidations
Returns true if any focus invalidations are pending.
install_modifier_chain_trace
Installs a callback that receives modifier chain snapshots when debugging is enabled.
is_cursor_visible
Returns whether the cursor should be visible right now.
last_fling_velocity
log_layout_tree
Logs the current layout tree through the logger with indentation showing hierarchy.
log_modifier_chain
Logs the contents of a modifier node chain including capabilities.
log_render_scene
Logs the current render scene through the logger.
log_screen_summary
Logs a compact summary of what’s on screen (counts by type).
next_cursor_blink_time
Returns the next cursor blink transition time, if any. Use this for WaitUntil scheduling in the event loop.
process_focus_invalidations
Processes all pending focus invalidations.
rememberLazyListState
Creates a remembered LazyListState with default initial position.
rememberLazyListStateWithPosition
Creates a remembered LazyListState with the specified initial position.
rememberMutableInteractionSource
reset_cursor_blink
Resets cursor to visible and restarts the blink timer. Call this on any input (key press, paste) so cursor stays visible while typing.
reset_last_fling_velocity
run_test_composition
Build a composition with a simple in-memory applier and run the provided closure once.
scale_sp
A size in scale-independent pixels, in dp, through the running app’s curve.
schedule_focus_invalidation
Schedules a focus invalidation for the specified node.
set_active_focus_target
Sets the currently active focus target.
set_density
Updates the current density scale factor.
set_font_scale
Updates the system font scale, taking it as a plain multiplier.
set_font_scale_curve
Updates the system font scale and the conversion behind it.
start_cursor_blink
Starts the active context’s cursor blink animation. Called when a text field gains focus.
stop_cursor_blink
Stops the active context’s cursor blink animation. Called when no text field is focused.
tick_cursor_blink
Advances the cursor blink state if needed. Returns true if a redraw is needed. A transition schedules a scoped draw repass on the focused field, so the caller only has to run the ordinary dirty-node paths — no whole-scene work.

Type Aliases§

DrawCommandFn
A draw command records into a scope the CONSUMER provides, instead of returning a freshly allocated primitive vector. This is the boundary that lets recording storage live with the command’s stable identity and be reused frame over frame (the retained draw-command recorder), rather than being reallocated, moved, and dropped on every execution.
Key
TextPanResolver
Resolver that recomputes (and stores) the horizontal pan offset for a text field given the current content viewport width in px.

Attribute Macros§

composable