GPUI MaterialClose

Architecture and dependencies

English | 中文

GPUI Material provides Material tokens, themes, visual states, layout, and composition. GPUI Base provides reusable behavior, focus, input, scrolling, state, and infrastructure. Design sources

Crate dependency direction

Arrows point from caller to dependency. The table describes each layer’s dependency and responsibility.

Crate Dependencies and responsibilities
gpui-material-theme Pure Rust. Owns tokens, semantic colors, typography, shape descriptions, motion parameters, and layout policy. Exposes pure value types.
gpui-material-foundation → theme, gpui-base, and GPUI from the same source. Provides MaterialRoot, theme projection, drawing, state layers, ripple, geometry, and motion adapters.
gpui-material-components → foundation and theme as needed. Owns core display primitives and feature-grouped component sets (actions, selection, inputs, surfaces, feedback, navigation; default = ["full"]).
gpui-material-extras → components (enabling only the groups each family uses), foundation, and relevant theme APIs. Enable by family and declare additional dependencies separately.
gpui-material-design-symbols Companion crate for the full Material Symbols catalog. Builds SVG data from variable glyph outlines. Applications pass the result to Icon::svg_data. Integration
gpui-material → shipped public implementation crates. Forwards component feature groups (default = ["full"]) and optional extras/theme features as needed.
gpui-material-gallery → the shipped facade. The package provides the gpui_material_story library and a desktop executable outside the default workspace build.
xtask Documentation and dependency checks, build timings, and offline token generation. Independent of GPUI.

Inputs, overlays, and navigation may use controls/display. The TextField editing model exposes editing commands to the composition layer, which integrates ExposedDropdown and the editing menu. Navigation provides slots for search and toolbars. Implementation crates share lower-level interfaces. The facade provides the user entry point. Production depends on gpui-base and uses gpui-component as an upstream integration reference.

A host can depend on apps/gallery with default-features = false to use gpui_material_story without the desktop launcher. Call init_gallery before opening the first window. Mount Gallery::new for the full catalog or Story::new_view for a single component example under a gpui_base::Root. The Story identifier can be used in a URL and resolved with Story::find.

State and theme

Search and exposed dropdowns retain complete result identities and scroll state while GPUI’s variable-height list constructs visible rows and bounded overscan. Search preserves focus handles by result ID; dropdowns keep focus in the Base editor and retain the active option ID. Measurement is invalidated for changed content, width, typography, the installed-font snapshot, rem size, and dropdown animation scale. A logical row anchor reveals an unmeasured keyboard target without laying out its entire prefix. The lightweight List remains suitable for small collections; passing it a visible slice alone does not implement full-model keyboard navigation.

The dropdown keeps a narrow IME-aware keyboard adapter over Base Input and Popup. The pinned Base Select/Combobox root adds its own semantic/focus owner and cannot veto action handling during composition, so wrapping the existing editable TextField would change its contract. Button and selection feedback share one presentation event adapter; Base still owns activation and controlled values, while Material retains ripple timing and shape transitions.

Foundation shares typography, ripple feedback, and the desktop shadow projection across component families. Press ripples are separate from hover, focus, and drag state layers; reduced motion uses a static press indication. Single-line text shares tracked glyph measurement and drawing. Wrapping text delegates line breaking to GPUI with Material font families, weight, size, and line height; the pinned native wrapping API does not expose custom letter spacing. GPUI’s two-layer shadow projection is a desktop adaptation, not a pixel-identical reproduction of Android’s platform shadow renderer.

Dependency policy

Pin Base and GPUI as listed in design sources. For dependency proposals, record the purpose, enabled features, resolved graph, maintenance, licensing, and replacement boundaries in the issue or PR.

Dependency or candidate Purpose and constraints Replacement boundary
gpui-base =0.10.0 / gpui-pre =0.3.12 / gpui-pre-platform =0.3.12 Pin crates.io sources and retain the upstream pairing of font-kit, x11, wayland, and runtime_shaders. test-support is for tests; inspector is optional. Apache-2.0. Foundation wraps public Base APIs; keep a single resolved GPUI core and platform package identity.
material-color-utils 0.1.3 HCT, tonal palettes, and dynamic semantic colors. Disable default features to avoid image, serde, and rayon. Direct dependencies are bon, indexmap, papaya, and thiserror. Bundled license is Apache-2.0. Adapt library types inside theme.
polymorpher 0.1.4 Rounded polygons and morphing. Retain the empty default feature set and use basic geometry. Directly depends on euclid. Apache-2.0. Foundation owns GPUI path conversion and geometry adaptation.
Material Symbols Pin the necessary assets and let applications replace icons. Apache-2.0. Record distributed assets and licenses individually.
chrono 0.4.45 and Base Calendar The date-time feature enables a direct chrono dependency in extras with default features disabled, resolving to the same package as Base and GPUI. MIT or Apache-2.0. Base owns calendar and range draft transitions; chrono supplies checked calendar arithmetic and typed dates/times; application formatters and parsers control locale presentation.
rust-i18n 4.2.4 Optional application adapter, MIT. The project uses overridable text and formatters by default; this candidate introduces a macro and support crate. Keep translation library types inside the application adapter.

