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
48
49
50
51
52
use {
    crate::{
        makepad_draw::*,
        widget::*
    }
};
live_design!{
    import makepad_draw::shader::std::*;
    
    HookWidgetBase = {{HookWidget}} {}
}

#[derive(Live)]
pub struct HookWidget {
    #[walk] walk: Walk,
    #[layout] layout: Layout,
    #[rust] draw_state: DrawStateWrap<DrawState>,
}

impl LiveHook for HookWidget{
    fn before_live_design(cx:&mut Cx){
        register_widget!(cx,HookWidget)
    }
}

#[derive(Clone)]
enum DrawState {
    Hook,
}

impl Widget for HookWidget{
   fn handle_widget_event_with(
        &mut self,
        _cx: &mut Cx,
        _event: &Event,
        _dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem)
    ) {
    }

    fn walk(&mut self, _cx:&mut Cx)->Walk{
        self.walk
    }
    
    fn redraw(&mut self, _cx:&mut Cx){}
    
    fn draw_walk_widget(&mut self, cx: &mut Cx2d, _walk: Walk) -> WidgetDraw {
        if self.draw_state.begin(cx, DrawState::Hook) {
            return WidgetDraw::hook_above();
        }
        WidgetDraw::done()
    }
}