zng_view_api

Enum Event

source
pub enum Event {
Show 59 variants Inited(Inited), Suspended, Disconnected(ViewProcessGen), WindowOpened(WindowId, WindowOpenData), HeadlessOpened(WindowId, HeadlessOpenData), WindowOrHeadlessOpenError { id: WindowId, error: Txt, }, FrameRendered(EventFrameRendered), WindowChanged(WindowChanged), DragHovered { window: WindowId, data: Vec<DragDropData>, allowed: DragDropEffect, }, DragMoved { window: WindowId, coalesced_pos: Vec<DipPoint>, position: DipPoint, }, DragDropped { window: WindowId, data: Vec<DragDropData>, allowed: DragDropEffect, drop_id: DragDropId, }, DragCancelled { window: WindowId, }, AppDragEnded { window: WindowId, drag: DragDropId, applied: DragDropEffect, }, FocusChanged { prev: Option<WindowId>, new: Option<WindowId>, }, KeyboardInput { window: WindowId, device: DeviceId, key_code: KeyCode, state: KeyState, key_location: KeyLocation, key: Key, key_modified: Key, text: Txt, }, Ime { window: WindowId, ime: Ime, }, MouseMoved { window: WindowId, device: DeviceId, coalesced_pos: Vec<DipPoint>, position: DipPoint, }, MouseEntered { window: WindowId, device: DeviceId, }, MouseLeft { window: WindowId, device: DeviceId, }, MouseWheel { window: WindowId, device: DeviceId, delta: MouseScrollDelta, phase: TouchPhase, }, MouseInput { window: WindowId, device: DeviceId, state: ButtonState, button: MouseButton, }, TouchpadPressure { window: WindowId, device: DeviceId, pressure: f32, stage: i64, }, AxisMotion { window: WindowId, device: DeviceId, axis: AxisId, value: f64, }, Touch { window: WindowId, device: DeviceId, touches: Vec<TouchUpdate>, }, ScaleFactorChanged { monitor: MonitorId, windows: Vec<WindowId>, scale_factor: f32, }, MonitorsChanged(Vec<(MonitorId, MonitorInfo)>), WindowCloseRequested(WindowId), WindowClosed(WindowId), ImageMetadataLoaded { image: ImageId, size: PxSize, ppi: Option<ImagePpi>, is_mask: bool, }, ImageLoaded(ImageLoadedData), ImagePartiallyLoaded { image: ImageId, partial_size: PxSize, ppi: Option<ImagePpi>, is_opaque: bool, is_mask: bool, partial_pixels: IpcBytes, }, ImageLoadError { image: ImageId, error: Txt, }, ImageEncoded { image: ImageId, format: Txt, data: IpcBytes, }, ImageEncodeError { image: ImageId, format: Txt, error: Txt, }, FrameImageReady { window: WindowId, frame: FrameId, image: ImageId, selection: PxRect, }, FontsChanged, FontAaChanged(FontAntiAliasing), MultiClickConfigChanged(MultiClickConfig), AnimationsConfigChanged(AnimationsConfig), KeyRepeatConfigChanged(KeyRepeatConfig), TouchConfigChanged(TouchConfig), LocaleChanged(LocaleConfig), ColorsConfigChanged(ColorsConfig), ChromeConfigChanged(ChromeConfig), DeviceAdded(DeviceId), DeviceRemoved(DeviceId), DeviceMouseMotion { device: DeviceId, delta: Vector2D<f64, ()>, }, DeviceMouseWheel { device: DeviceId, delta: MouseScrollDelta, }, DeviceMotion { device: DeviceId, axis: AxisId, value: f64, }, DeviceButton { device: DeviceId, button: ButtonId, state: ButtonState, }, DeviceKey { device: DeviceId, key_code: KeyCode, state: KeyState, }, MsgDialogResponse(DialogId, MsgDialogResponse), FileDialogResponse(DialogId, FileDialogResponse), AccessInit { window: WindowId, }, AccessCommand { window: WindowId, target: AccessNodeId, command: AccessCmd, }, AccessDeinit { window: WindowId, }, LowMemory, RecoveredFromComponentPanic { component: Txt, recover: Txt, panic: Txt, }, ExtensionEvent(ApiExtensionId, ApiExtensionPayload),
}
Expand description

