API reference

aster_blueprint::stock_chip

Pre-1.0: signatures are not frozen. Generated from rustdoc JSON of the compiled crate; rustdoc JSON format version 60. Only public items are listed.

A representative reusable graph component: the toggle chip.

The chip is two ordinary [AssetLibrary] assets (a body: one rect, one colour mix, one equal-stop linear paint and one rounded drawing; and the existing [crate::stock_text] prepared-text recipe) plus a small application-side [Chip] that wires the existing seams together:

  • the default look comes from a caller [Theme] whose ui.chip.off and ui.chip.on entries are Srgb8 literals and whose ui.chip.label entry names a caller-prepared [Label] handle in [ChipResources]; one [ThemeInstance] per chip may override any of them locally (a different colour, or a different prepared label, hence a different label paint) without touching the base or any other chip;
  • the caller's layout (chip.width/chip.height) and the motion value (chip.on) are plain graph parameters of the same runtime instance. chip.width is the width of the whole ROW: core.length.add.v1 and core.length.scale.v1 nodes turn it into the chip width, the x offset of chip chip.index, and the label slot. The root bounds, so also the pressable control's hit bounds ([Chip::hit_bounds]), are read from the same accepted graph outputs the Scene was committed from;
  • the label is a prepared, measured Label; its fit in the slot is the existing material-plan check (ResourceError::BoundsExceeded), nothing here shapes, measures or clips text;
  • an activation is observed through an existing acknowledged context and the chip's own [OwnedEndpoint]s, then drives one caller-clock [Motion] whose samples are committed into the caller's Scene.

This is not a stock Button: the pressable control, the Scene, the renderer and the presentation stay caller-owned existing aster-ui parts, and the

(documentation continues in the source)

Structs

structaster_blueprint::stock_chip::Chip

pub struct Chip { /* see fields */ }

One placed chip: a runtime instance of the shared plan in a caller Scene, its theme instance, its caller parameters and its caller-clock motion.

