agui_primitives/
drawable.rs1use agui_core::{
2 context::WidgetContext,
3 layout::Layout,
4 unit::{Color, Shape},
5 widget::{BuildResult, WidgetBuilder, WidgetRef},
6 Ref,
7};
8use agui_macros::Widget;
9
10#[derive(Clone, Default)]
11pub struct DrawableStyle {
12 pub color: Color,
13}
14
15#[derive(Widget)]
16pub struct Drawable {
17 pub layout: Ref<Layout>,
18
19 pub shape: Shape,
20 pub style: Option<DrawableStyle>,
21
22 pub child: WidgetRef,
23}
24
25impl Default for Drawable {
26 fn default() -> Self {
27 Self {
28 layout: Ref::default(),
29
30 shape: Shape::default(),
31 style: Option::default(),
32
33 child: WidgetRef::default(),
34 }
35 }
36}
37
38impl WidgetBuilder for Drawable {
39 fn build(&self, ctx: &WidgetContext) -> BuildResult {
40 ctx.set_layout(Ref::clone(&self.layout));
41
42 (&self.child).into()
43 }
44}