System and User events sent from the View Process.

Variants§

§

Inited(Inited)

View-process inited.

§

Suspended

View-process suspended.

§

Disconnected(ViewProcessGen)

The event channel disconnected, probably because the view-process crashed.

The ViewProcessGen is the generation of the view-process that was lost, it must be passed to Controller::handle_disconnect.

§

WindowOpened(WindowId, WindowOpenData)

Window, context and renderer have finished initializing and is ready to receive commands.

§

HeadlessOpened(WindowId, HeadlessOpenData)

Headless context and renderer have finished initializing and is ready to receive commands.

§

WindowOrHeadlessOpenError

Window open or headless context open request failed.

Fields

§id: WindowId

Id from the request.

§error: Txt

Error message.

§

FrameRendered(EventFrameRendered)

A frame finished rendering.

EventsCleared is not send after this event.

§

WindowChanged(WindowChanged)

Window moved, resized, or minimized/maximized etc.

This event aggregates events moves, resizes and other state changes into a single event to simplify tracking composite changes, for example, the window changes size and position when maximized, this can be trivially observed with this event.

The EventCause can be used to identify a state change initiated by the app.

§

DragHovered

A drag&drop gesture started dragging over the window.

Fields

§window: WindowId

Window that is hovered.

§data: Vec<DragDropData>

Data payload.

§allowed: DragDropEffect

Allowed effects.

§

DragMoved

A drag&drop gesture moved over the window.

Fields

§window: WindowId

Window that is hovered.

§coalesced_pos: Vec<DipPoint>

Cursor positions in between the previous event and this one.

§position: DipPoint

Cursor position, relative to the window top-left in device independent pixels.

§

DragDropped

A drag&drop gesture finished over the window.

Fields

§window: WindowId

Window that received the file drop.

§data: Vec<DragDropData>

Data payload.

§allowed: DragDropEffect

Allowed effects.

§drop_id: DragDropId

ID of this drop operation.

Handlers must call drag_dropped with this ID and what effect was applied to the data.

§

DragCancelled

A drag&drop gesture stopped hovering the window without dropping.

Fields

§window: WindowId

Window that was previous hovered.

§

AppDragEnded

A drag started by the app was dropped or canceled.

Fields

§window: WindowId

Window that started the drag.

§drag: DragDropId

Drag ID.

§applied: DragDropEffect

Effect applied to the data by the drop target.

Is a single flag if the data was dropped in a valid drop target, or is empty if was canceled.

§

FocusChanged

App window(s) focus changed.

Fields

§prev: Option<WindowId>

Window that lost focus.

§new: Option<WindowId>

Window that got focus.

§

KeyboardInput

An event from the keyboard has been received.

This event is only send if the window is focused, all pressed keys should be considered released after FocusChanged to None. Modifier keys receive special treatment, after they are pressed, the modifier key state is monitored directly so that the Released event is always send, unless the focus changed to none.

Fields

§window: WindowId

Window that received the key event.

§device: DeviceId

Device that generated the key event.

§key_code: KeyCode

Physical key.

§state: KeyState

If the key was pressed or released.

§key_location: KeyLocation

The location of the key on the keyboard.

§key: Key

Semantic key unmodified.

Pressing Shift+A key will produce Key::Char('a') in QWERTY keyboards, the modifiers are not applied. Note that the numpad keys do not represents the numbers unmodified

§key_modified: Key

Semantic key modified by the current active modifiers.

Pressing Shift+A key will produce Key::Char('A') in QWERTY keyboards, the modifiers are applied.

§text: Txt

Text typed.

This is only set during KeyState::Pressed of a key that generates text.

This is usually the key_modified char, but is also '\r' for Key::Enter. On Windows when a dead key was pressed earlier but cannot be combined with the character from this key press, the produced text will consist of two characters: the dead-key-character followed by the character resulting from this key press.

§

Ime

