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

Fade In/Fade out popups #5455

Closed
dimanchique opened this issue Jul 8, 2022 · 3 comments
Closed

Fade In/Fade out popups #5455

dimanchique opened this issue Jul 8, 2022 · 3 comments

Comments

@dimanchique
Copy link

I'm using ImGui 1.88 and I would like to know if it's possible to add some fade in/fade out effect to modal popup window? There's fade in effect on background but no fading out when window is closed. Need to fix it. Also I would like to use same behavior with window. I tried PushStyleVar with window transparency flag but I can't catch the speed of background so it's fading in with different speeds. When I tried to implement the same behavior to close popup I got fade out window with not fading out background and then immediately disabled background. That's look weird for me and I don't know how to make it in right way.
Also, thank you very much for this perfect and powerful library, guys!🙌

@rokups
Copy link
Contributor

rokups commented Jul 8, 2022

From the sound of it looks like there is no issues with Dear ImGui and you are just having issues coming up with a right logic for controlling window transparency. This question is best suited in general programming forums. Since you did not post any code it is hard to provide any useful feedback. Since you mentioned uneven animation time you are most likely experiencing differences due to inconsistent framerate and you should make your animations complete in constant time. You could do that using linear interpolation or a using a more advanced (and ascetically pleasing) easing curve function. Simplest attempt would be ImLerp(255.0f, 0.0f, (ImGui::GetTime() - start_time) / duration_seconds) (untested!), this will animate value from 255 to 0 in a constant time. Note that this is just an example and it uses a function provided in imgui_internal.h which you are encouraged to avoid using. It will also not look very good and you most likely want to use some function from https://github.com/nicolausYes/easing-functions.

@colesnicov
Copy link

#1925 (comment)

@colesnicov
Copy link

From the sound of it looks like there is no issues with Dear ImGui and you are just having issues coming up with a right logic for controlling window transparency. This question is best suited in general programming forums. Since you did not post any code it is hard to provide any useful feedback. Since you mentioned uneven animation time you are most likely experiencing differences due to inconsistent framerate and you should make your animations complete in constant time. You could do that using linear interpolation or a using a more advanced (and ascetically pleasing) easing curve function. Simplest attempt would be ImLerp(255.0f, 0.0f, (ImGui::GetTime() - start_time) / duration_seconds) (untested!), this will animate value from 255 to 0 in a constant time. Note that this is just an example and it uses a function provided in imgui_internal.h which you are encouraged to avoid using. It will also not look very good and you most likely want to use some function from https://github.com/nicolausYes/easing-functions.

I don't understand how can i use the easing functions here?? 8-O

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

No branches or pull requests

3 participants