Trait components::foundation::AsyncActivity
source · [−]pub trait AsyncActivity<R>: Context {
type Error: Sized + Debug;
Show 27 methods
fn resized(
&mut self,
runner: &mut R,
context: &mut Self::Context,
width: u32,
height: u32
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>>;
fn render(
&mut self,
runner: &mut R,
context: &mut Self::Context,
t: Time
) -> Pin<Box<dyn Future<Output = bool> + Send + 'static, Global>>;
fn suspend(
&mut self,
runner: &mut R,
context: &mut Self::Context
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn resume(
&mut self,
runner: &mut R,
context: &mut Self::Context
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn moved(
&mut self,
runner: &mut R,
context: &mut Self::Context,
x: i32,
y: i32
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn close(
&mut self,
runner: &mut R,
context: &mut Self::Context
) -> Pin<Box<dyn Future<Output = ControlFlow> + Send + 'static, Global>> { ... }
fn destroyed(
&mut self,
runner: &mut R,
context: &mut Self::Context
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn dropped_file(
&mut self,
runner: &mut R,
context: &mut Self::Context,
path: &PathBuf
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn hovered_file(
&mut self,
runner: &mut R,
context: &mut Self::Context,
path: &PathBuf
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn hovered_file_cancelled(
&mut self,
runner: &mut R,
context: &mut Self::Context
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn received_character(
&mut self,
runner: &mut R,
context: &mut Self::Context,
character: char
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn focused(
&mut self,
runner: &mut R,
context: &mut Self::Context,
is_focused: bool
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn keyboard_input(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
input: &KeyboardInput,
is_synthetic: bool
) -> Pin<Box<dyn Future<Output = ControlFlow> + Send + 'static, Global>> { ... }
fn modifiers_changed(
&mut self,
runner: &mut R,
context: &mut Self::Context,
state: &ModifiersState
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn cursor_moved(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
position: &PhysicalPosition<f64>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn cursor_entered(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn cursor_left(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn mouse_wheel(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
delta: &MouseScrollDelta,
phase: &TouchPhase
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn mouse_input(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
state: &ElementState,
button: &MouseButton
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn touchpad_pressure(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
pressure: f32,
stage: i64
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn axis_motion(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
axis: &u32,
value: f64
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn touch(
&mut self,
runner: &mut R,
context: &mut Self::Context,
touch: &Touch
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn scale_factor_changed(
&mut self,
runner: &mut R,
context: &mut Self::Context,
scale_factor: f64,
new_inner_size: &&mut PhysicalSize<u32>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn theme_changed(
&mut self,
runner: &mut R,
context: &mut Self::Context,
theme: &Theme
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn main_events_cleared(
&mut self,
runner: &mut R,
context: &mut Self::Context
) -> Pin<Box<dyn Future<Output = bool> + Send + 'static, Global>> { ... }
fn before_event(
&mut self,
runner: &mut R,
context: &mut Self::Context,
event: &WindowEvent<'_>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
fn after_event(
&mut self,
runner: &mut R,
context: &mut Self::Context,
event: &WindowEvent<'_>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>> { ... }
}
Expand description
Defines asynchronous application behavior.
Simple application is basically just a single fn that takes the current time and display something.
Required Associated Types
Required Methods
Resize the application when the framebuffer gets resized.
The runner is passed so that specific resizing is possible.
Render the application at a given time.
The runner is passed so that specific rendering is possible.
return agressive
state. true for applications which FPS aggressive,
like a games or animation/media oriented applications.
also you can change the behaviour for your needs.
Provided Methods
Notify the application has been suspended.
Notify the application has been resumed.
The position of the window has changed. Contains the window’s new position.
The window has been requested to close.
By default application will exit
The window has been destroyed.
A file has been dropped into the window.
When the user drops multiple files at once, this event will be emitted for each file separately.
A file is being hovered over the window.
When the user hovers multiple files at once, this event will be emitted for each file separately.
A file was hovered, but has exited the window.
There will be a single HoveredFileCancelled
event triggered even if multiple files were
hovered.
The window received a unicode character.
The window gained or lost focus.
The parameter is true if the window has gained focus, and false if it has lost focus.
fn keyboard_input(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
input: &KeyboardInput,
is_synthetic: bool
) -> Pin<Box<dyn Future<Output = ControlFlow> + Send + 'static, Global>>
fn keyboard_input(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
input: &KeyboardInput,
is_synthetic: bool
) -> Pin<Box<dyn Future<Output = ControlFlow> + Send + 'static, Global>>
An event from the keyboard has been received.
If true
, the event was generated synthetically by winit
in one of the following circumstances:
Synthetic key press events are generated for all keys pressed when a window gains focus. Likewise, synthetic key release events are generated for all keys pressed when a window goes out of focus. Currently, this is only functional on X11 and Windows
Otherwise, this value is always false
.
The keyboard modifiers have changed.
Platform-specific behavior:
- Web: This API is currently unimplemented on the web. This isn’t by design - it’s an issue, and it should get fixed - but it’s the current state of the API.
The cursor has moved on the window.
(x,y) coords in pixels relative to the top-left corner of the window. Because the range of this data is limited by the display area and it may have been transformed by the OS to implement effects such as cursor acceleration, it should not be used to implement non-cursor-like interactions such as 3D camera control.
The cursor has entered the window.
The cursor has left the window.
fn mouse_wheel(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
delta: &MouseScrollDelta,
phase: &TouchPhase
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>>
fn mouse_wheel(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
delta: &MouseScrollDelta,
phase: &TouchPhase
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>>
A mouse wheel movement or touchpad scroll occurred.
fn mouse_input(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
state: &ElementState,
button: &MouseButton
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>>
fn mouse_input(
&mut self,
runner: &mut R,
context: &mut Self::Context,
device_id: &DeviceId,
state: &ElementState,
button: &MouseButton
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>>
An mouse button press has been received.
Touchpad pressure event.
At the moment, only supported on Apple forcetouch-capable macbooks. The parameters are: pressure level (value between 0 and 1 representing how hard the touchpad is being pressed) and stage (integer representing the click level).
Motion on some analog axis. May report data redundant to other, more specific events.
Touch event has been received
The window’s scale factor has changed.
The following user actions can cause DPI changes:
Changing the display’s resolution. Changing the display’s scale factor (e.g. in Control Panel on Windows). Moving the window to a display with a different scale factor.
After this event callback has been processed, the window will be resized to whatever value
is pointed to by the new_inner_size
reference. By default, this will contain the size suggested
by the OS, but it can be changed to any value.
The system window theme has changed.
Applications might wish to react to this to change the theme of the content of the window when the system changes the window theme.
At the moment this is only supported on Windows.
Analogue of winit::MainEventsCleared
Used to route winit :: WindowEvent to external handlers (third party UI handlers, etc.). Called before internal matching