IME composition event.

Fields

§window: WindowId

Window that received the IME event.

§ime: Ime

IME event.

§

MouseMoved

The mouse cursor has moved on the window.

This event can be coalesced, i.e. multiple cursor moves packed into the same event.

Fields

§window: WindowId

Window that received the cursor move.

§device: DeviceId

Device that generated the cursor move.

§coalesced_pos: Vec<DipPoint>

Cursor positions in between the previous event and this one.

§position: DipPoint

Cursor position, relative to the window top-left in device independent pixels.

§

MouseEntered

The mouse cursor has entered the window.

Fields

§window: WindowId

Window that now is hovered by the cursor.

§device: DeviceId

Device that generated the cursor move event.

§

MouseLeft

The mouse cursor has left the window.

Fields

§window: WindowId

Window that is no longer hovered by the cursor.

§device: DeviceId

Device that generated the cursor move event.

§

MouseWheel

A mouse wheel movement or touchpad scroll occurred.

Fields

§window: WindowId

Window that was hovered by the cursor when the mouse wheel was used.

§device: DeviceId

Device that generated the mouse wheel event.

§delta: MouseScrollDelta

Delta of change in the mouse scroll wheel state.

§phase: TouchPhase

Touch state if the device that generated the event is a touchpad.

§

MouseInput

An mouse button press has been received.

Fields

§window: WindowId

Window that was hovered by the cursor when the mouse button was used.

§device: DeviceId

Mouse device that generated the event.

§state: ButtonState

If the button was pressed or released.

§button: MouseButton

The mouse button.

§

TouchpadPressure

Touchpad pressure event.

Fields

§window: WindowId

Window that was hovered when the touchpad was touched.

§device: DeviceId

Touchpad device.

§pressure: f32

Pressure level between 0 and 1.

§stage: i64

Click level.

§

AxisMotion

Motion on some analog axis. May report data redundant to other, more specific events.

Fields

§window: WindowId

Window that was focused when the motion was realized.

§device: DeviceId

Analog device.

§axis: AxisId

Axis.

§value: f64

Motion value.

§

Touch

Touch event has been received.

Fields

§window: WindowId

Window that was touched.

§device: DeviceId

Touch device.

§touches: Vec<TouchUpdate>

Coalesced touch updates, never empty.

§

ScaleFactorChanged

The monitor’s scale factor has changed.

Fields

§monitor: MonitorId

Monitor that has changed.

§windows: Vec<WindowId>

Windows affected by this change.

Note that a window’s scale factor can also change if it is moved to another monitor, the Event::WindowChanged event notifies this using the WindowChanged::monitor.

§scale_factor: f32

The new scale factor.

§

MonitorsChanged(Vec<(MonitorId, MonitorInfo)>)

The available monitors have changed.

§

WindowCloseRequested(WindowId)

The window has been requested to close.

§

WindowClosed(WindowId)

The window has closed.

§

ImageMetadataLoaded

An image resource already decoded size and PPI.

Fields

§image: ImageId

The image that started loading.

§size: PxSize

The image pixel size.

§ppi: Option<ImagePpi>

The image pixels-per-inch metadata.

§is_mask: bool

The image is a single channel R8.

§

ImageLoaded(ImageLoadedData)

An image resource finished decoding.

§

ImagePartiallyLoaded

An image resource, progressively decoded has decoded more bytes.

Fields

§image: ImageId

The image that has decoded more pixels.

§partial_size: PxSize

The size of the decoded pixels, can be different then the image size if the image is not interlaced.

§ppi: Option<ImagePpi>

The image pixels-per-inch metadata.

§is_opaque: bool

If the decoded pixels so-far are all opaque (255 alpha).

§is_mask: bool

If the decoded pixels so-far are a single channel.

§partial_pixels: IpcBytes

Updated BGRA8 pre-multiplied pixel buffer or R8 if is_mask. This includes all the pixels decoded so-far.

§

ImageLoadError

An image resource failed to decode, the image ID is not valid.

Fields

§image: ImageId

The image that failed to decode.

§error: Txt

The error message.

