change: remove gap between CPU and columns in basic ()

Removes the gap between the CPU section and other columns in basic mode.
This commit is contained in:
Clement Tsang 2021-04-24 15:08:19 -04:00 committed by GitHub
parent d4a18aea75
commit f98fa4a5f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 11 deletions
src
app/data_harvester
canvas.rs

View File

@ -189,6 +189,7 @@ pub async fn get_cpu_data_list(
})
}
// Ok(Vec::from(cpu_deque.drain(0..5).collect::<Vec<_>>()))
// Ok(Vec::from(cpu_deque.drain(0..3).collect::<Vec<_>>())) // For artificially limiting the CPU results
Ok(Vec::from(cpu_deque))
}

View File

@ -536,15 +536,24 @@ impl Painter {
}
let actual_cpu_data_len = app_state.canvas_data.cpu_data.len().saturating_sub(1);
let cpu_height = (actual_cpu_data_len / 4) as u16
+ (if actual_cpu_data_len % 4 == 0 { 0 } else { 1 });
// This fixes #397, apparently if the height is 1, it can't render the CPU bars...
let cpu_height = {
let c = (actual_cpu_data_len / 4) as u16
+ (if actual_cpu_data_len % 4 == 0 { 0 } else { 1 });
if c <= 1 {
1
} else {
c
}
};
let vertical_chunks = Layout::default()
.direction(Direction::Vertical)
.margin(0)
.constraints([
Constraint::Length(cpu_height + if cpu_height <= 1 { 1 } else { 0 }), // This fixes #397, apparently if the height is 1, it can't render the CPU bars...
Constraint::Length(if cpu_height <= 1 { 0 } else { 1 }),
Constraint::Length(cpu_height),
Constraint::Length(2),
Constraint::Length(2),
Constraint::Min(5),
@ -554,7 +563,7 @@ impl Painter {
let middle_chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
.split(vertical_chunks[2]);
.split(vertical_chunks[1]);
self.draw_basic_cpu(&mut f, app_state, vertical_chunks[0], 1);
self.draw_basic_memory(&mut f, app_state, middle_chunks[0], 2);
self.draw_basic_network(&mut f, app_state, middle_chunks[1], 3);
@ -567,7 +576,7 @@ impl Painter {
Disk => self.draw_disk_table(
&mut f,
app_state,
vertical_chunks[4],
vertical_chunks[3],
false,
widget_id,
),
@ -581,7 +590,7 @@ impl Painter {
self.draw_process_features(
&mut f,
app_state,
vertical_chunks[4],
vertical_chunks[3],
false,
wid,
);
@ -589,14 +598,14 @@ impl Painter {
Temp => self.draw_temp_table(
&mut f,
app_state,
vertical_chunks[4],
vertical_chunks[3],
false,
widget_id,
),
Battery => self.draw_battery_display(
&mut f,
app_state,
vertical_chunks[4],
vertical_chunks[3],
false,
widget_id,
),
@ -605,7 +614,7 @@ impl Painter {
}
if let Some(widget_id) = later_widget_id {
self.draw_basic_table_arrows(&mut f, app_state, vertical_chunks[3], widget_id);
self.draw_basic_table_arrows(&mut f, app_state, vertical_chunks[2], widget_id);
}
} else {
// Draws using the passed in (or default) layout.