mirror of
https://github.com/storytold/craft-launcher.git
synced 2026-10-13 23:08:16 +00:00
Improve indeterminate installer progress bar animation (#163)
* Improve indeterminate progress bar animation Refactor indeterminate progress bar rendering for smoother animation. * progress: rustfmt, and skip the wrapped segment while it's off the track Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Brandon Thomas <echelon@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 file changed
+10
-8
@@ -400,14 +400,16 @@ pub fn progress(ui: &mut Ui, fraction: Option<f32>, caption: &str, color: Color3
|
||||
p.rect_filled(Rect::from_min_size(bar.min, vec2(bar.width() * f.clamp(0.0, 1.0), bar.height())), CornerRadius::ZERO, color);
|
||||
}
|
||||
None => {
|
||||
// Indeterminate: a sweeping segment.
|
||||
let x = (ui.input(|i| i.time) as f32 * 0.8).fract();
|
||||
let seg = Rect::from_min_size(
|
||||
egui::pos2(bar.left() + bar.width() * (x * 1.3 - 0.3).max(0.0), bar.top()),
|
||||
vec2(bar.width() * 0.3, bar.height()),
|
||||
)
|
||||
.intersect(bar);
|
||||
p.rect_filled(seg, CornerRadius::ZERO, color);
|
||||
// Keep the segment moving through the track boundary without resetting visibly.
|
||||
let width = bar.width();
|
||||
let segment_width = width * 0.3;
|
||||
let x = (ui.input(|i| i.time) * 0.8).fract() as f32 * width;
|
||||
for left in [x, x - width] {
|
||||
let seg = Rect::from_min_size(egui::pos2(bar.left() + left, bar.top()), vec2(segment_width, bar.height())).intersect(bar);
|
||||
if seg.is_positive() {
|
||||
p.rect_filled(seg, CornerRadius::ZERO, color);
|
||||
}
|
||||
}
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user