Skip to content

feat(live): add El::live_rotation and support wrapped/truncated live_text without panicking - #1912

Merged
Hona merged 1 commit into
devfrom
feat/422-live-rotation-live-text
Nov 24, 2026
Merged

Hona merged 1 commit into
devfrom
feat/422-live-rotation-live-text

Conversation

@Hona

@Hona Hona commented Nov 24, 2026

Copy link
Copy Markdown
Member

Fixes #422
Refs #420

Summary

  • Live rotation (El::live_rotation): binds clockwise rotation in radians about El::origin to &Live<f32>, Live::smooth, or &Tween<f32> via Property::Rotation -> prop::ROTATION, updating presented rotation, upright bounding rects, and turned hit testing without rebuilding or laying out the view.
    • apply.rs skips static El::rotate commits while Property::Rotation owns prop::ROTATION; unbinding restores the authored El::rotate (or 0.0).
    • elements.rs reports live_intent (POSITION | SIZE) for unsmoothed live_rotation, agreeing with MotionElement::LIVE.
  • Non-panicking El::live_text with wrap, truncation, and line clamps: removes the commit-time panic in flatten.rs and the build-time asserts in El::live_text.
    • Plain single-line live_text (including .truncate_fade()) keeps its existing TextSystem::layout_live fast path unchanged.
    • .wrap(), .truncate() / .truncate_middle() / .truncate_head(), and .max_lines(n) re-wrap or re-elide in place inside the existing content box via lay_out_live_text_in_place (Keep::Owned), without reflowing siblings or growing the shared layout/elision caches.
    • Incompatible combinations (text_input, non-text elements, .spans(), .reveal(), .secure(), links, pills, or byte-indexed text decorations) drop the live binding and keep the authored text safely.
flowchart LR
    A[Live&lt;f32&gt; / Tween&lt;f32&gt;] -->|Property::Rotation| B[latch_live]
    B -->|prop::ROTATION| C[Scene &amp; turned layer / hit test]
    D[LiveText] -->|plain single-line| E[TextSystem::layout_live]
    D -->|wrap / truncate / max_lines| F[lay_out_live_text_in_place Keep::Owned]
    D -->|spans / reveal / secure / input| G[degrade to authored text]
Loading

Example usage

let angle = rune::Live::new(0.0_f32);
let caption = rune::LiveText::new("Starting...");

let needle = rune::el().size(4.0, 42.0).origin(0.5, 1.0).live_rotation(&angle);
let readout = rune::text("Placeholder").size(120.0, 40.0).max_lines(2).live_text(&caption);
  • Visible example: examples/live-values (rotating dial needle via El::live_rotation, wrapped .max_lines(2) live caption, and .truncate() live ticker).

Outside answer followed

  • El::live_rotation: Rune's existing El::live_scale / El::live_offset / El::rotate builder shape and prop::ROTATION scene track (clockwise radians about El::origin).
  • El::live_text: Rune's existing lay_out_text_in_place fixed-box layout path (using Keep::Owned to keep caches bounded) and non-panicking builder degradation matching sibling text builders in crates/rune/src/el/text.rs.

Notes

  • Headless tests and wasm32 checks (WebGPU and WebGL) were run on Windows and macOS; a live window and Linux build (OOM in container compiling upstream rustix) were not run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

live_text panics on wrapping, truncated or span-styled text

1 participant