Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
1 changed files with 16 additions and 25 deletions
Showing only changes of commit 28ed05e654 - Show all commits

View File

@ -191,26 +191,11 @@ impl ConsoleUI {
self.terminal.draw(|frame| {
// Create layout elements
let main_layout = Layout::default().direction(Direction::Vertical).constraints([
Constraint::Length(3),
Constraint::Length(3),
Constraint::Min(3)
]).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
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 = {
const MENU_TITLES: &'static [&'static str] = &["Stats", "Quit"];
@ -224,7 +209,7 @@ impl ConsoleUI {
Tabs::new(menu).select(self.menu_selection.get_id()).block(
Block::default()
.title("Menu").borders(Borders::ALL))
.title("psxreadmap - Menu").borders(Borders::ALL))
.style(Style::default().fg(Color::White))
.highlight_style(Style::default().bg(Color::LightYellow))
.divider(Span::raw("|")
@ -232,14 +217,13 @@ impl ConsoleUI {
};
// Render screen
frame.render_widget(titel_bar, main_layout[0]);
frame.render_widget(menu_bar, main_layout[1]);
frame.render_widget(menu_bar, main_layout[0]);
match self.menu_selection {
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 => {
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(())
}
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 mut vec = Vec::new();
@ -268,14 +257,16 @@ impl ConsoleUI {
.style(Style::default().fg(Color::White))
.border_type(BorderType::Plain)
)
.highlight_style(Style::default().bg(Color::Yellow));
let mem_gauge = Self::create_mem_gauge("Overall memory usage", data.highest_adr, Color::Cyan);
.highlight_style(Style::default().bg(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();
list_state.select(content_selection.selection);
frame.render_stateful_widget(content_list, frames[0], &mut list_state);
frame.render_widget(mem_gauge, frames[1]);
frame.render_stateful_widget(content_list, layout[0], &mut list_state);
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> {