pub trait Application: Send + 'static {
// Required methods
fn initialize(&mut self, ctx: &Context, event_loop: &ActiveEventLoop);
fn window_event(
&mut self,
ctx: &Context,
event_loop: &ActiveEventLoop,
window_id: WindowId,
event: WindowEvent,
);
// Provided methods
fn device_event(
&mut self,
ctx: &Context,
event_loop: &ActiveEventLoop,
device_id: DeviceId,
event: DeviceEvent,
) { ... }
fn update(&mut self, ctx: &Context, event_loop: &ActiveEventLoop) { ... }
fn exiting(&mut self, ctx: &Context) { ... }
}Expand description
应用程序生命周期 trait(桌面端)。
上层 crate(如 iris-app)实现此 trait 来定义应用生命周期。
Required Methods§
Sourcefn initialize(&mut self, ctx: &Context, event_loop: &ActiveEventLoop)
fn initialize(&mut self, ctx: &Context, event_loop: &ActiveEventLoop)
当事件循环启动、窗口即将创建时调用。
Sourcefn window_event(
&mut self,
ctx: &Context,
event_loop: &ActiveEventLoop,
window_id: WindowId,
event: WindowEvent,
)
fn window_event( &mut self, ctx: &Context, event_loop: &ActiveEventLoop, window_id: WindowId, event: WindowEvent, )
窗口事件回调。
Provided Methods§
Sourcefn device_event(
&mut self,
ctx: &Context,
event_loop: &ActiveEventLoop,
device_id: DeviceId,
event: DeviceEvent,
)
fn device_event( &mut self, ctx: &Context, event_loop: &ActiveEventLoop, device_id: DeviceId, event: DeviceEvent, )
设备/系统事件回调(如屏幕 DPI 变化、时间戳等)。
Sourcefn update(&mut self, ctx: &Context, event_loop: &ActiveEventLoop)
fn update(&mut self, ctx: &Context, event_loop: &ActiveEventLoop)
每帧更新回调(AboutToWait 事件)。