1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 22:00:03 -04:00

Progress bar (#519)

* add progress bar

* update changelog

* apply suggestions

* disable animation by default and tweak colors

* allow toggling the animation by clicking

* Update egui/src/widgets/progress_bar.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui/src/widgets/progress_bar.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui/src/widgets/progress_bar.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* address review comments

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Sven Niederberger
2021-07-01 22:50:41 +02:00
committed by GitHub
parent 52e3663958
commit 89cea7aca7
4 changed files with 158 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ pub struct WidgetGallery {
scalar: f32,
string: String,
color: egui::Color32,
animate_progress_bar: bool,
}
impl Default for WidgetGallery {
@@ -28,6 +29,7 @@ impl Default for WidgetGallery {
scalar: 42.0,
string: Default::default(),
color: egui::Color32::LIGHT_BLUE.linear_multiply(0.5),
animate_progress_bar: false,
}
}
}
@@ -95,6 +97,7 @@ impl WidgetGallery {
scalar,
string,
color,
animate_progress_bar,
} = self;
ui.add(doc_link_label("Label", "label,heading"));
@@ -157,6 +160,17 @@ impl WidgetGallery {
ui.add(egui::Slider::new(scalar, 0.0..=360.0).suffix("°"));
ui.end_row();
ui.add(doc_link_label("ProgressBar", "ProgressBar"));
let progress = *scalar / 360.0;
let progress_bar = egui::ProgressBar::new(progress)
.show_percentage()
.animate(*animate_progress_bar);
*animate_progress_bar = ui
.add(progress_bar)
.on_hover_text("The progress bar can be animated!")
.hovered();
ui.end_row();
ui.add(doc_link_label("DragValue", "DragValue"));
ui.add(egui::DragValue::new(scalar).speed(1.0));
ui.end_row();