Methods

  • fn new(plan: Arc<Plan>, theme: ThemeInstance, resources: Arc<ChipResources>, parent: NodeId, model_key: ModelKey, index: usize) -> Result<Self, ChipError> — Place chip number index of the row under parent in scene. plan is the shared [compile_plan] result; model_key is the caller's own part identity. Nothing is written to the Scene until the first [Chip::publish].
  • fn theme(&self) -> &ThemeInstance
  • fn placed(&self) -> &MaterialInstance
  • fn is_on(&self) -> bool — The target state of the latest accepted press.
  • fn value(&self) -> f64 — The last committed chip.on value.
  • fn motion(&self) -> &Motion
  • fn needs_tick(&self) -> bool
  • fn event_plan(&self) -> &Arc<Plan> — The chip's own event plan (identity is per chip).
  • fn bounds(&self) -> Option<LogicalRect> — The chip root's bounds in its parent's space, read from the accepted graph output the Scene was last committed from. None before the first commit.
  • fn hit_bounds(&self, parent_origin: [f64; 2]) -> Option<LogicalRect> — The bounds for the chip's pressable control, in the Scene's space: [Chip::bounds] translated by the parent group's absolute origin. This is the only place hit geometry comes from; there is no second formula.
  • fn commits(&self) -> u64 — How many Scene commits this chip has made.
  • fn publish(&mut self, scene: &mut Scene, output: Output) -> Result<(), ChipError> — Commit the accepted theme and parameters (the first placement, or an explicit refresh). Unchanged inputs re-evaluate zero graph nodes.
  • fn set_theme(&mut self, scene: &mut Scene, output: Output, theme: ThemeInstance) -> Result<(), ChipError> — Adopt a new theme instance (a local override or a rebased global theme). A refused theme leaves the chip, Scene and motion untouched.
  • fn set_layout(&mut self, scene: &mut Scene, output: Output, width: f64, height: f64) -> Result<(), ChipError> — Change the caller's layout parameters: width is the whole row's width (the graph derives this chip's width, offset and label slot) and height the chip height. Motion state is not touched: an in-flight transition keeps its position and keeps playing. A layout whose label no longer fits its slot is refused (BoundsExceeded) with the chip, Scene and motion unchanged.
  • fn bind_press(&self, ctx: &AcknowledgedContext<'_>, node: NodeId, snapshot: SnapshotId) -> Result<ChipPress, ChipError> — Bind a deliberate press to the caller's acknowledged context. The caller has already admitted the gesture; this only observes that node (the chip's pressable control) was really presented in snapshot.
  • fn dispatch(&mut self, ctx: &AcknowledgedContext<'_>, press: &ChipPress) -> Result<CommandReport, ChipError> — Validate the press as an exact acknowledgement and start a transition from the CURRENT value to its target, so a reversal mid-flight has no jump. A stale acknowledgement, a foreign plan, a press from before a cancel or another press, all leave the motion exactly as it was.
  • fn cancel(&mut self) — Cancel any in-flight transition. The chip keeps its last committed value and requests no further tick; any press bound earlier is stale.
  • fn tick(&mut self, scene: &mut Scene, output: Output, now: Seconds) -> Result<Option<TickOutcome>, ChipError> — Advance by a caller clock reading. An idle chip does NO work: no evaluation, no Scene commit. A refused commit rolls the motion back so the same reading can be retried.

structaster_blueprint::stock_chip::ChipOptions

pub struct ChipOptions { /* see fields */ }

Caller-defaulted geometry, in logical units. width is the width of the row of two chips; each chip is (width - gap) * 0.5 wide and chip i sits at i * (chip width + gap) inside its parent group. The label slot is the chip inset by padding on every side; the label is placed at its origin.

Public fields

fieldtype
widthf64
heightf64
radiusf64
gapf64
paddingf64

Trait implementations: Clone, Copy, Debug, Default, PartialEq, StructuralPartialEq

structaster_blueprint::stock_chip::ChipPress

pub struct ChipPress { /* see fields */ }

One observed, bound press. It is valid for exactly the chip state it was bound from: any accepted press, cancel or flip makes it stale.

Methods

  • fn target_on(&self) -> bool — The state this press asks for.

structaster_blueprint::stock_chip::ChipResources

pub struct ChipResources { /* see fields */ }

The caller's prepared label resources, shared by every chip that uses them. Labels are measured once by the caller (the fonts and the shaper stay outside); a chip only resolves them by name through its theme.

Methods

  • fn new() -> Result<Self, ChipError>
  • fn add_label(&mut self, name: &str, label: Label) -> Result<(), ChipError> — Retain a prepared label under a caller name; a taken name is refused.

Enums

enumaster_blueprint::stock_chip::ChipError

pub enum ChipError { Model, Asset, Compile, Material, Instance, Runtime, Resource, Endpoint, Motion, Refused, Stale, Capacity, Setup }

A refusal of the chip. Every variant leaves the accepted chip unchanged.

Variants

  • Model
  • Asset
  • Compile
  • Material
  • Instance
  • Runtime
  • Resource
  • Endpoint
  • Motion
  • Refused — A bad caller value or an out-of-date press, with the reason.
  • Stale — The candidate was not staged from this chip's current runtime state.
  • Capacity — The runtime generation counter cannot advance.
  • Setup — A boundary the library cannot type (e.g. an endpoint seam error).

Trait implementations: Debug, Display, Error, From<AssetError>, From<CommitFailure<MaterialInstanceError>>, From<CompileError>, From<MaterialPlanError>, From<ModelError>, From<MotionError>, From<ResourceError>, From<RuntimeError>

Functions

fnaster_blueprint::stock_chip::compile_plan

pub fn compile_plan(options: ChipOptions) -> Result<std::sync::Arc<compiler::Plan>, ChipError>

Expand and compile the chip into ONE plan that any number of chips share.

Layout is typed length arithmetic over the caller's row width, not a solver: available = width + (-gap), chip = available * 0.5, x = (chip + gap) * chip.index, slot = chip + (-2 padding) wide. The root declares chip.width/height/radius/on/index; the compiler environment carries the themed colour and label types.

fnaster_blueprint::stock_chip::default_theme

pub fn default_theme(off: [u8; 4], on: [u8; 4], label: &str) -> Result<theme::Theme, ChipError>

The default chip theme: the two colours as typed Srgb8 literals and the label as a host entry naming label in the caller's [ChipResources].

fnaster_blueprint::stock_chip::label_entry

pub fn label_entry(name: &str) -> asset::ResourceEntry

A theme entry naming a prepared label of the caller's [ChipResources]. Use it with ThemeInstance::override_resource(HOST_LABEL, ..) to give one chip a different label (and so a different label paint).

fnaster_blueprint::stock_chip::toggle_chip

pub fn toggle_chip(options: ChipOptions) -> Result<model::GraphSource, ChipError>

The reusable chip body asset: bounds plus a rounded drawing painted with the themed off/on colours mixed by chip.on. Its chip.width is the width of ONE chip; the row arithmetic lives in [compile_plan].

Constants

constaster_blueprint::stock_chip::EVENT_TURN_OFF

pub const EVENT_TURN_OFF: &str

constaster_blueprint::stock_chip::EVENT_TURN_ON

pub const EVENT_TURN_ON: &str

Intent outputs of the per-chip event plan.

constaster_blueprint::stock_chip::HOST_LABEL

pub const HOST_LABEL: &str

Themed prepared-label entry (Host entry naming a [ChipResources] label).

constaster_blueprint::stock_chip::HOST_OFF

pub const HOST_OFF: &str

Themed colour of the off state (Srgb8 literal).

constaster_blueprint::stock_chip::HOST_ON

pub const HOST_ON: &str

Themed colour of the on state (Srgb8 literal).

constaster_blueprint::stock_chip::OUTPUT_BODY

pub const OUTPUT_BODY: &str

constaster_blueprint::stock_chip::OUTPUT_BOUNDS

pub const OUTPUT_BOUNDS: &str

Declared outputs of the compiled chip plan. chip.bounds is in the parent's space (it carries the x offset) and is the source of the hit bounds; chip.body and chip.label_slot are in the chip root's local space.

constaster_blueprint::stock_chip::OUTPUT_DRAWING

pub const OUTPUT_DRAWING: &str

constaster_blueprint::stock_chip::OUTPUT_LABEL

pub const OUTPUT_LABEL: &str

constaster_blueprint::stock_chip::OUTPUT_LABEL_SLOT

pub const OUTPUT_LABEL_SLOT: &str

constaster_blueprint::stock_chip::PARAM_HEIGHT

pub const PARAM_HEIGHT: &str

constaster_blueprint::stock_chip::PARAM_INDEX

pub const PARAM_INDEX: &str

Position of this chip in the row, Scalar (0 = first). Scales the stride.

constaster_blueprint::stock_chip::PARAM_ON

pub const PARAM_ON: &str

Motion-driven mix between the off and on colours, Scalar in 0..=1.

constaster_blueprint::stock_chip::PARAM_RADIUS

pub const PARAM_RADIUS: &str

constaster_blueprint::stock_chip::PARAM_WIDTH

pub const PARAM_WIDTH: &str

Root parameters of the compiled chip plan. chip.width is the width of the whole row of chips; the chip's own width is derived from it by the graph.

constaster_blueprint::stock_chip::TRANSITION_SECONDS

pub const TRANSITION_SECONDS: f64

Caller-clock length of every off/on transition.