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
30
31
32
33
34
35
36
37
use fltk::prelude::WidgetExt;
use fltk::widget::Widget;

pub mod button;
pub mod frame;
pub mod grid;
pub mod input;
pub mod misc;
pub mod text;
mod wrappers;

pub use self::wrappers::{SimpleWrapper, WrapperFactory};

pub trait LayoutElement {
    fn min_size(&self) -> Size;
    fn layout(&self, x: i32, y: i32, width: i32, height: i32);
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct Size {
    pub width: i32,
    pub height: i32,
}

pub trait IntoWidget: Clone {
    fn into_widget(self) -> Widget;
}

impl<W: WidgetExt + Clone> IntoWidget for W {
    fn into_widget(self) -> Widget {
        self.as_base_widget()
    }
}

pub trait LayoutWidgetWrapper<W: IntoWidget>: LayoutElement {
    fn wrap(widget: W) -> Self;
}