§

ImageEncoded

An image finished encoding.

Fields

§image: ImageId

The image that finished encoding.

§format: Txt

The format of the encoded data.

§data: IpcBytes

The encoded image data.

§

ImageEncodeError

An image failed to encode.

Fields

§image: ImageId

The image that failed to encode.

§format: Txt

The encoded format that was requested.

§error: Txt

The error message.

§

FrameImageReady

An image generated from a rendered frame is ready.

Fields

§window: WindowId

Window that had pixels copied.

§frame: FrameId

The frame that was rendered when the pixels where copied.

§image: ImageId

The frame image.

§selection: PxRect

The pixel selection relative to the top-left.

§

FontsChanged

System fonts have changed.

§

FontAaChanged(FontAntiAliasing)

System text anti-aliasing configuration has changed.

§

MultiClickConfigChanged(MultiClickConfig)

System double-click definition changed.

§

AnimationsConfigChanged(AnimationsConfig)

System animations config changed.

§

KeyRepeatConfigChanged(KeyRepeatConfig)

System definition of pressed key repeat event changed.

§

TouchConfigChanged(TouchConfig)

System touch config changed.

§

LocaleChanged(LocaleConfig)

System locale changed.

§

ColorsConfigChanged(ColorsConfig)

System color scheme or colors changed.

§

ChromeConfigChanged(ChromeConfig)

System window chrome (decorations) preference changed.

§

DeviceAdded(DeviceId)

Device added or installed.

§

DeviceRemoved(DeviceId)

Device removed.

§

DeviceMouseMotion

Mouse pointer motion.

The values if the delta of movement (x, y), not position.

Fields

§device: DeviceId

Device that generated the event.

§delta: Vector2D<f64, ()>

Delta of change in the cursor position.

§

DeviceMouseWheel

Mouse scroll wheel turn.

Fields

§device: DeviceId

Mouse device that generated the event.

§delta: MouseScrollDelta

Delta of change in the mouse scroll wheel state.

§

DeviceMotion

Motion on some analog axis.

This includes the mouse device and any other that fits.

Fields

§device: DeviceId

Device that generated the event.

§axis: AxisId

Device dependent axis of the motion.

§value: f64

Device dependent value.

§

DeviceButton

Device button press or release.

Fields

§device: DeviceId

Device that generated the event.

§button: ButtonId

Device dependent button that was used.

§state: ButtonState

If the button was pressed or released.

§

DeviceKey

Device key press or release.

Fields

§device: DeviceId

Device that generated the key event.

§key_code: KeyCode

Physical key.

§state: KeyState

If the key was pressed or released.

§

MsgDialogResponse(DialogId, MsgDialogResponse)

User responded to a native message dialog.

§

FileDialogResponse(DialogId, FileDialogResponse)

User responded to a native file dialog.

§

AccessInit

Accessibility info tree is now required for the window.

Fields

§window: WindowId

Window that must now build access info.

§

AccessCommand

Accessibility command.

Fields

§window: WindowId

Window that had pixels copied.

§target: AccessNodeId

Target widget.

§command: AccessCmd

Command.

§

AccessDeinit

Accessibility info tree is no longer needed for the window.

Note that accessibility may be enabled again after this. It is not an error to send access updates after this, but they will be ignored.

Fields

§window: WindowId

Window that can release access info.

§

LowMemory

System low memory warning, some platforms may kill the app if it does not release memory.

§

RecoveredFromComponentPanic

An internal component panicked, but the view-process managed to recover from it without needing to respawn.

Fields

§component: Txt

Component identifier.

§recover: Txt

How the view-process recovered from the panic.

§panic: Txt

The panic.

§

ExtensionEvent(ApiExtensionId, ApiExtensionPayload)

Represents a custom event send by the extension.

Implementations§

source§

impl Event

source

pub fn coalesce(&mut self, other: Event) -> Result<(), Event>

Change self to incorporate other or returns other if both events cannot be coalesced.

Trait Implementations§

source§

impl Clone for Event

source§

fn clone(&self) -> Event

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Event

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Event

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Event

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,