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

Progress bars #496

Closed
Bauxitedev opened this issue Jun 18, 2021 · 6 comments · Fixed by #519
Closed

Progress bars #496

Bauxitedev opened this issue Jun 18, 2021 · 6 comments · Fixed by #519

Comments

@Bauxitedev
Copy link

Quick question, does egui contain any kind of functionality to draw a progress bar? I haven't been able to find any.

Ideally it would be kinda similar to this imgui progress bar: ocornut/imgui#1901

@EmbersArc
Copy link
Contributor

@emilk If you agree that this would be a good feature to have, I could implement one. Let me know if you have any ideas how to style it.

@sourcebox
Copy link

A progress bar would be really nice to have, I was recently looking for one in the demo app to include it in my latest project.

@Bauxitedev
Copy link
Author

Here's my temporary workaround if you want a progress bar right now. Replace progress with your own progress value from 0 to 1, and progress_bar_len with the width of the progress bar in characters.

let progress_bar_len = 18;
let progress = 0.5;
ui.label(format!(
    "{}",
    (0..progress_bar_len)
        .map(|i| {
            let percent = i as f32 / progress_bar_len as f32;
            if percent < progress {
                '◼'
            } else {
                '◻'
            }
        })
        .collect::<String>()
));

egui_progress

@sourcebox
Copy link

@Bauxitedev Thanks, that look good already. I don't need it right now, maybe in about 2 weeks.

@emilk
Copy link
Owner

emilk commented Jun 24, 2021

A progress bar would be nice yes, ideally with an optional text attached to it!

@EmbersArc EmbersArc mentioned this issue Jun 26, 2021
@EmbersArc
Copy link
Contributor

I've opened a PR: #519
Let me know if you have suggestions on how to improve it.

@emilk emilk closed this as completed in #519 Jul 1, 2021
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 a pull request may close this issue.

4 participants