Add widget timers to Masonry and use them for delayed UI behavior.#1779
Draft
waywardmonkeys wants to merge 4 commits intolinebender:mainfrom
Draft
Add widget timers to Masonry and use them for delayed UI behavior.#1779waywardmonkeys wants to merge 4 commits intolinebender:mainfrom
waywardmonkeys wants to merge 4 commits intolinebender:mainfrom
Conversation
Contributor
Author
|
This was done with LLM assistance to avoid typing out the boring stuff. Draft since I will publish |
Add `understory_timing` as a `masonry_core` dependency and keep the timer queue inside `RenderRoot` so widget timer requests synchronously return the queue-assigned identity. Expose timer time/deadline/drain hooks for backends, and update `masonry_winit` to own only the host clock origin and platform wakeup scheduling. Add focused tests for targeted timer delivery and cancellation.
Replace `TextArea`'s animation-frame polling for caret blinking with one-shot widget timers. Focus and text activity reset the blink state and schedule a half-cycle timer; timer updates toggle the caret and reschedule while the text area remains focused. Update the text input cursor blink snapshot test to advance the simulated timer clock instead of sending an animation frame.
Replace the layers example's animation-frame polling loop with a one-shot hover timer. Pointer movement cancels and reschedules the delay, hover exit cancels it, and the timer update creates the tooltip layer once the cursor has settled.
Clarify that `request_anim_frame` and `Widget::on_anim_frame` are for frame-cadenced visual updates, while delayed one-shot UI behavior should use widget timers. Update the pass-system and widget-implementation docs to describe timer delivery through `Update::Timer`, the non-bubbling delivery model, and the usual `Option<TimerToken>` request/cancel pattern.
8e792bf to
cfeb24c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
understory_timingas amasonry_coredependency.RenderRoot.TimerTokenand deliver expired timers throughUpdate::Timer.request_timer(delay) -> TimerTokencancel_timer(token)RenderRoot::set_timer_timeRenderRoot::next_timer_deadlineRenderRoot::handle_timersmasonry_winitto drive timer time and platform wakeups.TextAreacursor blinking to one-shot timers.Rationale
Masonry has several UI behaviors that are delayed but not frame-cadenced. Examples include cursor blinking, tooltip
delays, debounce, and long press recognition. These fit a timer model better than animation frames.
This PR adds a widget-local timer lifecycle: widgets request a timer, keep the returned
TimerToken, and receiveUpdate::Timerwhen it expires. Widgets can cancel pending timers when the relevant state changes.Animation frames remain the right tool for continuous visual updates, such as interpolation or motion that should advance with frame cadence.