1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
mod canvas;
mod capture;
mod elementary;
mod layout;
mod painter;
mod placement;

pub use self::canvas::*;
pub use self::capture::*;
pub use self::elementary::*;
pub use self::layout::*;
pub use self::painter::*;
pub use self::placement::*;
use crate::geometry::*;
use crate::input::*;
use std::io;

pub trait Widget {
    fn render(&self, painter: &mut Painter) -> io::Result<()> {
        Ok(())
    }
    fn arrange(&mut self, _window: Window) {}
    fn consume(&mut self, input: Vec<GrinInput>) -> Vec<GrinInput> {
        input
    }
    fn captures(&self, window: Window, point: Point) -> bool {
        (window & point).is_some()
    }
}