bug: fix broken basic table arrows on other widgets

This commit is contained in:
ClementTsang 2020-04-29 23:12:49 -04:00
parent b75eeaea46
commit dacf8b1abb
2 changed files with 18 additions and 8 deletions

View File

@ -386,9 +386,18 @@ impl Painter {
self.draw_basic_cpu(&mut f, app_state, vertical_chunks[0], 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_memory(&mut f, app_state, middle_chunks[0], 2);
self.draw_basic_network(&mut f, app_state, middle_chunks[1], 3); self.draw_basic_network(&mut f, app_state, middle_chunks[1], 3);
self.draw_basic_table_arrows(&mut f, app_state, vertical_chunks[3]);
if let Some(basic_table_widget_state) = &app_state.basic_table_widget_state { if let Some(basic_table_widget_state) = &app_state.basic_table_widget_state {
let widget_id = basic_table_widget_state.currently_displayed_widget_id; let widget_id = basic_table_widget_state.currently_displayed_widget_id;
if let Some(current_table) = app_state.widget_map.get(&widget_id) {
self.draw_basic_table_arrows(
&mut f,
app_state,
vertical_chunks[3],
current_table,
);
}
match basic_table_widget_state.currently_displayed_widget_type { match basic_table_widget_state.currently_displayed_widget_type {
Disk => self.draw_disk_table( Disk => self.draw_disk_table(
&mut f, &mut f,

View File

@ -1,7 +1,10 @@
use std::cmp::max; use std::cmp::max;
use crate::{ use crate::{
app::{layout_manager::BottomWidgetType, App}, app::{
layout_manager::{BottomWidget, BottomWidgetType},
App,
},
canvas::Painter, canvas::Painter,
}; };
@ -14,19 +17,18 @@ use tui::{
pub trait BasicTableArrows { pub trait BasicTableArrows {
fn draw_basic_table_arrows<B: Backend>( fn draw_basic_table_arrows<B: Backend>(
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, &self, f: &mut Frame<'_, B>, app_state: &App, draw_loc: Rect, current_table: &BottomWidget,
); );
} }
impl BasicTableArrows for Painter { impl BasicTableArrows for Painter {
fn draw_basic_table_arrows<B: Backend>( fn draw_basic_table_arrows<B: Backend>(
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, &self, f: &mut Frame<'_, B>, app_state: &App, draw_loc: Rect, current_table: &BottomWidget,
) { ) {
// Effectively a paragraph with a ton of spacing // Effectively a paragraph with a ton of spacing
let (left_table, right_table) = ( let (left_table, right_table) = (
{ {
app_state current_table
.current_widget
.left_neighbour .left_neighbour
.map(|left_widget_id| { .map(|left_widget_id| {
app_state app_state
@ -38,8 +40,7 @@ impl BasicTableArrows for Painter {
.unwrap_or_else(|| &BottomWidgetType::Temp) .unwrap_or_else(|| &BottomWidgetType::Temp)
}, },
{ {
app_state current_table
.current_widget
.right_neighbour .right_neighbour
.map(|right_widget_id| { .map(|right_widget_id| {
app_state app_state