Introduce second memory gauge
This commit is contained in:
parent
05ec879113
commit
28ed05e654
|
@ -191,26 +191,11 @@ impl ConsoleUI {
|
||||||
self.terminal.draw(|frame| {
|
self.terminal.draw(|frame| {
|
||||||
// Create layout elements
|
// Create layout elements
|
||||||
let main_layout = Layout::default().direction(Direction::Vertical).constraints([
|
let main_layout = Layout::default().direction(Direction::Vertical).constraints([
|
||||||
Constraint::Length(3),
|
|
||||||
Constraint::Length(3),
|
Constraint::Length(3),
|
||||||
Constraint::Min(3)
|
Constraint::Min(3)
|
||||||
]).split(frame.size()).to_vec();
|
]).split(frame.size()).to_vec();
|
||||||
let stats_layout = Layout::default().direction(Direction::Vertical).constraints([
|
|
||||||
Constraint::Min(3),
|
|
||||||
Constraint::Length(3)
|
|
||||||
]).split(main_layout[2]).to_vec();
|
|
||||||
|
|
||||||
// Elements
|
// Elements
|
||||||
let titel_bar = {
|
|
||||||
Paragraph::new("psxreadmap")
|
|
||||||
.style(Style::default().fg(Color::White))
|
|
||||||
.alignment(Alignment::Center)
|
|
||||||
.block(Block::default()
|
|
||||||
.borders(Borders::ALL)
|
|
||||||
.style(Style::default().fg(Color::White))
|
|
||||||
.border_type(BorderType::Plain)
|
|
||||||
)
|
|
||||||
};
|
|
||||||
let menu_bar = {
|
let menu_bar = {
|
||||||
const MENU_TITLES: &'static [&'static str] = &["Stats", "Quit"];
|
const MENU_TITLES: &'static [&'static str] = &["Stats", "Quit"];
|
||||||
|
|
||||||
|
@ -224,7 +209,7 @@ impl ConsoleUI {
|
||||||
|
|
||||||
Tabs::new(menu).select(self.menu_selection.get_id()).block(
|
Tabs::new(menu).select(self.menu_selection.get_id()).block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.title("Menu").borders(Borders::ALL))
|
.title("psxreadmap - Menu").borders(Borders::ALL))
|
||||||
.style(Style::default().fg(Color::White))
|
.style(Style::default().fg(Color::White))
|
||||||
.highlight_style(Style::default().bg(Color::LightYellow))
|
.highlight_style(Style::default().bg(Color::LightYellow))
|
||||||
.divider(Span::raw("|")
|
.divider(Span::raw("|")
|
||||||
|
@ -232,14 +217,13 @@ impl ConsoleUI {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Render screen
|
// Render screen
|
||||||
frame.render_widget(titel_bar, main_layout[0]);
|
frame.render_widget(menu_bar, main_layout[0]);
|
||||||
frame.render_widget(menu_bar, main_layout[1]);
|
|
||||||
match self.menu_selection {
|
match self.menu_selection {
|
||||||
MenuSelection::Stats => {
|
MenuSelection::Stats => {
|
||||||
Self::render_stats(frame, &stats_layout, &self.content_selection, &mut self.data);
|
Self::render_stats(frame, main_layout[1], &self.content_selection, &mut self.data);
|
||||||
},
|
},
|
||||||
MenuSelection::Quit => {
|
MenuSelection::Quit => {
|
||||||
frame.render_widget(Self::create_exit_message(), main_layout[2]);
|
frame.render_widget(Self::create_exit_message(), main_layout[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
|
@ -254,7 +238,12 @@ impl ConsoleUI {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_stats(frame: &mut ConsoleFrame, frames: &Vec<Rect>, content_selection: &ListSelection, data: &mut ConsoleUIData) {
|
fn render_stats(frame: &mut ConsoleFrame, layout: Rect, content_selection: &ListSelection, data: &mut ConsoleUIData) {
|
||||||
|
let layout = Layout::default().direction(Direction::Vertical).constraints([
|
||||||
|
Constraint::Min(3),
|
||||||
|
Constraint::Min(3),
|
||||||
|
Constraint::Length(3),
|
||||||
|
]).split(layout).to_vec();
|
||||||
let content_list = List::new({
|
let content_list = List::new({
|
||||||
let mut vec = Vec::new();
|
let mut vec = Vec::new();
|
||||||
|
|
||||||
|
@ -268,14 +257,16 @@ impl ConsoleUI {
|
||||||
.style(Style::default().fg(Color::White))
|
.style(Style::default().fg(Color::White))
|
||||||
.border_type(BorderType::Plain)
|
.border_type(BorderType::Plain)
|
||||||
)
|
)
|
||||||
.highlight_style(Style::default().bg(Color::Yellow));
|
.highlight_style(Style::default().bg(Color::Cyan));
|
||||||
let mem_gauge = Self::create_mem_gauge("Overall memory usage", data.highest_adr, Color::Cyan);
|
let first_mem_gauge = Self::create_mem_gauge("Overall memory usage", data.highest_adr, Color::Cyan);
|
||||||
|
let second_mem_gauge = Self::create_mem_gauge("Overall memory usage", data.highest_adr, Color::Red);
|
||||||
let mut list_state = ListState::default();
|
let mut list_state = ListState::default();
|
||||||
|
|
||||||
list_state.select(content_selection.selection);
|
list_state.select(content_selection.selection);
|
||||||
|
|
||||||
frame.render_stateful_widget(content_list, frames[0], &mut list_state);
|
frame.render_stateful_widget(content_list, layout[0], &mut list_state);
|
||||||
frame.render_widget(mem_gauge, frames[1]);
|
frame.render_widget(first_mem_gauge, layout[1]);
|
||||||
|
frame.render_widget(second_mem_gauge, layout[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_mem_gauge<'a>(name: &str, adr: u64, color: Color) -> Gauge<'a> {
|
fn create_mem_gauge<'a>(name: &str, adr: u64, color: Color) -> Gauge<'a> {
|
||||||
|
|
Loading…
Reference in New Issue