Pass application context to GUI. #11
@ -1,4 +1,3 @@
|
|||||||
use log::info;
|
|
||||||
use ratatui::buffer::Buffer;
|
use ratatui::buffer::Buffer;
|
||||||
use ratatui::layout::{Constraint, Direction, Layout, Rect};
|
use ratatui::layout::{Constraint, Direction, Layout, Rect};
|
||||||
use ratatui::text::{Line, Span};
|
use ratatui::text::{Line, Span};
|
||||||
@ -21,14 +20,6 @@ impl Widget for About {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
let kilroy_rect = Rect {
|
|
||||||
x: area.x,
|
|
||||||
y: area.y + 8,
|
|
||||||
width: 85,
|
|
||||||
height: 35,
|
|
||||||
};
|
|
||||||
info!(target: About::ID, "Created rect: {kilroy_rect:?}");
|
|
||||||
|
|
||||||
let chunks = Layout::default()
|
let chunks = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints([
|
.constraints([
|
||||||
@ -37,12 +28,20 @@ impl Widget for About {
|
|||||||
])
|
])
|
||||||
.split(area);
|
.split(area);
|
||||||
let kilroy = [
|
let kilroy = [
|
||||||
" * ",
|
" * ",
|
||||||
" |.===. ",
|
" |.===. ",
|
||||||
" {}o o{} ",
|
" {}o o{} ",
|
||||||
"-----------------------ooO--(_)--Ooo---------------------------",
|
"-ooO--(_)--Ooo",
|
||||||
" CLIDE WAS HERE ",
|
"CLIDE WAS HERE",
|
||||||
];
|
];
|
||||||
|
let kilroy_rect = Rect {
|
||||||
|
x: area.x,
|
||||||
|
y: area.y + 7,
|
||||||
|
width: area.width,
|
||||||
|
height: kilroy.len() as u16,
|
||||||
|
};
|
||||||
|
// info!(target: About::ID, "Created rect: {kilroy_rect:?}");
|
||||||
|
|
||||||
let kilroy_lines: Vec<Line> = kilroy.iter().map(|l| Line::from(Span::raw(*l))).collect();
|
let kilroy_lines: Vec<Line> = kilroy.iter().map(|l| Line::from(Span::raw(*l))).collect();
|
||||||
let about_text = [
|
let about_text = [
|
||||||
"Clide",
|
"Clide",
|
||||||
@ -65,16 +64,8 @@ impl Widget for About {
|
|||||||
.map(|l| Line::from(Span::raw(*l)))
|
.map(|l| Line::from(Span::raw(*l)))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Clear::default().render(area, buf);
|
Clear::default().render(kilroy_rect, buf);
|
||||||
Paragraph::new(kilroy_lines)
|
Clear::default().render(chunks[1], buf);
|
||||||
.block(
|
|
||||||
Block::default()
|
|
||||||
.borders(Borders::NONE)
|
|
||||||
.padding(Padding::bottom(0)),
|
|
||||||
)
|
|
||||||
.wrap(Wrap { trim: false })
|
|
||||||
.centered()
|
|
||||||
.render(kilroy_rect, buf);
|
|
||||||
Paragraph::new(about_lines)
|
Paragraph::new(about_lines)
|
||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
@ -84,5 +75,14 @@ impl Widget for About {
|
|||||||
)
|
)
|
||||||
.wrap(Wrap { trim: false })
|
.wrap(Wrap { trim: false })
|
||||||
.render(chunks[1], buf);
|
.render(chunks[1], buf);
|
||||||
|
Paragraph::new(kilroy_lines)
|
||||||
|
.block(
|
||||||
|
Block::default()
|
||||||
|
.borders(Borders::NONE)
|
||||||
|
.padding(Padding::bottom(0)),
|
||||||
|
)
|
||||||
|
.wrap(Wrap { trim: false })
|
||||||
|
.centered()
|
||||||
|
.render(kilroy_rect, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -230,7 +230,7 @@ impl<'a> Widget for &mut App<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.about {
|
if self.about {
|
||||||
let about_area = area.centered(Constraint::Percentage(40), Constraint::Percentage(60));
|
let about_area = area.centered(Constraint::Percentage(40), Constraint::Percentage(50));
|
||||||
About::new().render(about_area, buf);
|
About::new().render(about_area, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user