-
-
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
Animations #31
Comments
I'm not sure why a redraw at a specific time is necessary. Is this so that a component can render at e.g. a specific framerate? It seems like a timer or a separate scheduler to call update functions might be a way to go about this, followed by requesting a window redraw? |
I need this too. I'm writing a program for the web that does custom animation. I looked at the For a "normal" web program I would just use the |
Hey @hecrj! I’m a noob but would love to take a shot at helping out with this. Are there any blockers for this issue?; and if not, which place(s) in the codebase would the change be made? |
I have an idea for a simple but versatile Animation widget where different functional methods could be used to modify a child widget. fn update(&mut self, message: Message){
match message {
Message::TriggerAnimation => self.animation_state.forward(), // If the animation has not been run yet, run it forward
}
}
fn view(&mut self) {
Button::new(&mut self.increment_button, Text::new("Trigger")).on_press(Message::TriggerAnimation)
Animation::new(&mut self.animation_state, child: Text::new("I just faded in!"))
.fade_in(Curve::linear()) // Fade in linearly
.translate(Curve::ease(), (-10, 0), (0,0)) // Move in from relative left
} |
Following on from a conversation on the zulip chat, @hecrj mentioned a good start would be enumerating use-cases, and think through how animations/draw state will interact with other features and API design decisions (of particular note, async rendering, and layout/widget state). In the interest of getting started, he's my attempt at rounding up the use-cases:
Non-case: Updating a widget based on external/non-UI state. I believe Thoughts:
Prior art / Implementation ideas
|
Note: not every "animation" is purely visual, e.g. in Qt menus, there is a short delay (maybe 500ms) between hovering over a menu item and opening/closing submenus. The reason is more functional than visual: during mouse movement the cursor may temporarily leave the menu item before entering the sub-menu's area, yet the user expects the sub-menu not to close during this brief period. (Alternative approaches are possible here, e.g. GTK does not close sub-menus when the cursor leaves the menu area, but does immediately do so if moving over a different item in the parent menu.) KAS has a very simple solution similar to Flutter: let widgets request an update after |
Allow widgets to request a redraw at a specific time.
This is a necessary feature to render loading spinners, a blinking text cursor, GIF images, etc.
winit
allows controlling the event loop in a flexible way. We may be able to useControlFlow::WaitUntil
for this purpose.The text was updated successfully, but these errors were encountered: