wip: fixing the modal

This commit is contained in:
🪞👃🪞 2024-09-26 03:29:18 +03:00
parent 29f11b5977
commit 2adf0028c3
5 changed files with 57 additions and 69 deletions

View file

@ -178,6 +178,11 @@ impl<H, E: Engine> Handle<E> for Arc<RwLock<H>> where H: Handle<E> {
pub trait Component<E: Engine>: Widget<Engine = E> + Handle<E> {}
/// Everything that implements [Render] and [Handle] is a [Component].
impl<E: Engine, C: Widget<Engine = E> + Handle<E>> Component<E> for C {}
/// A UI component that can render itself and handle input
pub trait ContentComponent<E: Engine>: Widget<Engine = E> + Handle<E> {}
/// Everything that implements [Render] and [Handle] is a [Component].
impl<E: Engine, C: Content<Engine = E> + Handle<E>> ContentComponent<E> for C {}
pub trait Exit: Send {
fn exited (&self) -> bool;
fn exit (&mut self);
@ -185,6 +190,7 @@ pub trait Exit: Send {
Box::new(self)
}
}
/// Marker trait for [Component]s that can [Exit]
pub trait ExitableComponent<E>: Exit + Component<E> where E: Engine {
/// Perform type erasure for collecting heterogeneous components.

View file

@ -217,15 +217,7 @@ impl<E: Engine, W: Widget<Engine = E>> Layout<E> for W {}
pub struct DebugOverlay<E: Engine, W: Widget<Engine = E>>(pub W);
pub struct ModalHost<E: Engine, M: Widget<Engine = E>, W: Widget<Engine = E>>(
pub bool, pub M, pub W
);
pub enum Fill<E: Engine, W: Widget<Engine = E>> {
X(W),
Y(W),
XY(W)
}
pub enum Fill<E: Engine, W: Widget<Engine = E>> { X(W), Y(W), XY(W) }
impl<E: Engine, W: Widget<Engine = E>> Fill<E, W> {
fn inner (&self) -> &W {

View file

@ -410,21 +410,6 @@ pub trait TuiStyle: Widget<Engine = Tui> + Sized {
}
}
impl<W: Widget<Engine = Tui>> TuiStyle for W {}
impl<M: Widget<Engine = Tui>, W: Widget<Engine = Tui>> Widget for ModalHost<Tui, M, W> {
type Engine = Tui;
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
Ok(Some(to))
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
self.2.render(to)?;
if self.0 {
to.fill_bg(to.area(), COLOR_BG1);
to.fill_fg(to.area(), COLOR_BG2);
self.1.render(to)?;
}
Ok(())
}
}
pub struct Foreground(pub Color);
impl Widget for Foreground {