Expand description
GPUI Kit bindings for the portable gpui-ce-motion animation engine.
This adapter uses Kit’s GPUI types. It does not enable the core crate’s CE
feature, and it does not change either renderer. Retain one state per logical
object, or use Motions to collect ordinary transitions by key. Declare
destinations during render and notify after input changes.
use gpui_ce_motion::{Motion, Target};
use gpui_motion_kit::MotionState;
use gpui_kit::{AnyElement, App, Window, div, prelude::*};
fn panel(state: &mut MotionState, open: bool, window: &mut Window, cx: &App) -> AnyElement {
let frame = state.frame(Motion::new(Target::default()).present(open), window, cx);
frame.render(|frame| frame.apply(div().child("Details")))
}Re-exports§
pub use gpui_ce_motion as core;
Structs§
- Anchor
Element - Frame-scoped measuring wrapper created by
MotionAnchor::element. - Animation
State - Retained prepared-clip playback using Kit’s controllable executor clock.
Controls are inherited from
core::AnimationState; usenow(cx)for them. - Auto
Size - Measures content as a separate layout root, reserves its animated size, and clips painting/input to that reservation. This adds a layout node. Constraints are explicit because the content is measured before parent layout is resolved. This is real layout sizing, not GPU projection. Retain the same Kit-scoped ID.
- Frame
- A sampled frame with Kit-native element builders and portable status getters.
- Gesture
Element - Frame-scoped input/motion wrapper produced by
GestureState::bind. - Gesture
State - Retain one handle per logical control. Clones share input/motion state. Mouse release outside the hitbox, lost button, Escape, blur and deactivation clear ownership. Pinch and supported native touch gestures are opt-in; raw multi-touch availability depends on the backend/platform.
- Graph
State - View-owned native clock for a portable motion-value graph. Keep this state alive and notify after source/control changes.
- Layout
Group - A view-owned coordinate scope for automatic position-only layout animation. Clone shares the ancestor scope; retain one group across renders and use that same group for nested animated elements. Independent groups should not nest. Element history is owned by Kit’s keyed element state and lasts while mounted.
- Layout
Position Element - Transparent native wrapper produced by
LayoutGroup::position. Its child’s paint, hitboxes and accessibility bounds receive the same prepaint translation. No scale/rotation, size projection, or cross-parent shared IDs. - Motion
Anchor - Retained measurement of one native element in logical window coordinates.
Mount each anchor once. Clones share storage.
clearreleases a stale measurement before reusing the owner in another window. - Motion
State - View-owned motion state using GPUI Kit’s monotonic executor clock.
- Motion
Tree State - Native owner for a portable variant tree; shares the graph’s explicit clock contract.
- Motions
- Component-owned keyed transitions using the shared engine and Kit’s clock.
- Number
Element - Styled count declaration. Number formatting reserves at most 256 minimum digits.
- Number
Motion State - Retained count animation. Unchanged digits match by place value, from the right.
- PopElement
- Native wrapper constructed by
PopLayout. - PopLayout
- Retain in the view. A container records its origin; exiting items reserve no
flow space but remain at their last measured parent-relative bounds. Use the
same container and retain outgoing content with
PresenceGroupuntil exit finishes. Ancestor clipping still applies. Independent containers must use separate handles; this is not cross-parent projection. - PopRequest
- Per-frame layout data for a popped element. Native implementations should use
PopLayout::item; this type only appears through theElementtrait. - Reorder
Element - Native spatial reorder item.
- Reorder
Group - Retained logical order and measured spatial geometry. Mouse/keyboard input, cancellation and optional edge autoscroll share the portable engine. Automatic axis detection occurs on acquisition. Host owns model persistence and focus restoration after removal. Cross-list transfer and virtualization are separate application policies; keep this group’s mounted geometry in one scroll source.
- Scramble
- Deterministic visual substitutions. The logical accessibility text is unchanged.
- Scroll
Frame - Native scroll sample, also suitable for feeding a portable graph or typed track.
- Scroll
Motion - Binds native scroll progress to partial numeric targets. Defaults to instant mapping; choose a spring for smoothing. Layout extent changes trigger a follow-up frame, so the previous measurement cannot remain stale after resize. Preserve its Kit-scoped ID and configure styles before wrapping.
- Scroll
Tracker - Tracks an element’s progress through another measured element, with configurable intersections, margins and optional spring smoothing. Retain anchors and this state; render their wrappers in the same window.
- Shared
Element - Native position/crossfade appearance constructed by
SharedLayout::member. - Shared
Layout - View-owned shared identity registry. Exactly one active destination per key
is required. Render incoming/outgoing appearances in a common overlay; retain
outgoing content until its normal presence exit completes. Native clipping
still applies, sizes change immediately, and independent scrolling coordinate
spaces are not reconciled. This is position/crossfade, not full
layoutId. Clones share storage. Callremovewhen a logical shared identity is finished. - Shared
Overlay - Window-root coordinator connecting anchors in separate containers. Render its floating appearances in an unclipped root layer. Anchor geometry is reconciled in window coordinates, including explicitly tracked scrolling. Sizes can follow measured destinations through real layout; no scale projection or transformed clipping is installed. One active appearance per key is required. The host retains exits and owns focus/input policy.
- Shared
Overlay Element - Frame-scoped, window-coordinate position/crossfade appearance.
- Style
Frame - Presented style tracks with Kit-native conversion and engine status getters.
- Style
Motion State - Retain one style sampler per logical element. Uses Kit’s executor clock.
- SvgFrame
- A portable SVG presentation with Kit-native transform conversion.
- SvgMotion
State - Retained SVG transform sampler using Kit’s monotonic executor clock.
- Text
Element - Styled native text declaration created by
TextMotionState::element. Layout takes destination sizes immediately; usereflowfor position motion. This is display text, not an editable or selectable input implementation. - Text
Motion State - View-owned native text motion. Clones share lifecycle and shape caches. Retain one state per logical label, with one mounted element per state. Fonts and full runs are shaped before splitting; native glyph atlas painting preserves kerning, contextual forms, bidi positions, and emoji.
- Text
Target - Text-relative offsets, opacity, and horizontal reveal fraction. Builders panic on non-finite offsets or fractions outside zero through one.
- Text
Unit Info - Metadata supplied once when preparing each unit’s custom entrance.
- Timeline
- Prepared tracks for separate Kit elements, using the shared timeline engine.
Track insertion allocates; sampling reuses a Kit frame buffer. Retain the
timeline, add tracks once, and use
now(cx)for playback controls. - Typed
State - Kit executor clock around a shared, independently sampled typed state.
- Typed
Timeline - Kit executor clock around a shared heterogeneous timeline.
- Unsupported
Style - A requested style track has no public renderer hook in Kit 0.7.3.
- Value
State - A retained scalar presentation in caller-chosen units.
- Vector
Element - Fixed-size native vector drawing. This paints vector geometry, not an SVG sprite or a GPUI subtree; it does not install pointer semantics.
- Vector
State - Retain one vector state per drawing. Clones share morph/reveal storage. Path sampling allocates no memory; native tessellation/paint preparation does.
Enums§
- Axis
- Native scroll axis.
- Number
Effect - Digit transitions. Rolling and sliding retain unchanged digits by place value.
- Size
Axis - Which measured dimensions interpolate. Other dimensions follow content immediately.
- Text
Clip - Stationary clipping around each unit’s final layout reservation.
- Text
Error - Native text failures, independent of the chosen GPUI backend.
- Text
Match - Identity policy when the requested text changes.
- Text
Preset - Convenience effects. A subsequent
enterorexitoverrides that target. - Text
Unit - Grouping for text motion. Native adapters merge boundaries inside shaped clusters.
Functions§
- color_
to_ rgba - Converts the engine’s sRGB color to Kit’s native RGBA value.
- native_
scroll_ progress - Reads native scroll offsets and extents; unscrollable content returns zero. Handles Kit’s negative scroll offsets and positive maximum extents.