Extras define families such as expressive-groups, search, date-time, and carousel as needed. Theme supports static data with dynamic-color and serde on demand. Keep image-based color extraction in tooling where possible. Required keyboard, semantics, and motion are part of complete component behavior.

Use package-level commands in CI and development to isolate theme, components, and Gallery. Prefer concrete internal types with type erasure where needed.

Desktop adapter boundaries

Mechanism Adapter and boundary
Activation and drag Base manages button activation and focus. Composition owns roving focus. Windows capture loss, disabling, and Esc feed the cancellation path. The pinned Windows GPUI lacks capture-loss events, so Foundation checks Win32 capture ownership on the UI thread during a drag.
Text and semantics Base owns editing state, clipboard, fixed-bullet (•) masking, pre-commit validate/pattern filtering, structured MaskPattern formatting, and input handlers (upstream longbridge/gpui-kit#4059 redacts masked text_for_range IME queries for the next Base release). Material exposes TextFieldObfuscationMode (Hidden/Visible) and re-exports TextFieldMaskPattern rather than maintaining a separate display-only offset-mapping layer. GPUI owns the native bridge, glyph fallback, and layout. Use the same shaped line for measurement and drawing. Base 0.10.0 handles Windows UI Automation RangeValue SetValue on its Slider. Material exposes one native range node per custom thumb and routes each action to the matching Base SliderState thumb.
Drawing and motion Foundation reuses GPUI fill meshes for exact geometric path/rect/disc clipping, EvenOdd exterior backdrop masking, and shape-aware hit testing across convex and concave polygons. Non-rectangular polygon surfaces approximate shape-matched shadows with three translucent fills. Foundation unifies keyed spring/tween channels (animate / animate_with_status), entity-owned retargetable transitions (RetargetTransition), continuous loop clocks (LoopClock), and bounds visibility checks (is_bounds_visible) so mid-flight interruptions preserve spring velocity or shorten tween reversals proportionally, reduced motion settles immediately, and off-screen, clipped, inactive, or hidden components pause without scheduling idle frames.
Overlays and scrolling Base Popover and Dialog own placement, scrim, and focus scope. Composition maps logical alignment and manages open state, focus restoration, and drag cancellation. GPUI hit occlusion can isolate inner scrolling. Value labels subscribe to Base SliderState.
Theme and dates Application color transitions follow the target Slow Effects motion spec and project into the Base global on frame callbacks without disturbing overridden windows. Window and subtree themes supply complete local presentation (including multiline editor scrollbars and deferred exit overlays) to Material and its Base-backed controls, with current_base_theme available for standalone Base widgets. Reuse Base Calendar for date boundaries and disabled dates.
Window chrome The optional window-chrome adapter in extras owns cross-platform title bar layout, theme typography, vector caption icons, macOS traffic-light insets, Linux CSD/SSD control routing, and accessible controls. GPUI and the host window system own native hit testing, move, resize, Snap Layouts, and traffic lights. The application retains its window options and close policy.

Icon::new(IconName::Favorite) renders embedded official Material Symbols SVGs through GPUI; .filled(true) selects the official filled variant. Named icons inherit their control slot’s text size and foreground so size variants, disabled ink and animated colors remain consistent. Outside a slot, set .size(px(24.)); .color(ColorRole::Primary) is an explicit override. Icons are decorative unless .label(id, name) is set; icon-only buttons retain their own accessible labels. .mirror_in_rtl(true) is opt-in for directional symbols, and .rotate(...) composes with it. Existing Icon::svg and Icon::custom remain available with their original 24dp/OnSurfaceVariant defaults. Embedded icons need no application asset registration or font. The asset manifest pins unchanged upstream files and hashes; the license ships with them. Glyph placeholders and bespoke static icon paths are not used for built-in component icons; animated selection geometry stays in its owning component.

Close