utilities/widgets: only advance stage by timer in ProgressSpinner
parent
393c5d0d53
commit
d8d66641e2
|
@ -654,7 +654,7 @@ impl fmt::Display for StatusBar {
|
||||||
|
|
||||||
impl StatusBar {
|
impl StatusBar {
|
||||||
pub fn new(context: &Context, container: Box<dyn Component>) -> Self {
|
pub fn new(context: &Context, container: Box<dyn Component>) -> Self {
|
||||||
let mut progress_spinner = ProgressSpinner::new(0);
|
let mut progress_spinner = ProgressSpinner::new(19);
|
||||||
match context.settings.terminal.progress_spinner_sequence.as_ref() {
|
match context.settings.terminal.progress_spinner_sequence.as_ref() {
|
||||||
Some(conf::terminal::ProgressSpinnerSequence::Integer(k)) => {
|
Some(conf::terminal::ProgressSpinnerSequence::Integer(k)) => {
|
||||||
progress_spinner.set_kind(*k);
|
progress_spinner.set_kind(*k);
|
||||||
|
|
|
@ -1180,16 +1180,8 @@ impl Component for ProgressSpinner {
|
||||||
if self.active {
|
if self.active {
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
match self.kind.as_ref() {
|
match self.kind.as_ref() {
|
||||||
Ok(kind) => {
|
Ok(kind) => Self::KINDS[*kind][self.stage].as_ref(),
|
||||||
let stage = self.stage;
|
Err(custom) => custom[self.stage].as_ref(),
|
||||||
self.stage = (self.stage + 1).wrapping_rem(Self::KINDS[*kind].len());
|
|
||||||
Self::KINDS[*kind][stage].as_ref()
|
|
||||||
}
|
|
||||||
Err(custom) => {
|
|
||||||
let stage = self.stage;
|
|
||||||
self.stage = (self.stage + 1).wrapping_rem(custom.len());
|
|
||||||
custom[stage].as_ref()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
grid,
|
grid,
|
||||||
theme_attr.fg,
|
theme_attr.fg,
|
||||||
|
@ -1207,6 +1199,14 @@ impl Component for ProgressSpinner {
|
||||||
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
|
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
|
||||||
match event {
|
match event {
|
||||||
UIEvent::Timer(id) if *id == self.timer.si_value => {
|
UIEvent::Timer(id) if *id == self.timer.si_value => {
|
||||||
|
match self.kind.as_ref() {
|
||||||
|
Ok(kind) => {
|
||||||
|
self.stage = (self.stage + 1).wrapping_rem(Self::KINDS[*kind].len());
|
||||||
|
}
|
||||||
|
Err(custom) => {
|
||||||
|
self.stage = (self.stage + 1).wrapping_rem(custom.len());
|
||||||
|
}
|
||||||
|
}
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue