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
38
39
40
41
42
43
44
45
46
47
use druid::kurbo::{Rect, Size};
use crate::flex::FlexParams;
use crate::glue::DruidAppData;
use druid::{
BoxConstraints, Env, Event, EventCtx, LayoutCtx, LifeCycle, LifeCycleCtx, PaintCtx, UpdateCtx,
};
pub trait WidgetSequence {
fn widgets(&mut self) -> Vec<&mut dyn FlexWidget>;
}
pub trait FlexWidget {
fn flex_params(&self) -> FlexParams;
fn event(&mut self, ctx: &mut EventCtx, event: &Event, data: &mut DruidAppData, env: &Env);
fn lifecycle(
&mut self,
ctx: &mut LifeCycleCtx,
event: &LifeCycle,
data: &DruidAppData,
env: &Env,
);
fn update(
&mut self,
ctx: &mut UpdateCtx,
old_data: &DruidAppData,
data: &DruidAppData,
env: &Env,
);
fn layout(
&mut self,
ctx: &mut LayoutCtx,
bc: &BoxConstraints,
data: &DruidAppData,
env: &Env,
) -> Size;
fn paint_rect(&self) -> Rect;
fn set_layout_rect(&mut self, ctx: &mut LayoutCtx, data: &DruidAppData, env: &Env, rect: Rect);
fn layout_rect(&self) -> Rect;
fn paint(&mut self, ctx: &mut PaintCtx, data: &DruidAppData, env: &Env);
}