diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-12-22 02:19:46 -0500 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2021-01-25 01:30:35 -0500 |
commit | da6d4992fb70d2eb07979f10e5067bd349ebc233 (patch) | |
tree | c7bec0e921aa9b15a0a0d7231ddc60adaf2e6f41 | |
parent | 88366b37140656f6b6e5364db296fc3b37641fc4 (diff) |
bug: Fixes incorrect colours being used the CPU widget in basic mode (#373)
Fixes the colour order being off in basic mode, and not using the average CPU colour.
(cherry picked from commit 23ad597d18f28cbe079f29f720d74506bd858c53)
-rw-r--r-- | src/canvas/widgets/cpu_basic.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/canvas/widgets/cpu_basic.rs b/src/canvas/widgets/cpu_basic.rs index 12b9949a..1ac1b3a6 100644 --- a/src/canvas/widgets/cpu_basic.rs +++ b/src/canvas/widgets/cpu_basic.rs @@ -49,6 +49,7 @@ impl CpuBasicWidget for Painter { } let num_cpus = cpu_data.len(); + let show_avg_cpu = app_state.app_config_fields.show_average_cpu; if draw_loc.height > 0 { let remaining_height = usize::from(draw_loc.height); @@ -158,11 +159,20 @@ impl CpuBasicWidget for Painter { let end_index = min(start_index + how_many_cpus, num_cpus); let cpu_column = (start_index..end_index) - .map(|cpu_index| { + .map(|itx| { Spans::from(Span { - content: (&cpu_bars[cpu_index]).into(), - style: self.colours.cpu_colour_styles - [cpu_index % self.colours.cpu_colour_styles.len()], + content: (&cpu_bars[itx]).into(), + style: if show_avg_cpu { + if itx == 0 { + self.colours.avg_colour_style + } else { + self.colours.cpu_colour_styles + [(itx - 1) % self.colours.cpu_colour_styles.len()] + } + } else { + self.colours.cpu_colour_styles + [(itx - 1) % self.colours.cpu_colour_styles.len()] + }, }) }) .collect::<Vec<_>>(); |