MCPcopy Create free account
hub / github.com/Kethku/Pando / new

Method new

aspen/src/application.rs:31–60  ·  view source on GitHub ↗
(root_constructor: F)

Source from the content-addressed store, hash-verified

29
30impl<Root: Element> Application<Root> {
31 pub fn new<F>(root_constructor: F) -> Self
32 where F: for<'a> FnOnce(&mut Context<'a>) -> ElementPointer<Root>,
33 {
34 let event_state = EventState::new();
35 let shaper = RefCell::new(Shaper::new());
36 let states = RefCell::new(HashMap::new());
37 let focused_element = RefCell::new(None);
38 let base_token = Token::new::<Self>();
39
40 let root = {
41 let tokens = Vec::new();
42 let mut context = Context::new(&event_state, &shaper, &states, &focused_element, base_token, &tokens);
43 RefCell::new(root_constructor(&mut context))
44 };
45
46 Application {
47 mouse_region_manager: RefCell::new(MouseRegionManager::new()),
48 event_state,
49 shaper,
50
51 regions: RefCell::new(HashMap::new()),
52 states,
53 tokens: Arc::new(Vec::new()),
54 focused_element,
55 base_token,
56 force_redraw: false,
57
58 root
59 }
60 }
61
62 pub fn token(&self) -> Token {
63 self.root.borrow().token()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected