Skip to content
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

wip: animations for default widgets #1855

Closed
wants to merge 12 commits into from

Conversation

lazytanuki
Copy link

@lazytanuki lazytanuki commented May 15, 2023

Hi!

This WIP implements default animations for default widgets. The goal here is to make Iced application appear smooth when hovering / clicking things, without breaking the API. It is also possible to keep the actual behavior (using a simple enum), although I do not know which should be default.
This heavily uses the new frame subscription API.
This is one thing that I was missing since transitioning from GTK, where you don't really need to worry about animations but can still end up with something that looks nice and smooth.

Current progress

Buttons

Buttons have smooth color transitions when hovered and pressed.

Kooha-2023-05-15-23-28-06.mp4

Things to discuss and fix:

  • Buttons look for cursor movement events to know whether they're being hovered or not. Could this be replaced by a new Hovered event in the update() function?
  • When clicking a button that is moved on click, it is possible that it is hovered anymore. However, if the mouse does not move, it will not be aware of it and will remain highlighted until the cursor moves again.

Text input (cursor)

In the text input, the cursor will fade-blink. It will however remain a full opacity while typing

Kooha-2023-05-15-23-36-43.mp4

Radio buttons

Radio buttons have smooth color transitions when hovered and pressed.

Kooha-2023-05-15-23-40-07.mp4

Togglers

Togglers have smooth color and movements transitions when pressed.

Kooha-2023-05-15-23-44-52.mp4

To do

  • checkboxes
  • scrollables
  • sliders
  • ...

Interferences

I stumbled upon cosmic-time, which implements a framework for animations in iced. From what I understand, it is made for more complex animations to be implemented by the user, whereas my goal is to bring default animations to Iced. However, I do not know if it would be better to use what has been made for cosmic-time for this or not. Or maybe this WIP is better suited to be used in cosmic-time after all.

I think default animations would be great, at least to be on par with GTK, but that's just IMO!
Thanks!

@max397574
Copy link

just stumbled upon this and it looks really promising
Any plans on how to continue with this @hecrj @lazytanuki ?

@nerocui
Copy link

nerocui commented Nov 22, 2023

Any plan to merge this one?

@lazytanuki
Copy link
Author

Hi ! I don't have a lot of time to work on this right now, but I believe we should have a discussion with @hecrj in order to figure out what is the best way to implement this. I know folks over at System76 have their own Cosmic time animation system and I don't want to step on their feet. However their system makes animations "external" to the widgets (at least from what I saw a while back, may have changed now), but I think it would be nice to have the animations system "internal" to widgets, at least for the ones that don't modify the layout. That way, users wouldn't have any extra work to do to have simple fade in/out animations for buttons, cursors, etc.
This is still on my list of todos.

@genusistimelord
Copy link
Contributor

The Idea behind this looks Solid so its just a matter of if Hector wants to take a look at it or if he rather you Post a topic about it first.

@lazytanuki
Copy link
Author

Superseded by #2483.

@lazytanuki lazytanuki closed this Jun 28, 2024
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.

None yet

4 participants