Skip to main content

Crate frust_core

Crate frust_core 

Source
Expand description

Layer 1+2 of Frust: the declarative view API, the retained widget tree, box-constraint layout, and the rebuild/layout/paint pass skeleton.

The design mirrors xilem_core’s proven View lifecycle and Masonry’s tree_arena-backed widget tree, but owns its implementation — there is no xilem/masonry dependency and no unsafe in this crate.

§Layers

  • view — layer 1: the View trait, ChangeFlags, and BuildCtx. Views are cheap descriptors produced by fn build(&mut State) -> impl View<State>.
  • widget — layer 2: the Widget trait and its layout/paint/event contexts, the PaintScene paint boundary, and container-owned ChildPod children.
  • event — layer 2 input: InputEvent/ PointerEvent and the EventCtx handlers mutate state through.
  • input — pure gesture helpers: slop/wheel constants, a VelocityTracker, and the fling-decay math the interactive widgets build on.
  • layout — the BoxConstraints box model.
  • tree — the WidgetTree arena wrapper, WidgetPod, and the read-only InspectNode walk tooling reads the tree through.
  • app — the RenderRoot that drives rebuild → layout → paint. This is what each platform shell owns.
  • [component] — Component, Flutter’s StatefulWidget analog: a subtree with retained local state, a per-component reactive Owner, and a state boundary the outer view tree never sees.
  • overlay — the overlay portal: an owner-hosted, root-painted, root-routed pod a widget floats above the whole app (menus, popovers, tooltips, selection toolbars).
  • selection_toolbar — what a text field publishes when it has a selection, plus the process-global policy/builder slots that decide who draws the toolbar.
  • hit — hit-testing helpers for content drawn under an arbitrary kurbo::Affine: the test ChildPod uses for a transformed pod, exposed for canvas hit closures and pan/zoom containers.

Re-exports§

pub use anim::AnimationController;
pub use anim::AnimationStatus;
pub use anim::Curve;
pub use anim::FrameTime;
pub use anim::Lerp;
pub use anim::Spring;
pub use anim::SpringDesc;
pub use anim::Tween;
pub use app::Orientation;
pub use app::RenderRoot;
pub use app::WindowMetrics;
pub use component::Component;
pub use component::ComponentView;
pub use component::ComponentWidget;
pub use component::component;
pub use event::CursorIcon;
pub use event::EditCommand;
pub use event::EditingState;
pub use event::EventCtx;
pub use event::EventOutcome;
pub use event::EventResult;
pub use event::ImeContentType;
pub use event::ImeEvent;
pub use event::ImeState;
pub use event::InputEvent;
pub use event::Key;
pub use event::KeyEvent;
pub use event::Modifiers;
pub use event::NamedKey;
pub use event::OverlayEvent;
pub use event::OverlayEventKind;
pub use event::PointerButton;
pub use event::PointerEvent;
pub use event::PointerPhase;
pub use event::ScrollDelta;
pub use event::has_pending_result_flush;
pub use event::mark_focus_orphaned;
pub use event::mark_pending_result_flush;
pub use event::take_focus_orphaned;
pub use event::take_pending_result_flush;
pub use input::FLING_DECAY;
pub use input::FLING_STOP;
pub use input::MOUSE_SLOP;
pub use input::TOUCH_SLOP;
pub use input::VELOCITY_WINDOW_MS;
pub use input::VelocityTracker;
pub use input::WHEEL_LINE_PX;
pub use input::fling_decay;
pub use input::fling_displacement;
pub use insets::CornerInset;
pub use insets::CornerInsets;
pub use insets::EdgeInsets as WindowEdgeInsets;
pub use insets::WindowInsets;
pub use layout::BoxConstraints;
pub use overlay::OutsideTap;
pub use overlay::OverlayBand;
pub use overlay::OverlayEntry;
pub use overlay::OverlayHit;
pub use overlay::OverlayInput;
pub use overlay::OverlayKey;
pub use overlay::OverlayPod;
pub use selection_toolbar::SelectionToolbarActions;
pub use selection_toolbar::SelectionToolbarBuilder;
pub use selection_toolbar::SelectionToolbarPolicy;
pub use selection_toolbar::SelectionToolbarRequest;
pub use selection_toolbar::install_selection_toolbar_builder_if_unset;
pub use selection_toolbar::lock_selection_toolbar_policy;
pub use selection_toolbar::selection_toolbar_builder;
pub use selection_toolbar::selection_toolbar_policy;
pub use selection_toolbar::set_selection_toolbar_builder;
pub use selection_toolbar::set_selection_toolbar_policy;
pub use semantics::SemanticsCtx;
pub use semantics::SemanticsUpdate;
pub use tree::InspectNode;
pub use tree::WidgetPod;
pub use tree::WidgetTree;
pub use view::AnyView;
pub use view::BuildCtx;
pub use view::ChangeFlags;
pub use view::View;
pub use view::WidgetId;
pub use view::any;
pub use widget::ChildPod;
pub use widget::DiscardScene;
pub use widget::HeroDirective;
pub use widget::HeroFrames;
pub use widget::LayoutCtx;
pub use widget::PaintCtx;
pub use widget::PaintOutcome;
pub use widget::PaintScene;
pub use widget::TickClass;
pub use widget::Widget;
pub use accesskit;

Modules§

anim
Animation vocabulary: the shared frame clock (FrameTime) plus the pure math widgets consume it through — easing Curves, Tween interpolation, analytic Spring dynamics, and the duration-/spring-driven AnimationController.
app
The render root: the object each platform shell drives each frame.
component
Component: Flutter’s StatefulWidget analog.
event
Layer 2 input: pointer/scroll events and the EventCtx a widget mutates while handling them.
hit
Hit-testing under an arbitrary kurbo::Affine.
input
Pure input/gesture helpers: slop/wheel constants, a trailing-window VelocityTracker, and the fling-decay math (numbers cross-checked against masonry’s implementation).
insets
Window insets: Flutter’s ViewportMetrics inset model ported into the framework core.
layout
Box-constraint layout model.
overlay
The overlay portal: the mechanism a widget anywhere in the tree floats a pod above the whole app with.
selection_toolbar
The selection-toolbar seam: what a text field asks for when it has a selection, and who draws it.
semantics
Layer 2: the semantics seam — a pull-based accessibility tree pass.
tree
The retained widget tree, backed by tree_arena.
view
Layer 1: the declarative View trait.
widget
Layer 2: the retained Widget trait and its layout/paint contexts.

Structs§

CornerRadii
The per-corner radii and dash-pattern vocabulary PaintScene’s own signatures name, re-exported from frust-scene so a widget calling PaintScene::fill_rounded_rect_radii/PaintScene::push_clip_rounded_radii/ PaintScene::stroke_path_dashed can name their arguments through the same paint surface it already paints through (mirrors the crate-root accesskit re-export). Per-corner radii for a rounded rectangle, in the pre-transform coordinate space.
DashPattern
The per-corner radii and dash-pattern vocabulary PaintScene’s own signatures name, re-exported from frust-scene so a widget calling PaintScene::fill_rounded_rect_radii/PaintScene::push_clip_rounded_radii/ PaintScene::stroke_path_dashed can name their arguments through the same paint surface it already paints through (mirrors the crate-root accesskit re-export). A stroke’s dash pattern: an on run, an off gap, and a phase offset into that repeating cycle — all lengths in the pre-transform coordinate space.