lgui_core/command/
context.rs1use std::sync::Arc;
2
3use crate::{application::ApplicationContext, events::Event};
4
5#[derive(Clone)]
6pub struct CommandContext {
7 application: ApplicationContext,
8}
9
10impl CommandContext {
11 pub(crate) fn new(application: ApplicationContext) -> Self {
12 Self { application }
13 }
14
15 pub fn application(&self) -> ApplicationContext {
16 self.application.clone()
17 }
18
19 pub fn resource<T>(&self) -> Arc<T>
20 where
21 T: Send + Sync + 'static,
22 {
23 self.application.resource::<T>()
24 }
25
26 pub fn emit<E>(&self, event: E) -> usize
27 where
28 E: Event,
29 {
30 self.application.emit(event)
31 }
32}