-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Widget-driven animations #1647
Widget-driven animations #1647
Conversation
... and implement `TextInput` cursor blink 🎉
... and use it in the `solar_system` example 🎉
d02810a
to
c6d0046
Compare
I guess this currently depends on GL On Wayland, Mesa's EGL/WSI implementation uses |
That is very exciting |
Yes. Without vsync, the
I can clarify in the docs that the subscription matches the maximum refresh rate of the window at any given moment, which is in turn controlled by graphics drivers and the OS. In any case, there is no reason to believe the event will be emitted regularly even with the current docs, since a window can be moved to a screen with different refresh rate. This is why an |
Fixes #31 and closes #560.
This PR introduces a new method
request_redraw
to theShell
type which enables aWidget
to request a redraw duringon_event
.Shell::request_redraw
takes awindow::RedrawRequest
, which is defined as follows:Additionally, a new variant
RedrawRequested(Instant)
has been added towindow::Event
. This event is triggered before the user interface is redrawn.As a result, widgets can now choose to draw whenever necessary; making animations possible! For instance, the
TextInput
widget has now a blinking cursor:2023-01-11.05-36-44.mp4
Furthermore, these changes allow us to finally implement a subscription to subscribe to the frame rate of a window. The brand new
window::frames
subscription produces anInstant
at the same frequency as the frame rate of the screen of the user. This can be very useful to smoothly animate layout or different parts of an application (as opposed to usingtime::every
with a fixed frame rate). Thesolar_system
example now uses thewindow::frames
subscription!