diff --git a/src/view/dialog.rs b/src/view/dialog.rs index 7e5daf8..5a8c9f3 100644 --- a/src/view/dialog.rs +++ b/src/view/dialog.rs @@ -1,12 +1,28 @@ use crate::*; impl Perch { + pub fn render_dialog (&self, to: &mut TuiOut) { + match self.mode { + Some(Mode::Edit { .. }) => {}, + Some(_) => to.tint_all(Color::Rgb(96,96,96), Color::Rgb(48,48,48), Modifier::DIM), + _ => {} + } + match self.mode { + Some(Mode::Edit { .. }) => {}, + Some(Mode::Save { choice }) => Content::render(&self.dialog_save(choice), to), + Some(Mode::Quit { choice }) => Content::render(&self.dialog_quit(choice), to), + Some(Mode::Help { page }) => Content::render(&self.dialog_help(page), to), + _ => {}, + } + } fn dialog (content: impl Content) -> impl Content { - let pos = |x|Fill::xy( Align::c(x)); - let style = |x|Tui::modify(false, Modifier::DIM, Tui::fg_bg(FG_MODAL, BG_MODAL, x)); - let border = |x|Margin::xy(1, 1, Bsp::b(Border(true, Lozenge(true, Default::default())), x)); - let bg = |x|Bsp::a(x, Repeat(" ")); - pos(style(border(bg(content)))) + Bsp::b( + Fill::xy(Tui::fg_bg(Color::Rgb(64,64,64), Color::Rgb(32,32,32), "")), + Fixed::xy(64, 15, Tui::fg_bg(Color::Rgb(255,255,255), Color::Rgb(16,16,16), Bsp::b( + Repeat(" "), + Outer(true, Style::default().fg(Tui::g(96))).enclose(content) + ))) + ) } fn dialog_help (&self, _page: u8) -> impl Content { Self::dialog(Bsp::s( @@ -22,7 +38,8 @@ impl Perch { ]; Self::dialog(Bsp::s( format!("Save {} change(s)?", self.changes), - Bsp::s("", Bsp::e(choices[0], Bsp::e(choices[1], choices[2]))))) + Bsp::s("", Bsp::e(choices[0], Bsp::e(choices[1], choices[2]))) + )) } fn dialog_quit (&self, choice: u8) -> impl Content { let choices = [ @@ -32,20 +49,7 @@ impl Perch { ]; Self::dialog(Bsp::s( format!("Save {} change(s) before exiting?", self.changes), - Bsp::s("", Bsp::e(choices[0], Bsp::e(choices[1], choices[2]))))) - } - pub fn render_dialog (&self, to: &mut TuiOut) { - match self.mode { - Some(Mode::Edit { .. }) => {}, - Some(_) => to.tint_all(Color::Rgb(96,96,96), Color::Rgb(48,48,48), Modifier::DIM), - _ => {} - } - match self.mode { - Some(Mode::Edit { .. }) => {}, - Some(Mode::Save { choice }) => Content::render(&self.dialog_save(choice), to), - Some(Mode::Quit { choice }) => Content::render(&self.dialog_quit(choice), to), - Some(Mode::Help { page }) => Content::render(&self.dialog_help(page), to), - _ => {}, - } + Bsp::s("", Bsp::e(choices[0], Bsp::e(choices[1], choices[2]))) + )) } }