pub struct Window { /* private fields */ }Expand description
Holds the state for a specific window.
Implementations§
Source§impl Window
impl Window
Sourcepub fn visibility(&self) -> WindowVisibility
pub fn visibility(&self) -> WindowVisibility
Whether the platform is presenting this window’s frames (see
WindowVisibility).
Sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Whether frames drawn for this window will be shown.
This is not the window’s shown/hidden state: a shown window that is fully behind another window, minimized, or on a sleeping display is not visible here.
Sourcepub fn observe_window_visibility(
&self,
callback: impl FnMut(WindowVisibility, &mut Window, &mut App) + 'static,
) -> Subscription
pub fn observe_window_visibility( &self, callback: impl FnMut(WindowVisibility, &mut Window, &mut App) + 'static, ) -> Subscription
Registers a callback to be invoked when the window’s visibility changes.
Sourcepub fn observe_window_activation(
&self,
callback: impl FnMut(&mut Window, &mut App) + 'static,
) -> Subscription
pub fn observe_window_activation( &self, callback: impl FnMut(&mut Window, &mut App) + 'static, ) -> Subscription
Registers a callback to be invoked when the window is activated or deactivated, without an entity to update (vue-native fork).
Sourcepub fn observe_window_appearance(
&self,
callback: impl FnMut(&mut Window, &mut App) + 'static,
) -> Subscription
pub fn observe_window_appearance( &self, callback: impl FnMut(&mut Window, &mut App) + 'static, ) -> Subscription
Registers a callback to be invoked when the window appearance changes.
Registers a callback to be invoked when the window button layout changes.
Sourcepub fn replace_root<E>(
&mut self,
cx: &mut App,
build_view: impl FnOnce(&mut Window, &mut Context<'_, E>) -> E,
) -> Entity<E>where
E: 'static + Render,
pub fn replace_root<E>(
&mut self,
cx: &mut App,
build_view: impl FnOnce(&mut Window, &mut Context<'_, E>) -> E,
) -> Entity<E>where
E: 'static + Render,
Replaces the root entity of the window with a new one.
Sourcepub fn root<E>(&self) -> Option<Option<Entity<E>>>where
E: 'static + Render,
pub fn root<E>(&self) -> Option<Option<Entity<E>>>where
E: 'static + Render,
Returns the root entity of the window, if it has one.
Sourcepub fn window_handle(&self) -> AnyWindowHandle
pub fn window_handle(&self) -> AnyWindowHandle
Obtain a handle to the window that belongs to this context.
Sourcepub fn refresh(&mut self)
pub fn refresh(&mut self)
Mark the window as dirty, scheduling it to be redrawn on the next frame.
Sourcepub fn remove_window(&mut self)
pub fn remove_window(&mut self)
Close this window.
Sourcepub fn focused(&self, cx: &App) -> Option<FocusHandle>
pub fn focused(&self, cx: &App) -> Option<FocusHandle>
Obtain the currently focused FocusHandle. If no elements are focused, returns None.
Sourcepub fn focus_lost_restore_target(&self, cx: &App) -> Option<FocusHandle>
pub fn focus_lost_restore_target(&self, cx: &App) -> Option<FocusHandle>
While focus-lost listeners are being dispatched, returns the closest ancestor of the
previously focused element that can still receive focus, making it a suitable target
for focus restoration. Returns None at all other times, or when no such ancestor exists.
Sourcepub fn focus(&mut self, handle: &FocusHandle, cx: &mut App)
pub fn focus(&mut self, handle: &FocusHandle, cx: &mut App)
Move focus to the element associated with the given FocusHandle.
Sourcepub fn blur(&mut self, cx: &mut App)
pub fn blur(&mut self, cx: &mut App)
Remove focus from all elements within this context’s window.
Sourcepub fn disable_focus(&mut self, cx: &mut App)
pub fn disable_focus(&mut self, cx: &mut App)
Blur the window and don’t allow anything in it to be focused again.
Sourcepub fn focus_next(&mut self, cx: &mut App)
pub fn focus_next(&mut self, cx: &mut App)
Move focus to next tab stop.
Sourcepub fn focus_prev(&mut self, cx: &mut App)
pub fn focus_prev(&mut self, cx: &mut App)
Move focus to previous tab stop.
Sourcepub fn text_system(&self) -> &Rc<WindowTextSystem>
pub fn text_system(&self) -> &Rc<WindowTextSystem>
Accessor for the text system.
Sourcepub fn text_style(&self) -> TextStyle
pub fn text_style(&self) -> TextStyle
The current text style. Which is composed of all the style refinements provided to with_text_style.
Sourcepub fn is_maximized(&self) -> bool
pub fn is_maximized(&self) -> bool
Check if the platform window is maximized.
On some platforms (namely Windows) this is different than the bounds being the size of the display
Sourcepub fn request_decorations(&self, decorations: WindowDecorations)
pub fn request_decorations(&self, decorations: WindowDecorations)
request a certain window decoration (Wayland)
Sourcepub fn set_exclusive_zone(&self, zone: Pixels)
pub fn set_exclusive_zone(&self, zone: Pixels)
Set the exclusive zone for a layer-shell surface: how much screen space it reserves so other surfaces avoid occluding it (e.g. a panel reserving space). Positive values reserve that distance from the anchored edge, 0 lets the surface be moved out of others’ exclusive zones, and -1 ignores reserved space and may extend under other surfaces. (Wayland layer-shell windows only)
Sourcepub fn set_exclusive_edge(&self, edge: Anchor)
pub fn set_exclusive_edge(&self, edge: Anchor)
Set which anchored edge a layer-shell surface’s exclusive zone applies to. This is only needed to disambiguate a corner-anchored surface; otherwise the edge is deduced from the anchor. The edge must be a single edge the surface is anchored to, or it is ignored. (Wayland layer-shell windows only)
Sourcepub fn start_window_resize(&self, edge: ResizeEdge)
pub fn start_window_resize(&self, edge: ResizeEdge)
Start an interactive window resize operation if this window is resizable.
Sourcepub fn set_input_region(&self, region: Option<&[Bounds<Pixels>]>)
pub fn set_input_region(&self, region: Option<&[Bounds<Pixels>]>)
Linux (wayland) only: Set the window’s input region, the area that receives pointer and touch input. Events outside it pass through to whatever is below the window.
Some(rects)restricts input to the union ofrects, in window coordinates.Some(&[])is an empty region, so the window receives no pointer or touch input.Noneresets the region to the default, so the whole window receives input again.
Sourcepub fn window_bounds(&self) -> WindowBounds
pub fn window_bounds(&self) -> WindowBounds
Return the WindowBounds to indicate that how a window should be opened
after it has been closed
Sourcepub fn inner_window_bounds(&self) -> WindowBounds
pub fn inner_window_bounds(&self) -> WindowBounds
Return the WindowBounds excluding insets (Wayland and X11)
Sourcepub fn vn_composition_underlay(&self) -> Option<(usize, usize)>
pub fn vn_composition_underlay(&self) -> Option<(usize, usize)>
vue-native: Windows’ composition device and the container visual drawn
UNDER this window’s surface (see PlatformWindow::vn_composition_underlay):
owned COM pointers, released by the caller.
Sourcepub fn vn_set_maximized(&self, maximized: bool)
pub fn vn_set_maximized(&self, maximized: bool)
vue-native: maximizes or leaves the maximized state without toggling.
Sourcepub fn vn_is_zoomed(&self) -> bool
pub fn vn_is_zoomed(&self) -> bool
vue-native: the platform’s own maximized (zoomed) state.
Sourcepub fn vn_is_minimized(&self) -> bool
pub fn vn_is_minimized(&self) -> bool
vue-native: minimized, where the platform reports it.
Sourcepub fn vn_unminimize(&self)
pub fn vn_unminimize(&self)
vue-native: leaves the minimized state.
Sourcepub fn vn_hide(&self) -> bool
pub fn vn_hide(&self) -> bool
vue-native: hides the window without minimizing it; false where unsupported.
Sourcepub fn vn_is_shown(&self) -> bool
pub fn vn_is_shown(&self) -> bool
vue-native: false while hidden by Self::vn_hide or not yet shown.
Sourcepub fn vn_set_frame(
&self,
origin: Option<Point<Pixels>>,
size: Option<Size<Pixels>>,
) -> bool
pub fn vn_set_frame( &self, origin: Option<Point<Pixels>>, size: Option<Size<Pixels>>, ) -> bool
vue-native: moves and/or resizes the outer frame, in the space of Self::bounds;
false when the platform refuses part of it.
Sourcepub fn vn_set_always_on_top(&self, on: bool) -> bool
pub fn vn_set_always_on_top(&self, on: bool) -> bool
vue-native: keeps the window above normal windows; false where unsupported.
Sourcepub fn vn_set_maximizable(&self, maximizable: bool)
pub fn vn_set_maximizable(&self, maximizable: bool)
vue-native: whether the platform’s own maximize control is enabled.
Sourcepub fn vn_set_ignore_mouse(&self, ignore: bool) -> bool
pub fn vn_set_ignore_mouse(&self, ignore: bool) -> bool
vue-native: lets pointer input pass through; false where unsupported.
Sourcepub fn vn_set_content_protection(&self, on: bool) -> bool
pub fn vn_set_content_protection(&self, on: bool) -> bool
vue-native: keeps the contents out of screen capture; false where unsupported.
Sourcepub fn vn_request_close(&self)
pub fn vn_request_close(&self)
vue-native: closes as the platform’s close button would; the should-close callback decides.
Sourcepub fn native_window_state(&self) -> Option<Vec<u8>>
pub fn native_window_state(&self) -> Option<Vec<u8>>
Encode the window’s native restorable state into an opaque blob.
Returns None on platforms without native state restoration or if encoding fails.
Sourcepub fn restore_native_window_state(&self, state: &[u8])
pub fn restore_native_window_state(&self, state: &[u8])
Restore the window’s native state from a blob previously produced
by Window::native_window_state. A no-op on platforms without native state restoration.
Sourcepub fn dispatch_action(&mut self, action: Box<dyn Action>, cx: &mut App)
pub fn dispatch_action(&mut self, action: Box<dyn Action>, cx: &mut App)
Dispatch the given action on the currently focused element.
Sourcepub fn defer(
&self,
cx: &mut App,
f: impl FnOnce(&mut Window, &mut App) + 'static,
)
pub fn defer( &self, cx: &mut App, f: impl FnOnce(&mut Window, &mut App) + 'static, )
Schedules the given function to be run at the end of the current effect cycle, allowing entities that are currently on the stack to be returned to the app.
Sourcepub fn observe<T: 'static>(
&mut self,
observed: &Entity<T>,
cx: &mut App,
on_notify: impl FnMut(Entity<T>, &mut Window, &mut App) + 'static,
) -> Subscription
pub fn observe<T: 'static>( &mut self, observed: &Entity<T>, cx: &mut App, on_notify: impl FnMut(Entity<T>, &mut Window, &mut App) + 'static, ) -> Subscription
Subscribe to events emitted by a entity.
The entity to which you’re subscribing must implement the EventEmitter trait.
The callback will be invoked a handle to the emitting entity, the event, and a window context for the current window.
Sourcepub fn subscribe<Emitter, Evt>(
&mut self,
entity: &Entity<Emitter>,
cx: &mut App,
on_event: impl FnMut(Entity<Emitter>, &Evt, &mut Window, &mut App) + 'static,
) -> Subscriptionwhere
Emitter: EventEmitter<Evt>,
Evt: 'static,
pub fn subscribe<Emitter, Evt>(
&mut self,
entity: &Entity<Emitter>,
cx: &mut App,
on_event: impl FnMut(Entity<Emitter>, &Evt, &mut Window, &mut App) + 'static,
) -> Subscriptionwhere
Emitter: EventEmitter<Evt>,
Evt: 'static,
Subscribe to events emitted by a entity.
The entity to which you’re subscribing must implement the EventEmitter trait.
The callback will be invoked a handle to the emitting entity, the event, and a window context for the current window.
Sourcepub fn observe_release<T>(
&self,
entity: &Entity<T>,
cx: &mut App,
on_release: impl FnOnce(&mut T, &mut Window, &mut App) + 'static,
) -> Subscriptionwhere
T: 'static,
pub fn observe_release<T>(
&self,
entity: &Entity<T>,
cx: &mut App,
on_release: impl FnOnce(&mut T, &mut Window, &mut App) + 'static,
) -> Subscriptionwhere
T: 'static,
Register a callback to be invoked when the given Entity is released.
Sourcepub fn to_async(&self, cx: &App) -> AsyncWindowContext
pub fn to_async(&self, cx: &App) -> AsyncWindowContext
Creates an AsyncWindowContext, which has a static lifetime and can be held across
await points in async code.
Sourcepub fn on_next_frame(
&self,
callback: impl FnOnce(&mut Window, &mut App) + 'static,
)
pub fn on_next_frame( &self, callback: impl FnOnce(&mut Window, &mut App) + 'static, )
Schedule the given closure to be run directly after the current frame is rendered.
Sourcepub fn on_next_frame_passive(
&self,
callback: impl FnOnce(&mut Window, &mut App) + 'static,
)
pub fn on_next_frame_passive( &self, callback: impl FnOnce(&mut Window, &mut App) + 'static, )
vue-native fork: like Self::on_next_frame, but rides along with the
next frame the platform delivers without asking for one. A frame source
that paces idle windows can then let a self-rescheduling pump wait for
real demand (input, an invalidation, an on_next_frame) or its own
deadline; one that delivers every refresh runs it on the next.
Sourcepub fn request_animation_frame(&self)
pub fn request_animation_frame(&self)
Schedule a frame to be drawn on the next animation frame.
This is useful for elements that need to animate continuously, such as a video player or an animated GIF. It will cause the window to redraw on the next frame, even if no other changes have occurred.
If called from within a view, it will notify that view on the next frame. Otherwise, it will refresh the entire window.
Callers driving purely decorative animations (spinners, pulses, and the
like) should prefer AnimationExt::with_animation,
which automatically respects App::reduce_motion. When using this
method directly for decorative motion, check App::reduce_motion
and skip the frame request when it is set.
Sourcepub fn spawn<AsyncFn, R>(&self, cx: &App, f: AsyncFn) -> Task<R> ⓘwhere
R: 'static,
AsyncFn: AsyncFnOnce(&mut AsyncWindowContext) -> R + 'static,
pub fn spawn<AsyncFn, R>(&self, cx: &App, f: AsyncFn) -> Task<R> ⓘwhere
R: 'static,
AsyncFn: AsyncFnOnce(&mut AsyncWindowContext) -> R + 'static,
Spawn the future returned by the given closure on the application thread pool.
The closure is provided a handle to the current window and an AsyncWindowContext for
use within your future.
Sourcepub fn spawn_with_priority<AsyncFn, R>(
&self,
priority: Priority,
cx: &App,
f: AsyncFn,
) -> Task<R> ⓘwhere
R: 'static,
AsyncFn: AsyncFnOnce(&mut AsyncWindowContext) -> R + 'static,
pub fn spawn_with_priority<AsyncFn, R>(
&self,
priority: Priority,
cx: &App,
f: AsyncFn,
) -> Task<R> ⓘwhere
R: 'static,
AsyncFn: AsyncFnOnce(&mut AsyncWindowContext) -> R + 'static,
Spawn the future returned by the given closure on the application thread
pool, with the given priority. The closure is provided a handle to the
current window and an AsyncWindowContext for use within your future.
Sourcepub fn bounds_changed(&mut self, cx: &mut App)
pub fn bounds_changed(&mut self, cx: &mut App)
Notify the window that its bounds have changed.
This updates internal state like viewport_size and scale_factor from
the platform window, then notifies observers. Normally called automatically
by the platform’s resize callback, but exposed publicly for test infrastructure.
Sourcepub fn refresh_interval(&self, cx: &App) -> Option<Duration>
pub fn refresh_interval(&self, cx: &App) -> Option<Duration>
The time between refreshes of the display the window is on, as of the
platform’s last display change notification. Variable refresh rate
displays report their maximum rate. Returns None when the platform
doesn’t report it.
Sourcepub fn observe_window_display(
&self,
callback: impl FnMut(&mut Window, &mut App) + 'static,
) -> Subscription
pub fn observe_window_display( &self, callback: impl FnMut(&mut Window, &mut App) + 'static, ) -> Subscription
Registers a callback invoked when the window moves to another display
or its display’s properties change, for example its refresh
interval. Self::refresh_interval already returns the new value
when the callback runs.
Sourcepub fn bounds(&self) -> Bounds<Pixels>
pub fn bounds(&self) -> Bounds<Pixels>
Returns the bounds of the current window in the global coordinate space, which could span across multiple displays.
Sourcepub fn insets(&self) -> WindowInsets
pub fn insets(&self) -> WindowInsets
Returns the regions of this window obscured by system UI and the keyboard.
Sourcepub fn render_to_image(&self) -> Result<RgbaImage>
pub fn render_to_image(&self) -> Result<RgbaImage>
Renders the current frame’s scene to a texture and returns the pixel data as an RGBA image. This does not present the frame to screen - useful for visual testing where we want to capture what would be rendered without displaying it or requiring the window to be visible.
Sourcepub fn is_fullscreen(&self) -> bool
pub fn is_fullscreen(&self) -> bool
Returns whether or not the window is currently fullscreen
Sourcepub fn is_simple_fullscreen(&self) -> bool
pub fn is_simple_fullscreen(&self) -> bool
Returns whether the window is currently in simple (borderless) fullscreen,
where it covers the entire screen including the menu bar and notch area.
Always false on platforms other than macOS.
Sourcepub fn appearance(&self) -> WindowAppearance
pub fn appearance(&self) -> WindowAppearance
Returns the appearance of the current window.
Sourcepub fn viewport_size(&self) -> Size<Pixels>
pub fn viewport_size(&self) -> Size<Pixels>
Returns the size of the drawable area within the window.
Sourcepub fn visual_viewport_bounds(&self) -> Bounds<Pixels>
pub fn visual_viewport_bounds(&self) -> Bounds<Pixels>
Returns the platform’s visible viewport in window-local logical pixels.
Unlike viewport_size, this can shrink or move when the keyboard opens.
During drawing this is a consistent frame snapshot. Outside drawing it
reflects the latest platform sample, not a synchronous geometry query.
Sourcepub fn fully_visible_bounds(&self) -> Bounds<Pixels>
pub fn fully_visible_bounds(&self) -> Bounds<Pixels>
Returns a conservative rectangle avoiding platform-known obscured content.
Intersects the visual viewport with the full layout area inset by system safe areas and keyboard occlusion. Unknown overlays cannot be excluded.
Sourcepub fn request_virtual_keyboard(&self)
pub fn request_virtual_keyboard(&self)
Requests the virtual keyboard for the currently focused text input.
Call from a user gesture on platforms that require one. The platform may decline the request; this does not change focus or the layout viewport.
Sourcepub fn dismiss_virtual_keyboard(&self)
pub fn dismiss_virtual_keyboard(&self)
Requests dismissal of the virtual keyboard without changing GPUI focus.
Sourcepub fn is_window_active(&self) -> bool
pub fn is_window_active(&self) -> bool
Returns whether this window is focused by the operating system (receiving key events).
Sourcepub fn set_assume_active(&mut self, on: bool)
pub fn set_assume_active(&mut self, on: bool)
vue-native fork: while on, gpui treats this window as active whatever
the operating system says. That covers Window::is_window_active,
the focus paths a frame’s focus events carry (with no OS activation
they are empty, so on_focus never fires), and the inactive-window
frame throttle. The platform’s activation changes are ignored while it
is set.
Nothing at the OS level changes: the window is not raised, activated or given keyboard focus. vue-native’s test hosts open their windows behind everything and never take the foreground, yet must run focus exactly as a window in front does. Turning it off goes back to what the platform reports.
Sourcepub fn is_window_hovered(&self) -> bool
pub fn is_window_hovered(&self) -> bool
Returns whether this window is considered to be the window
that currently owns the mouse cursor.
On mac, this is equivalent to is_window_active.
Sourcepub fn zoom_window(&self)
pub fn zoom_window(&self)
Toggle zoom on the window.
Opens the native title bar context menu, useful when implementing client side decorations (Wayland and X11)
Sourcepub fn start_window_move(&self)
pub fn start_window_move(&self)
Handle window movement for Linux and macOS. Tells the compositor to take control of window movement (Wayland and X11)
Events may not be received during a move operation.
Sourcepub fn set_client_inset(&mut self, inset: Pixels)
pub fn set_client_inset(&mut self, inset: Pixels)
When using client side decorations, set this to the width of the invisible decorations (Wayland and X11)
Sourcepub fn set_client_corner_radii(&mut self, radii: Corners<Pixels>)
pub fn set_client_corner_radii(&mut self, radii: Corners<Pixels>)
Sets the client-drawn corner radii so platform effects can match the window’s shape.
Sourcepub fn client_inset(&self) -> Option<Pixels>
pub fn client_inset(&self) -> Option<Pixels>
Returns the client_inset value by Self::set_client_inset.
Sourcepub fn window_decorations(&self) -> Decorations
pub fn window_decorations(&self) -> Decorations
Returns whether the title bar window controls need to be rendered by the application (Wayland and X11)
Sourcepub fn is_resizable(&self) -> bool
pub fn is_resizable(&self) -> bool
Returns whether this window is resizable.
Sourcepub fn is_minimizable(&self) -> bool
pub fn is_minimizable(&self) -> bool
Returns whether this window is minimizable.
Sourcepub fn window_controls(&self) -> WindowControls
pub fn window_controls(&self) -> WindowControls
Returns the controls supported by the platform.
Sourcepub fn set_window_title(&mut self, title: &str)
pub fn set_window_title(&mut self, title: &str)
Updates the window’s title at the platform level.
Sourcepub fn set_app_id(&mut self, app_id: &str)
pub fn set_app_id(&mut self, app_id: &str)
Sets the application identifier.
Sourcepub fn set_background_appearance(
&self,
background_appearance: WindowBackgroundAppearance,
)
pub fn set_background_appearance( &self, background_appearance: WindowBackgroundAppearance, )
Sets the window background appearance.
Sourcepub fn is_background_appearance_drawn(&self) -> bool
pub fn is_background_appearance_drawn(&self) -> bool
Whether the window currently draws the appearance last given to
Self::set_background_appearance. false only while the platform
stands in for it — a blurred macOS window in native fullscreen whose
desktop picture could not be shown behind the blur — so an app can
paint a background of its own exactly then.
Sourcepub fn set_window_edited(&mut self, edited: bool)
pub fn set_window_edited(&mut self, edited: bool)
Mark the window as dirty at the platform level.
Sourcepub fn set_document_path(&self, path: Option<&Path>)
pub fn set_document_path(&self, path: Option<&Path>)
Set the path of the file this window represents. On macOS, this sets the window’s accessibility document property (AXDocument).
Sourcepub fn display(&self, cx: &App) -> Option<Rc<dyn PlatformDisplay>>
pub fn display(&self, cx: &App) -> Option<Rc<dyn PlatformDisplay>>
Determine the display on which the window is visible.
Sourcepub fn show_character_palette(&self)
pub fn show_character_palette(&self)
Show the platform character palette.
Sourcepub fn scale_factor(&self) -> f32
pub fn scale_factor(&self) -> f32
The scale factor of the display associated with the window. For example, it could return 2.0 for a “retina” display, indicating that each logical pixel should actually be rendered as two pixels on screen.
Sourcepub fn rem_size(&self) -> Pixels
pub fn rem_size(&self) -> Pixels
The size of an em for the base font of the application. Adjusting this value allows the UI to scale, just like zooming a web page.
Sourcepub fn set_rem_size(&mut self, rem_size: impl Into<Pixels>)
pub fn set_rem_size(&mut self, rem_size: impl Into<Pixels>)
Sets the size of an em for the base font of the application. Adjusting this value allows the UI to scale, just like zooming a web page.
Sourcepub fn with_global_id<R>(
&mut self,
element_id: ElementId,
f: impl FnOnce(&GlobalElementId, &mut Self) -> R,
) -> R
pub fn with_global_id<R>( &mut self, element_id: ElementId, f: impl FnOnce(&GlobalElementId, &mut Self) -> R, ) -> R
Acquire a globally unique identifier for the given ElementId. Only valid for the duration of the provided closure.
Sourcepub fn with_id<R>(
&mut self,
element_id: impl Into<ElementId>,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_id<R>( &mut self, element_id: impl Into<ElementId>, f: impl FnOnce(&mut Self) -> R, ) -> R
Calls the provided closure with the element ID pushed on the stack.
Sourcepub fn with_rem_size<F, R>(
&mut self,
rem_size: Option<impl Into<Pixels>>,
f: F,
) -> Rwhere
F: FnOnce(&mut Self) -> R,
pub fn with_rem_size<F, R>(
&mut self,
rem_size: Option<impl Into<Pixels>>,
f: F,
) -> Rwhere
F: FnOnce(&mut Self) -> R,
Executes the provided function with the specified rem size.
This method must only be called as part of element drawing.
Sourcepub fn line_height(&self) -> Pixels
pub fn line_height(&self) -> Pixels
The line height associated with the current text style.
Sourcepub fn pixel_snap(&self, value: Pixels) -> Pixels
pub fn pixel_snap(&self, value: Pixels) -> Pixels
Rounds a logical value to the nearest device pixel.
Sourcepub fn pixel_snap_f64(&self, value: f64) -> f64
pub fn pixel_snap_f64(&self, value: f64) -> f64
f64 variant of Self::pixel_snap.
Sourcepub fn pixel_snap_bounds(&self, bounds: Bounds<Pixels>) -> Bounds<Pixels>
pub fn pixel_snap_bounds(&self, bounds: Bounds<Pixels>) -> Bounds<Pixels>
Snaps a bounds’ origin and size to the nearest device pixel.
Sourcepub fn pixel_snap_point(&self, position: Point<Pixels>) -> Point<Pixels>
pub fn pixel_snap_point(&self, position: Point<Pixels>) -> Point<Pixels>
Snaps a point’s coordinates to the nearest device pixel.
Sourcepub fn underline_bounds(
&self,
origin: Point<Pixels>,
width: Pixels,
style: &UnderlineStyle,
) -> Bounds<ScaledPixels>
pub fn underline_bounds( &self, origin: Point<Pixels>, width: Pixels, style: &UnderlineStyle, ) -> Bounds<ScaledPixels>
Returns the snapped device-space bounds used to paint an underline.
Sourcepub fn paint_underline_with_exclusions(
&mut self,
origin: Point<Pixels>,
width: Pixels,
style: &UnderlineStyle,
exclusions: &[Range<ScaledPixels>],
)
pub fn paint_underline_with_exclusions( &mut self, origin: Point<Pixels>, width: Pixels, style: &UnderlineStyle, exclusions: &[Range<ScaledPixels>], )
Paints an underline excluding absolute device-space horizontal spans.
Sourcepub fn prevent_default(&mut self)
pub fn prevent_default(&mut self)
Call to prevent the default action of an event. Currently only used to prevent parent elements from becoming focused on mouse down.
Sourcepub fn default_prevented(&self) -> bool
pub fn default_prevented(&self) -> bool
Obtain whether default has been prevented for the event currently being dispatched.
Sourcepub fn is_action_available(&self, action: &dyn Action, cx: &App) -> bool
pub fn is_action_available(&self, action: &dyn Action, cx: &App) -> bool
Determine whether the given action is available along the dispatch path to the currently focused element.
Sourcepub fn is_action_available_in(
&self,
action: &dyn Action,
focus_handle: &FocusHandle,
) -> bool
pub fn is_action_available_in( &self, action: &dyn Action, focus_handle: &FocusHandle, ) -> bool
Determine whether the given action is available along the dispatch path to the given focus_handle.
Sourcepub fn mouse_position(&self) -> Point<Pixels>
pub fn mouse_position(&self) -> Point<Pixels>
The position of the mouse relative to the window.
Sourcepub fn capture_pointer(&mut self, hitbox_id: HitboxId)
pub fn capture_pointer(&mut self, hitbox_id: HitboxId)
Captures the pointer for the given hitbox. While captured, all mouse move and mouse up
events will be routed to listeners that check this hitbox’s is_hovered status,
regardless of actual hit testing. This enables drag operations that continue
even when the pointer moves outside the element’s bounds.
The capture is automatically released on mouse up.
Sourcepub fn release_pointer(&mut self)
pub fn release_pointer(&mut self)
Releases any active pointer capture.
Sourcepub fn captured_hitbox(&self) -> Option<HitboxId>
pub fn captured_hitbox(&self) -> Option<HitboxId>
Returns the hitbox that has captured the pointer, if any.
Sourcepub fn capture_long_press<T: 'static>(&mut self, entity: &Entity<T>)
pub fn capture_long_press<T: 'static>(&mut self, entity: &Entity<T>)
Captures the current long press for the given entity.
The capture is released when the gesture ends or is cancelled, or when
a replacement touch begins. A listener must also call
Self::prevent_default on the started event to claim the gesture.
Sourcepub fn has_long_press_capture<T: 'static>(&self, entity: &Entity<T>) -> bool
pub fn has_long_press_capture<T: 'static>(&self, entity: &Entity<T>) -> bool
Returns whether the given entity has captured the current long press.
Sourcepub fn last_input_was_keyboard(&self) -> bool
pub fn last_input_was_keyboard(&self) -> bool
Returns true if the last input event was keyboard-based (key press, tab navigation, etc.) This is used for focus-visible styling to show focus indicators only for keyboard navigation.
Sourcepub fn last_input_was_touch(&self) -> bool
pub fn last_input_was_touch(&self) -> bool
Returns whether the last input event came from a touch screen.
Sourcepub fn draw(&mut self, cx: &mut App) -> ArenaClearNeeded
pub fn draw(&mut self, cx: &mut App) -> ArenaClearNeeded
Produces a new frame and assigns it to rendered_frame. To actually show
the contents of the new Scene, use Self::present.
Sourcepub fn vn_with_defer_scope<R>(
&mut self,
id: u64,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn vn_with_defer_scope<R>( &mut self, id: u64, f: impl FnOnce(&mut Self) -> R, ) -> R
vue-native fork: draws deferred in f belong to the content effect of
element id (0: none), which paints them ([VnDeferScope]).
Sourcepub fn with_text_style<F, R>(
&mut self,
style: Option<TextStyleRefinement>,
f: F,
) -> Rwhere
F: FnOnce(&mut Self) -> R,
pub fn with_text_style<F, R>(
&mut self,
style: Option<TextStyleRefinement>,
f: F,
) -> Rwhere
F: FnOnce(&mut Self) -> R,
Push a text style onto the stack, and call a function with that style active.
Use Window::text_style to get the current, combined text style. This method
should only be called as part of element drawing.
Sourcepub fn set_cursor_style(&mut self, style: CursorStyle, hitbox: &Hitbox)
pub fn set_cursor_style(&mut self, style: CursorStyle, hitbox: &Hitbox)
Updates the cursor style at the platform level. This method should only be called during the paint phase of element drawing.
Sourcepub fn set_window_cursor_style(&mut self, style: CursorStyle)
pub fn set_window_cursor_style(&mut self, style: CursorStyle)
Updates the cursor style for the entire window at the platform level. A cursor
style using this method will have precedence over any cursor style set using
set_cursor_style. This method should only be called during the paint
phase of element drawing.
Sourcepub fn set_tooltip(&mut self, tooltip: AnyTooltip) -> TooltipId
pub fn set_tooltip(&mut self, tooltip: AnyTooltip) -> TooltipId
Sets a tooltip to be rendered for the upcoming frame. This method should only be called during the paint phase of element drawing.
Sourcepub fn with_content_mask<R>(
&mut self,
mask: Option<ContentMask<Pixels>>,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_content_mask<R>( &mut self, mask: Option<ContentMask<Pixels>>, f: impl FnOnce(&mut Self) -> R, ) -> R
Invoke the given function with the given content mask after intersecting it with the current mask. This method should only be called during element drawing.
Sourcepub fn vn_with_clip_shape<R>(
&mut self,
outline: Option<&VnClipOutline>,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn vn_with_clip_shape<R>( &mut self, outline: Option<&VnClipOutline>, f: impl FnOnce(&mut Self) -> R, ) -> R
vue-native fork: runs f under a clip-path that is no rounded
rectangle (crate::Style::vn_clip_outline), laid out in the
element’s own frame. The outline is flattened through the transform in
force into window device pixels and pushed on the clip stack, which
every hitbox inserted in f takes (prepaint). While painting, f’s
primitives also go into an isolated layer that the renderer composites
through the shape (crate::Scene::vn_push_isolation). The caller
pushes the outline’s box as a content mask around this, which culls.
Sourcepub fn vn_with_color_matrix<R>(
&mut self,
matrix: Option<VnColorMatrix>,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn vn_with_color_matrix<R>( &mut self, matrix: Option<VnColorMatrix>, f: impl FnOnce(&mut Self) -> R, ) -> R
Applies an SVG color matrix to the entire painted subtree. The same stack node is retained in prepaint so deferred descendants reopen it.
Sourcepub fn vn_text_paint(
&self,
fill: VnTextFill,
bounds: Bounds<Pixels>,
) -> Arc<VnTextPaint> ⓘ
pub fn vn_text_paint( &self, fill: VnTextFill, bounds: Bounds<Pixels>, ) -> Arc<VnTextPaint> ⓘ
Resolve a text brush once at its owner, before descendant overflow masks.
Sourcepub fn vn_with_text_mask<R>(
&mut self,
paint: Arc<VnTextPaint>,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn vn_with_text_mask<R>( &mut self, paint: Arc<VnTextPaint>, f: impl FnOnce(&mut Self) -> R, ) -> R
Paint only glyph alpha into the owner’s shared mask. Child overflow masks still apply to their sprites without clipping later sibling glyphs.
Sourcepub fn vn_with_mask<R>(
&mut self,
mask: Option<&VnMask>,
bounds: Bounds<Pixels>,
cx: &mut App,
f: impl FnOnce(&mut Self, &mut App) -> R,
) -> R
pub fn vn_with_mask<R>( &mut self, mask: Option<&VnMask>, bounds: Bounds<Pixels>, cx: &mut App, f: impl FnOnce(&mut Self, &mut App) -> R, ) -> R
vue-native fork: CSS mask. While painting, f goes into an isolated
layer cut to the border box bounds, composited multiplied by the alpha
(or luminance) of what the mask paints over bounds. The mask is on the
clip stack meanwhile, in prepaint too, so a deferred descendant paints
through it again (Window::vn_reopen_clip_layers).
Sourcepub fn vn_with_capture<R>(
&mut self,
id: Option<u64>,
bounds: Bounds<Pixels>,
own: TransformationMatrix,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn vn_with_capture<R>( &mut self, id: Option<u64>, bounds: Bounds<Pixels>, own: TransformationMatrix, f: impl FnOnce(&mut Self) -> R, ) -> R
vue-native fork: f paints into the snapshot id rather than the
page: untransformed, unclipped by its ancestors and at full opacity,
in a group the renderer draws first and keeps
(crate::Scene::vn_captures). bounds and own (the element’s
transform) are what the capture reports of the element.
Sourcepub fn vn_with_isolation<R>(
&mut self,
isolate: bool,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn vn_with_isolation<R>( &mut self, isolate: bool, f: impl FnOnce(&mut Self) -> R, ) -> R
vue-native fork: f paints into an isolated group composited
source-over, so what blends inside it blends with the group only.
Sourcepub fn vn_paint_snapshot(
&mut self,
id: u64,
bounds: Bounds<Pixels>,
plus_lighter: bool,
)
pub fn vn_paint_snapshot( &mut self, id: u64, bounds: Bounds<Pixels>, plus_lighter: bool, )
vue-native fork: draws the snapshot id so that the border box it
captured fills bounds, through the transform and opacity in force.
Ink outside the border box scales along. Nothing is drawn for a
snapshot the renderer does not hold.
Sourcepub fn vn_paint_snapshot_in_place(&mut self, id: u64)
pub fn vn_paint_snapshot_in_place(&mut self, id: u64)
vue-native fork: draws the snapshot id where its element was when
captured, through the opacity in force.
Sourcepub fn vn_capture(&self, id: u64) -> Option<VnCaptureInfo>
pub fn vn_capture(&self, id: u64) -> Option<VnCaptureInfo>
vue-native fork: what the last drawn frame knows of capture id:
the element’s border box and transform in device pixels.
Sourcepub fn vn_forget_captures(&mut self, ids: &[u64])
pub fn vn_forget_captures(&mut self, ids: &[u64])
vue-native fork: forgets captures; their snapshots stop drawing and the renderer frees them once no frame paints them.
Sourcepub fn vn_supports_snapshots(&self) -> bool
pub fn vn_supports_snapshots(&self) -> bool
vue-native fork: whether this window’s renderer keeps snapshots
(Window::vn_with_capture).
Sourcepub fn with_element_offset<R>(
&mut self,
offset: Point<Pixels>,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_element_offset<R>( &mut self, offset: Point<Pixels>, f: impl FnOnce(&mut Self) -> R, ) -> R
Updates the global element offset relative to the current offset. This is used to implement scrolling. This method should only be called during the prepaint phase of element drawing.
Sourcepub fn with_absolute_element_offset<R>(
&mut self,
offset: Point<Pixels>,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_absolute_element_offset<R>( &mut self, offset: Point<Pixels>, f: impl FnOnce(&mut Self) -> R, ) -> R
Updates the global element offset based on the given offset. This is used to implement drag handles and other manual painting of elements. This method should only be called during the prepaint phase of element drawing.
Sourcepub fn with_image_tint<R>(
&mut self,
tint: Hsla,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_image_tint<R>( &mut self, tint: Hsla, f: impl FnOnce(&mut Self) -> R, ) -> R
vue-native fork: every image Window::paint_image paints inside f
is tinted with tint: its pixels take the colour by the colour’s alpha,
keeping their own alpha. In straight alpha that is
rgb = mix(rgb, tint.rgb, tint.a), a = a, which is a canvas filling
the image with tint in source-atop. A transparent tint (the value
outside any scope) leaves an image as it is; an opaque one paints the
image’s alpha in that colour, a monochrome emoji in currentColor.
The tile is the same one an untinted paint samples: tinting costs no upload, and two tints of one image share it.
Sourcepub fn with_absolute_element_transform<R>(
&mut self,
transformation: TransformationMatrix,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_absolute_element_transform<R>( &mut self, transformation: TransformationMatrix, f: impl FnOnce(&mut Self) -> R, ) -> R
Paints everything f paints — this element’s own quads, shadows, text
and its whole subtree — through transformation, which is composed on
top of whatever an ancestor already pushed.
This is CSS transform’s propagation rule: a transform applies to the
element’s rendering and to all of its descendants, and to none of the
layout. Nothing here touches taffy, bounds, or the content mask; the
primitives are still emitted in layout coordinates and carry the matrix
for the vertex shader to apply.
Hitboxes inserted under it record the same matrix, so hit-testing
follows the picture (see [Frame::hit_test]).
The identity is free — it early-returns without touching the field.
Installs transformation as THE transform, discarding whatever is on the
stack, for the duration of f.
The deferred-draw replay needs this rather than
Window::with_element_transform: it re-enters a subtree that was
prepainted somewhere else in the tree, so the transform it has to restore
is absolute, not something to compose onto the current one. Same
reasoning as Window::with_absolute_element_offset.
Sourcepub fn with_element_transform<R>(
&mut self,
transformation: TransformationMatrix,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_element_transform<R>( &mut self, transformation: TransformationMatrix, f: impl FnOnce(&mut Self) -> R, ) -> R
vue-native fork: composes transformation onto the current element
transform (the child’s own transform applied first) for the duration of
f. A unit transform is free.
Sourcepub fn content_mask_in_element_space(&self) -> ContentMask<Pixels>
pub fn content_mask_in_element_space(&self) -> ContentMask<Pixels>
The current content mask, expressed in the frame the CALLER is drawing in
— i.e. mapped BACK through the CSS transform in force.
Painting code computes a primitive’s rectangle in the element’s own,
untransformed space (the shader is what applies the matrix), while
Window::content_mask is a window-space rect. Anything that decides
whether to emit a primitive at all by comparing the two has to bring
them into one frame first, and this is the cheap end to move.
A singular matrix (scale(0)) has no inverse; the element is drawn to
nothing, so the mask is empty and everything is culled.
Sourcepub fn element_transform(&self) -> TransformationMatrix
pub fn element_transform(&self) -> TransformationMatrix
The composed transform of the element currently being painted. Identity
unless an ancestor pushed one with Window::with_element_transform.
Sourcepub fn transact<T, U>(
&mut self,
f: impl FnOnce(&mut Self) -> Result<T, U>,
) -> Result<T, U>
pub fn transact<T, U>( &mut self, f: impl FnOnce(&mut Self) -> Result<T, U>, ) -> Result<T, U>
Perform prepaint on child elements in a “retryable” manner, so that any side effects
of prepaints can be discarded before prepainting again. This is used to support autoscroll
where we need to prepaint children to detect the autoscroll bounds, then adjust the
element offset and prepaint again. See crate::List for an example. This method should only be
called during the prepaint phase of element drawing.
Sourcepub fn request_autoscroll(&mut self, bounds: Bounds<Pixels>)
pub fn request_autoscroll(&mut self, bounds: Bounds<Pixels>)
When you call this method during Element::prepaint, containing elements will attempt to
scroll to cause the specified bounds to become visible. When they decide to autoscroll, they will call
Element::prepaint again with a new set of bounds. See crate::List for an example of an element
that supports this method being called on the elements it contains. This method should only be
called during the prepaint phase of element drawing.
Sourcepub fn take_autoscroll(&mut self) -> Option<Bounds<Pixels>>
pub fn take_autoscroll(&mut self) -> Option<Bounds<Pixels>>
This method can be called from a containing element such as crate::List to support the autoscroll behavior
described in Self::request_autoscroll.
Sourcepub fn use_asset<A: Asset>(
&mut self,
source: &A::Source,
cx: &mut App,
) -> Option<A::Output>
pub fn use_asset<A: Asset>( &mut self, source: &A::Source, cx: &mut App, ) -> Option<A::Output>
Asynchronously load an asset, if the asset hasn’t finished loading this will return None. Your view will be re-drawn once the asset has finished loading.
Note that the multiple calls to this method will only result in one Asset::load call at a
time.
Sourcepub fn get_asset<A: Asset>(
&mut self,
source: &A::Source,
cx: &mut App,
) -> Option<A::Output>
pub fn get_asset<A: Asset>( &mut self, source: &A::Source, cx: &mut App, ) -> Option<A::Output>
Asynchronously load an asset, if the asset hasn’t finished loading or doesn’t exist this will return None. Your view will not be re-drawn once the asset has finished loading.
Note that the multiple calls to this method will only result in one Asset::load call at a
time.
Sourcepub fn element_offset(&self) -> Point<Pixels>
pub fn element_offset(&self) -> Point<Pixels>
Obtain the current element offset. This method should only be called during the prepaint phase of element drawing.
Sourcepub fn content_mask(&self) -> ContentMask<Pixels>
pub fn content_mask(&self) -> ContentMask<Pixels>
Obtain the current content mask. This method should only be called during element drawing.
Sourcepub fn with_element_namespace<R>(
&mut self,
element_id: impl Into<ElementId>,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_element_namespace<R>( &mut self, element_id: impl Into<ElementId>, f: impl FnOnce(&mut Self) -> R, ) -> R
Provide elements in the called function with a new namespace in which their identifiers must be unique. This can be used within a custom element to distinguish multiple sets of child elements.
Sourcepub fn use_keyed_state<S: 'static>(
&mut self,
key: impl Into<ElementId>,
cx: &mut App,
init: impl FnOnce(&mut Self, &mut Context<'_, S>) -> S,
) -> Entity<S>
pub fn use_keyed_state<S: 'static>( &mut self, key: impl Into<ElementId>, cx: &mut App, init: impl FnOnce(&mut Self, &mut Context<'_, S>) -> S, ) -> Entity<S>
Use a piece of state that exists as long this element is being rendered in consecutive frames.
Sourcepub fn use_state<S: 'static>(
&mut self,
cx: &mut App,
init: impl FnOnce(&mut Self, &mut Context<'_, S>) -> S,
) -> Entity<S>
pub fn use_state<S: 'static>( &mut self, cx: &mut App, init: impl FnOnce(&mut Self, &mut Context<'_, S>) -> S, ) -> Entity<S>
Use a piece of state that exists as long this element is being rendered in consecutive frames, without needing to specify a key
NOTE: This method uses the location of the caller to generate an ID for this state.
If this is not sufficient to identify your state (e.g. you’re rendering a list item),
you can provide a custom ElementID using the use_keyed_state method.
Sourcepub fn with_element_state<S, R>(
&mut self,
global_id: &GlobalElementId,
f: impl FnOnce(Option<S>, &mut Self) -> (R, S),
) -> Rwhere
S: 'static,
pub fn with_element_state<S, R>(
&mut self,
global_id: &GlobalElementId,
f: impl FnOnce(Option<S>, &mut Self) -> (R, S),
) -> Rwhere
S: 'static,
Updates or initializes state for an element with the given id that lives across multiple frames. If an element with this ID existed in the rendered frame, its state will be passed to the given closure. The state returned by the closure will be stored so it can be referenced when drawing the next frame. This method should only be called as part of element drawing.
Sourcepub fn with_optional_element_state<S, R>(
&mut self,
global_id: Option<&GlobalElementId>,
f: impl FnOnce(Option<Option<S>>, &mut Self) -> (R, Option<S>),
) -> Rwhere
S: 'static,
pub fn with_optional_element_state<S, R>(
&mut self,
global_id: Option<&GlobalElementId>,
f: impl FnOnce(Option<Option<S>>, &mut Self) -> (R, Option<S>),
) -> Rwhere
S: 'static,
A variant of with_element_state that allows the element’s id to be optional. This is a convenience
method for elements where the element id may or may not be assigned. Prefer using with_element_state
when the element is guaranteed to have an id.
The first option means ‘no ID provided’ The second option means ‘not yet initialized’
Sourcepub fn with_tab_group<R>(
&mut self,
index: Option<isize>,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_tab_group<R>( &mut self, index: Option<isize>, f: impl FnOnce(&mut Self) -> R, ) -> R
Executes the given closure within the context of a tab group.
Sourcepub fn defer_draw(
&mut self,
element: AnyElement,
absolute_offset: Point<Pixels>,
priority: usize,
content_mask: Option<ContentMask<Pixels>>,
)
pub fn defer_draw( &mut self, element: AnyElement, absolute_offset: Point<Pixels>, priority: usize, content_mask: Option<ContentMask<Pixels>>, )
Defers the drawing of the given element, scheduling it to be painted on top of the currently-drawn tree
at a later time. The priority parameter determines the drawing order relative to other deferred elements,
with higher values being drawn on top.
When content_mask is provided, the deferred element will be clipped to that region during
both prepaint and paint. When None, no additional clipping is applied.
This method should only be called as part of the prepaint phase of element drawing.
Sourcepub fn defer_draw_with_stack_key(
&mut self,
element: AnyElement,
absolute_offset: Point<Pixels>,
priority: usize,
content_mask: Option<ContentMask<Pixels>>,
stack_key: Option<Rc<[u128]>>,
)
pub fn defer_draw_with_stack_key( &mut self, element: AnyElement, absolute_offset: Point<Pixels>, priority: usize, content_mask: Option<ContentMask<Pixels>>, stack_key: Option<Rc<[u128]>>, )
vue-native fork: Window::defer_draw, sorted among draws of equal
priority by stack_key (see crate::Deferred::with_stack_key).
Sourcepub fn paint_layer<R>(&mut self, f: impl FnOnce(&mut Self) -> R) -> R
pub fn paint_layer<R>(&mut self, f: impl FnOnce(&mut Self) -> R) -> R
Creates a new painting layer. A “layer” is a batch of geometry that are non-overlapping and have the same draw order. This is typically used for performance reasons.
Layers painted inside f are drawn above this layer, including above
what f paints after them.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn paint_drop_shadows(
&mut self,
bounds: Bounds<Pixels>,
corner_radii: Corners<Pixels>,
shadows: &[BoxShadow],
)
pub fn paint_drop_shadows( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, shadows: &[BoxShadow], )
Paint the drop (non-inset) shadows from shadows into the scene at the current
z-index. Inset shadows are skipped; paint those with Self::paint_inset_shadows
after the element’s background so they layer on top of the fill.
This method should only be called as part of the paint phase of element drawing.
vue-native fork: a drop shadow is drawn outside the element’s border box
only, as CSS clips an outer box-shadow (CSS Backgrounds 3 §7.1). So a
translucent background shows what is behind the element, not the
shadow; a focus ring (0 0 0 3px) on a transparent control is a ring.
Sourcepub fn paint_drop_shadows_under_box(
&mut self,
bounds: Bounds<Pixels>,
corner_radii: Corners<Pixels>,
shadows: &[BoxShadow],
)
pub fn paint_drop_shadows_under_box( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, shadows: &[BoxShadow], )
vue-native fork: Self::paint_drop_shadows without the cut-out: the
shadow also fills the area under the border box. For a shadow that
stands in for the element’s own painting (Style::vn_shadow_under_box).
Sourcepub fn paint_inset_shadows(
&mut self,
bounds: Bounds<Pixels>,
corner_radii: Corners<Pixels>,
shadows: &[BoxShadow],
)
pub fn paint_inset_shadows( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, shadows: &[BoxShadow], )
Paint the inset shadows from shadows into the scene at the current z-index. Should
be called after the element’s background so the shadow layers on top of the fill.
Drop shadows are skipped; paint those with Self::paint_drop_shadows before the background.
Sourcepub fn paint_quad(&mut self, quad: PaintQuad)
pub fn paint_quad(&mut self, quad: PaintQuad)
Paint one or more quads into the scene for the next frame at the current stacking context.
Quads are colored rectangular regions with an optional background, border, and corner radius.
see fill, outline, and quad to construct this type.
This method should only be called as part of the paint phase of element drawing.
Note that the quad.corner_radii are allowed to exceed the bounds, creating sharp corners
where the circular arcs meet. This will not display well when combined with dashed borders.
Use Corners::clamp_radii_for_quad_size if the radii should fit within the bounds.
Sourcepub fn paint_backdrop_blur_rect(
&mut self,
bounds: Bounds<Pixels>,
corner_radii: Corners<Pixels>,
effect: BackdropBlurEffect,
)
pub fn paint_backdrop_blur_rect( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, effect: BackdropBlurEffect, )
Paint a backdrop blur rectangle into the scene at the current z-index.
This is the primitive behind CSS backdrop-filter: blur(): the pixels
already painted behind bounds are replaced with a blurred copy of
themselves, clipped to the rounded rect described by corner_radii.
The blur samples the render target as it exists at its paint position, so renderers may need to break the current pass when this primitive is encountered. Prefer one blur rect per glass surface rather than many small ones. Renderers without backdrop blur support ignore this primitive entirely, including its tint.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn paint_effect_quad(
&mut self,
bounds: Bounds<Pixels>,
corner_radii: Corners<Pixels>,
spec: EffectSpec,
)
pub fn paint_effect_quad( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, spec: EffectSpec, )
Paint a custom-shaded rounded rect into the scene at the current
z-index — the primitive behind the --shading CSS property.
spec.id selects one of the built-in fragment pipelines and params
are its positional arguments. Parameters the schema marks as lengths
arrive in LOGICAL pixels and are scaled here, exactly like every other
length in a primitive.
An effect that reads the backdrop ([EFFECT_FLAG_NEEDS_BACKDROP])
samples the render target as it exists at its paint position, so — like
Self::paint_backdrop_blur_rect — renderers break the current pass
when they meet one, and the scene forces everything painted afterwards
to draw above it. An effect that does not is an ordinary blended quad
and costs nothing extra.
Renderers without effect support (or on hardware below D3D feature level 11) ignore this primitive entirely.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn vn_paint_effect(
&mut self,
bounds: Bounds<Pixels>,
corner_radii: Corners<Pixels>,
spec: EffectSpec,
element: u64,
)
pub fn vn_paint_effect( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, spec: EffectSpec, element: u64, )
vue-native fork: Self::paint_effect_quad for element
(Self::vn_take_effect_element), which keys an [SkHistory] state.
Sourcepub fn vn_paint_textured_effect(
&mut self,
bounds: Bounds<Pixels>,
corner_radii: Corners<Pixels>,
spec: EffectSpec,
element: u64,
cx: &mut App,
)
pub fn vn_paint_textured_effect( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, spec: EffectSpec, element: u64, cx: &mut App, )
vue-native: Self::vn_paint_effect with the images spec samples,
resolved through crate::set_effect_texture_resolver.
Sourcepub fn vn_set_effect_element(&mut self, id: Option<&GlobalElementId>)
pub fn vn_set_effect_element(&mut self, id: Option<&GlobalElementId>)
vue-native fork: names the element whose style paints next
(Self::vn_take_effect_element).
Sourcepub fn vn_take_effect_element(&mut self) -> u64
pub fn vn_take_effect_element(&mut self) -> u64
vue-native fork: the element Self::vn_set_effect_element named, 0
for none; taken, so a child without an identity does not inherit it.
Sourcepub fn vn_with_effect_content<R>(
&mut self,
bounds: Bounds<Pixels>,
corner_radii: Corners<Pixels>,
effects: &[(EffectSpec, f32, Option<Arc<EffectTextureSet>>)],
element: u64,
cx: &mut App,
f: impl FnOnce(&mut Self, &mut App) -> R,
) -> R
pub fn vn_with_effect_content<R>( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, effects: &[(EffectSpec, f32, Option<Arc<EffectTextureSet>>)], element: u64, cx: &mut App, f: impl FnOnce(&mut Self, &mut App) -> R, ) -> R
vue-native fork: paints f into an isolated group at full opacity, which
the [SkContent] effects among effects composite in its place; the
opacity share none of them takes composites the group as it is.
Sourcepub fn vn_paint_punch(
&mut self,
bounds: Bounds<Pixels>,
corner_radii: Corners<Pixels>,
)
pub fn vn_paint_punch( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, )
vue-native: makes bounds (rounded by corner_radii) transparent in
this window’s surface, erasing what was painted there so far; what is
painted after it draws over the hole as usual. The window has to
present with alpha for anything to show through (on Windows,
DirectComposition: Window::vn_composition_underlay).
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn paint_path(&mut self, path: Path, color: impl Into<Background>)
pub fn paint_path(&mut self, path: Path, color: impl Into<Background>)
Paint the given Path into the scene for the next frame at the current z-index.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn paint_underline(
&mut self,
origin: Point<Pixels>,
width: Pixels,
style: &UnderlineStyle,
)
pub fn paint_underline( &mut self, origin: Point<Pixels>, width: Pixels, style: &UnderlineStyle, )
Paint an underline into the scene for the next frame at the current z-index.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn paint_strikethrough(
&mut self,
origin: Point<Pixels>,
width: Pixels,
style: &StrikethroughStyle,
)
pub fn paint_strikethrough( &mut self, origin: Point<Pixels>, width: Pixels, style: &StrikethroughStyle, )
Paint a strikethrough into the scene for the next frame at the current z-index.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn paint_glyph(
&mut self,
origin: Point<Pixels>,
font_id: FontId,
glyph_id: GlyphId,
font_size: Pixels,
color: Hsla,
) -> Result<()>
pub fn paint_glyph( &mut self, origin: Point<Pixels>, font_id: FontId, glyph_id: GlyphId, font_size: Pixels, color: Hsla, ) -> Result<()>
Paints a monochrome (non-emoji) glyph into the scene for the next frame at the current z-index.
The y component of the origin is the baseline of the glyph.
You should generally prefer to use the ShapedLine::paint or
WrappedLine::paint methods in the TextSystem.
This method is only useful if you need to paint a single glyph that has already been shaped.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn paint_glyph_shadow(
&mut self,
origin: Point<Pixels>,
font_id: FontId,
glyph_id: GlyphId,
font_size: Pixels,
is_emoji: bool,
color: Hsla,
blur_radius: Pixels,
) -> Result<()>
pub fn paint_glyph_shadow( &mut self, origin: Point<Pixels>, font_id: FontId, glyph_id: GlyphId, font_size: Pixels, is_emoji: bool, color: Hsla, blur_radius: Pixels, ) -> Result<()>
vue-native fork: paints a glyph’s CSS text-shadow, its coverage in color blurred by
blur_radius. origin is the shadow’s baseline origin, offset included.
Sourcepub fn paint_emoji(
&mut self,
origin: Point<Pixels>,
font_id: FontId,
glyph_id: GlyphId,
font_size: Pixels,
) -> Result<()>
pub fn paint_emoji( &mut self, origin: Point<Pixels>, font_id: FontId, glyph_id: GlyphId, font_size: Pixels, ) -> Result<()>
Paints an emoji glyph into the scene for the next frame at the current z-index.
The y component of the origin is the baseline of the glyph.
You should generally prefer to use the ShapedLine::paint or
WrappedLine::paint methods in the TextSystem.
This method is only useful if you need to paint a single emoji that has already been shaped.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn paint_svg(
&mut self,
bounds: Bounds<Pixels>,
path: SharedString,
data: Option<&[u8]>,
transformation: TransformationMatrix,
color: Hsla,
cx: &App,
) -> Result<()>
pub fn paint_svg( &mut self, bounds: Bounds<Pixels>, path: SharedString, data: Option<&[u8]>, transformation: TransformationMatrix, color: Hsla, cx: &App, ) -> Result<()>
Paint a monochrome SVG into the scene for the next frame at the current stacking context.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn paint_image(
&mut self,
bounds: Bounds<Pixels>,
image_bounds: Bounds<Pixels>,
corner_radii: Corners<Pixels>,
data: Arc<RenderImage>,
frame_index: usize,
grayscale: bool,
) -> Result<()>
pub fn paint_image( &mut self, bounds: Bounds<Pixels>, image_bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, data: Arc<RenderImage>, frame_index: usize, grayscale: bool, ) -> Result<()>
Paint an image into the scene for the next frame at the current z-index. This method will panic if the frame_index is not valid
This method should only be called as part of the paint phase of element drawing.
Paint an image into bounds, positioning and scaling it according to image_bounds.
vue-native: with an ImageResampler installed, an image that is not
RenderImage::dynamic may be drawn from the smaller copy it returns.
The visible region rendered is bounds.intersect(&image_bounds), with corner_radii
applied to bounds.
Sourcepub fn upload_image_from_gpu(
&mut self,
data: &RenderImage,
frame_index: usize,
texture: GpuTextureHandle,
) -> Result<bool>
pub fn upload_image_from_gpu( &mut self, data: &RenderImage, frame_index: usize, texture: GpuTextureHandle, ) -> Result<bool>
Fills the sprite-atlas tile that backs data from a texture that is
already in the renderer’s own GPU memory, with no CPU round trip.
data is used for its identity and its size only — its pixel buffer
is never read on this path, so a producer that decodes onto the GPU can
keep one zero-filled RenderImage alive for the life of the element and
overwrite its tile every frame. paint_image then finds the tile
already populated and never runs its build closure.
Returns Ok(false) when the platform has no GPU path or refused the
texture (wrong device, wrong format, too small) — the caller is expected
to fall back to a RenderImage carrying real bytes. This is not a paint
method: call it from a frame pump, before the draw that paints the image.
§Contract
See PlatformAtlas::upload_from_gpu. On Windows texture must be an
ID3D11Texture2D on the device gpui_windows::renderer_d3d11_device()
publishes, in DXGI_FORMAT_B8G8R8A8_UNORM, at least as large as
data.size(frame_index).
Sourcepub fn write_image_tile(
&mut self,
image: &RenderImage,
frame_index: usize,
source: TileSource,
) -> Result<TileWrite>
pub fn write_image_tile( &mut self, image: &RenderImage, frame_index: usize, source: TileSource, ) -> Result<TileWrite>
vue-native fork: writes a new frame into the sprite-atlas tile that backs
image, outside any draw, and says whether the frame already drawn will
show it.
The tile is keyed by image.id. A producer that keeps one id for the
life of a picture (a zero-copy video placeholder, or
RenderImage::successor for CPU frames) keeps one tile, and the
scene that painted it samples whatever was written last. When the write
lands TileWrite::InPlace, Window::request_present shows it with
no layout, prepaint or paint. The size is image.size(frame_index).
Call it from a frame callback, before the frame’s draw, never during one.
TileSource::Bytes writes image’s own pixels (premultiplied BGRA).
It always succeeds: a backend with no in-place path re-inserts the key,
which reports TileWrite::Placed. TileSource::Gpu has the contract
of PlatformAtlas::upload_from_gpu and reports
TileWrite::Refused where that returns None.
Sourcepub fn write_image_tile_d3d12(
&mut self,
image: &RenderImage,
frame_index: usize,
texture: D3D12TextureHandle,
owner: Arc<dyn Any + Send + Sync>,
) -> Result<TileWrite>
pub fn write_image_tile_d3d12( &mut self, image: &RenderImage, frame_index: usize, texture: D3D12TextureHandle, owner: Arc<dyn Any + Send + Sync>, ) -> Result<TileWrite>
Writes a GPU frame while retaining its producer until the asynchronous
atlas copy completes. See PlatformAtlas::upload_from_d3d12.
Sourcepub fn request_present(&self)
pub fn request_present(&self)
vue-native fork: presents the frame already drawn once more, with no
layout, prepaint or paint: the renderer encodes the same scene again, so
an atlas tile overwritten in place since (Window::write_image_tile,
TileWrite::InPlace) shows its new pixels. From an on_next_frame
callback it takes effect in that frame; elsewhere, on the next one. A
frame that draws anyway presents what it drew.
Sourcepub fn drop_image(&mut self, data: Arc<RenderImage>) -> Result<()>
pub fn drop_image(&mut self, data: Arc<RenderImage>) -> Result<()>
Removes an image from the sprite atlas.
Sourcepub fn sprite_atlas_stats(&self) -> Option<AtlasStats>
pub fn sprite_atlas_stats(&self) -> Option<AtlasStats>
vue-native fork: this window’s sprite atlas footprint (pages and bytes
per texture kind, keys, image tiles), for an embedder’s memory report.
None when the platform’s atlas does not keep count.
Sourcepub fn has_image_atlas_tile(
&self,
data: &RenderImage,
frame_index: usize,
) -> bool
pub fn has_image_atlas_tile( &self, data: &RenderImage, frame_index: usize, ) -> bool
Reports a live atlas tile on backends supporting GPU image imports.
Sourcepub fn vn_enable_retained_layout(&mut self)
pub fn vn_enable_retained_layout(&mut self)
Enable node retention for this window before its first layout request. Generic GPUI windows retain upstream’s per-frame layout by default.
Sourcepub fn vn_profile_retained_layout(&mut self, enabled: bool)
pub fn vn_profile_retained_layout(&mut self, enabled: bool)
Enable counters only while a profiling capture is active.
Sourcepub fn vn_take_retained_layout_stats(&mut self) -> Option<VnRetainedLayoutStats>
pub fn vn_take_retained_layout_stats(&mut self) -> Option<VnRetainedLayoutStats>
Drain this window’s retention counters, or None while profiling is off.
Sourcepub fn request_layout(
&mut self,
style: Style,
children: impl IntoIterator<Item = LayoutId>,
cx: &mut App,
) -> LayoutId
pub fn request_layout( &mut self, style: Style, children: impl IntoIterator<Item = LayoutId>, cx: &mut App, ) -> LayoutId
Add a node to the layout tree for the current frame. Takes the Style of the element for which
layout is being requested, along with the layout ids of any children. This method is called during
calls to the Element::request_layout trait method and enables any element to participate in layout.
This method should only be called as part of the request_layout or prepaint phase of element drawing.
Sourcepub fn request_measured_layout<F>(
&mut self,
style: Style,
measure: F,
) -> LayoutId
pub fn request_measured_layout<F>( &mut self, style: Style, measure: F, ) -> LayoutId
Add a node to the layout tree for the current frame. Instead of taking a Style and children,
this variant takes a function that is invoked during layout so you can use arbitrary logic to
determine the element’s size. One place this is used internally is when measuring text.
The given closure is invoked at layout time with the known dimensions and available space and
returns a Size.
This method should only be called as part of the request_layout or prepaint phase of element drawing.
Sourcepub fn compute_layout(
&mut self,
layout_id: LayoutId,
available_space: Size<AvailableSpace>,
cx: &mut App,
)
pub fn compute_layout( &mut self, layout_id: LayoutId, available_space: Size<AvailableSpace>, cx: &mut App, )
Compute the layout for the given id within the given available space. This method is called for its side effect, typically by the framework prior to painting. After calling it, you can request the bounds of the given layout node id or any descendant.
This method should only be called as part of the prepaint phase of element drawing.
Sourcepub fn layout_is_absolute(&self, layout_id: LayoutId) -> bool
pub fn layout_is_absolute(&self, layout_id: LayoutId) -> bool
vue-native fork: whether the layout node is out of flow (position: absolute).
Sourcepub fn layout_bounds(&mut self, layout_id: LayoutId) -> Bounds<Pixels>
pub fn layout_bounds(&mut self, layout_id: LayoutId) -> Bounds<Pixels>
Obtain the bounds computed for the given LayoutId relative to the window. This method will usually be invoked by
GPUI itself automatically in order to pass your element its Bounds automatically.
This method should only be called as part of element drawing.
Sourcepub fn insert_hitbox(
&mut self,
bounds: Bounds<Pixels>,
behavior: HitboxBehavior,
) -> Hitbox
pub fn insert_hitbox( &mut self, bounds: Bounds<Pixels>, behavior: HitboxBehavior, ) -> Hitbox
This method should be called during prepaint. You can use
the returned Hitbox during paint or in an event handler
to determine whether the inserted hitbox was the topmost.
This method should only be called as part of the prepaint phase of element drawing.
Sourcepub fn set_hitbox_tag(&mut self, tag: u32) -> u32
pub fn set_hitbox_tag(&mut self, tag: u32) -> u32
vue-native fork: tag every hitbox inserted from now until the tag is set back, with an embedder node id. Returns the previous tag, which the caller must restore — the pair brackets one node’s prepaint, so a child tags itself and hands the parent’s tag back on the way out.
0 disables tagging. See [Frame::vn_tagged_hitboxes].
Sourcepub fn with_hitbox_tag<R>(
&mut self,
tag: u32,
f: impl FnOnce(&mut Self) -> R,
) -> (R, Option<TransformationMatrix>)
pub fn with_hitbox_tag<R>( &mut self, tag: u32, f: impl FnOnce(&mut Self) -> R, ) -> (R, Option<TransformationMatrix>)
vue-native fork: Window::set_hitbox_tag for the duration of f,
which prepaints one embedder node, answering also the node’s whole CSS
transform (its ancestors’ composed with its own) when it has one of
its own. None means its picture moved only with its ancestors’, by
Window::element_transform as it stood before f.
“The node’s own” is the FIRST element to prepaint inside f: the
node’s element runs before anything inside it, and what it builds
internally under the same tag (a ::before box, a list marker) after,
so a transformed pseudo-element does not move its node.
Sourcepub fn transformed_bounds(
&self,
matrix: TransformationMatrix,
bounds: Bounds<Pixels>,
) -> Bounds<Pixels>
pub fn transformed_bounds( &self, matrix: TransformationMatrix, bounds: Bounds<Pixels>, ) -> Bounds<Pixels>
vue-native fork: the axis-aligned bounding box of bounds (logical
pixels) under matrix (device space, as Window::element_transform
is) — the rectangle a browser’s getBoundingClientRect() reports for a
transformed box.
Sourcepub fn set_tag_every_hitbox(&mut self, on: bool)
pub fn set_tag_every_hitbox(&mut self, on: bool)
vue-native fork: give EVERY element a hitbox, not only an interactive
one, so that Window::tagged_hitbox can answer for any node. Costs
one Hitbox per element per frame and the same number of rectangle
tests per mouse move, so it is opt-in; a dev host turns it on at boot
and a shipped one never does.
vue-native fork: is Window::set_tag_every_hitbox on?
Sourcepub fn tagged_hitbox(&self, tag: u32) -> Option<&Hitbox>
pub fn tagged_hitbox(&self, tag: u32) -> Option<&Hitbox>
vue-native fork: the hitbox the RENDERED frame made for the element
tagged tag — the handle Hitbox::is_hovered_at takes.
The first entry wins: an element’s own hitbox is inserted before any box
its subtree makes, and boxes a node’s build produces internally (a
pseudo-element, a list marker) carry the same tag. A pick
(Window::vn_insert_pick) is not a hitbox and is passed over.
vue-native fork: the embedder tags of the hitboxes under position in
the RENDERED frame, topmost first — the order a press resolves in
([Frame::hit_test], so a deferred draw’s boxes sort where it paints).
A hitbox no node tagged is left out; a node with several boxes there
appears once per box.
An embedder asks it to learn which of ITS nodes is on top under the
pointer, which gpui’s own answer (Hitbox::is_hovered, true for every
box under the pointer) cannot say. One hit test plus one pass over the
frame’s tagged boxes: meant for a press or a drag, not for every mouse
move.
The PICK records (Window::vn_insert_pick) are boxes too, so with
Window::set_vn_pick_every_box on this answers for every element,
listening or not. It walks the tagged list in paint order itself rather
than asking [Frame::hit_test], whose list has no picks; a
BlockMouse box ends it, as it ends gpui’s.
A box tagged VN_TAG_PASSIVE is left out: it is a node’s, but it is
not where the node is (a scroll container’s wheel viewport, which lies
over the content it scrolls).
Sourcepub fn set_vn_pick_every_box(&mut self, on: bool)
pub fn set_vn_pick_every_box(&mut self, on: bool)
vue-native fork: give an element that needs no hitbox a PICK record
instead — its box, content mask, transform and tag, in
[Frame::vn_tagged_hitboxes] only. gpui’s own hit test (the one every
mouse move runs) never sees a pick, so it costs a move nothing; it is
there for Window::vn_tags_at, which an embedder asks at a press to
learn the topmost of ALL its elements, the way a browser targets an
event. Replayed with the rest of a cached view’s prepaint.
Sourcepub fn vn_picks_every_box(&self) -> bool
pub fn vn_picks_every_box(&self) -> bool
vue-native fork: is Window::set_vn_pick_every_box on?
Sourcepub fn vn_insert_pick(&mut self, bounds: Bounds<Pixels>)
pub fn vn_insert_pick(&mut self, bounds: Bounds<Pixels>)
vue-native fork: records a pick for bounds under the current tag
(nothing outside a tag). Called where an element would insert its
hitbox, so the content mask and transform are the ones a hitbox there
would carry.
Sourcepub fn set_vn_hit_refiner(&mut self, refiner: Option<VnHitRefiner>)
pub fn set_vn_hit_refiner(&mut self, refiner: Option<VnHitRefiner>)
vue-native fork: installs (or removes) the embedder’s hit refiner.
gpui hands a mouse event to EVERY hitbox under the pointer, so a box
that listens takes a press through anything painted over it that does
not, and a box that does not listen is never anybody’s target. A
browser targets the topmost element and bubbles from there. The
refiner is run at the start of the dispatch of each press, release and
wheel event, before any listener, and may narrow what the event is for
with Window::vn_restrict_mouse_hit. Moves are not refined.
Sourcepub fn has_vn_hit_refiner(&self) -> bool
pub fn has_vn_hit_refiner(&self) -> bool
vue-native fork: is a hit refiner installed?
Sourcepub fn vn_key_event_seq(&self) -> u64
pub fn vn_key_event_seq(&self) -> u64
vue-native fork: which key event this window is dispatching — one number per key-down, key-up or modifiers change, taken before the keystroke interceptors run, so everything that hears one event (an interceptor, the capture listeners, the bubble listeners) reads the same number and the next event reads another.
gpui hands a key event to every listener on the focus path, and an
editor’s interceptor sees it before any of them. An embedder that turns
it into ONE event of its own (a browser’s keydown, dispatched once at
the focused element) records the number it dispatched for and lets the
others pass. Interceptor order and listener order do not matter, and a
listener whose element the first dispatch removed still reads the same
number, because gpui walks the path it computed before any of them ran.
Sourcepub fn vn_pointer_inside(&self) -> bool
pub fn vn_pointer_inside(&self) -> bool
vue-native fork: is the pointer in this window? false once it has
left (a MouseExited, the end of a file drag over it), true again at
the next pointer event here. Window::mouse_position keeps the last
position inside either way, so an embedder that decides hover itself
(a browser’s :hover and mouseenter, from its own hit test) asks
this to know that nothing is hovered, as Hitbox::is_hovered does.
Sourcepub fn vn_lock_pointer(
&mut self,
how: VnPointerLock,
) -> Result<(), PointerLockError>
pub fn vn_lock_pointer( &mut self, how: VnPointerLock, ) -> Result<(), PointerLockError>
vue-native fork: a browser’s pointer lock. Until Window::vn_unlock_pointer, every
mouse event is delivered at the position the pointer had now, and a move’s motion is
Window::vn_mouse_movement. Locking again changes the mode.
Sourcepub fn vn_unlock_pointer(&mut self)
pub fn vn_unlock_pointer(&mut self)
vue-native fork: releases Window::vn_lock_pointer’s lock, if any.
Sourcepub fn vn_pointer_locked(&self) -> bool
pub fn vn_pointer_locked(&self) -> bool
vue-native fork: is the pointer still locked? The platform lets go by itself when the window loses activation.
Sourcepub fn vn_mouse_movement(&self) -> Point<Pixels>
pub fn vn_mouse_movement(&self) -> Point<Pixels>
vue-native fork: how far the mouse move being dispatched moved the pointer since the
previous move, logical pixels: a browser’s movementX/movementY. While the pointer is
locked by the system it is the platform’s measure (device counts when unadjusted).
Sourcepub fn vn_is_dirty(&self) -> bool
pub fn vn_is_dirty(&self) -> bool
vue-native fork: will this frame draw the window? true once anything
invalidated it since its last draw (a notify, a refresh, a resize).
An embedder with work that must follow the frame’s layout and precede
its paint (a browser’s ResizeObserver delivery) draws the window itself
from an on_next_frame callback when this is set; the frame then finds
it clean and presents what that draw produced.
Sourcepub fn vn_restrict_mouse_hit(&mut self, keep: &dyn Fn(u32) -> bool, add: bool)
pub fn vn_restrict_mouse_hit(&mut self, keep: &dyn Fn(u32) -> bool, add: bool)
vue-native fork: for the mouse event being dispatched, keep only the
hitboxes whose tag keep accepts (an untagged hitbox is not the
embedder’s and stays). With add, the accepted tags’ boxes that do
NOT contain the pointer join the hovered set as well: a browser’s
event reaches every ancestor of its target, wherever their boxes are.
Only meant from inside a VnHitRefiner. The next frame or the next
mouse event recomputes the hit test from geometry.
Sourcepub fn window_control_area_at(
&self,
position: Point<Pixels>,
) -> Option<WindowControlArea>
pub fn window_control_area_at( &self, position: Point<Pixels>, ) -> Option<WindowControlArea>
Resolves native caption behavior at a point in the current painted frame. This does not reuse or modify the hit set narrowed for a DOM input event.
Sourcepub fn insert_window_control_hitbox(
&mut self,
area: WindowControlArea,
hitbox: Hitbox,
)
pub fn insert_window_control_hitbox( &mut self, area: WindowControlArea, hitbox: Hitbox, )
Set a hitbox which will act as a control area of the platform window.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn set_key_context(&mut self, context: KeyContext)
pub fn set_key_context(&mut self, context: KeyContext)
Sets the key context for the current element. This context will be used to translate keybindings into actions.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn set_focus_handle(&mut self, focus_handle: &FocusHandle, _: &App)
pub fn set_focus_handle(&mut self, focus_handle: &FocusHandle, _: &App)
Sets the focus handle for the current element. This handle will be used to manage focus state and keyboard event dispatch for the element.
This method should only be called as part of the prepaint phase of element drawing.
Sourcepub fn set_view_id(&mut self, view_id: EntityId)
pub fn set_view_id(&mut self, view_id: EntityId)
Sets the view id for the current element, which will be used to manage view caching.
This method should only be called as part of element prepaint. We plan on removing this method eventually when we solve some issues that require us to construct editor elements directly instead of always using editors via views.
Sourcepub fn current_view(&self) -> EntityId
pub fn current_view(&self) -> EntityId
Get the entity ID for the currently rendering view
Sourcepub fn with_image_cache<F, R>(
&mut self,
image_cache: Option<AnyImageCache>,
f: F,
) -> Rwhere
F: FnOnce(&mut Self) -> R,
pub fn with_image_cache<F, R>(
&mut self,
image_cache: Option<AnyImageCache>,
f: F,
) -> Rwhere
F: FnOnce(&mut Self) -> R,
Executes the provided function with the specified image cache.
Sourcepub fn handle_input(
&mut self,
focus_handle: &FocusHandle,
input_handler: impl InputHandler,
cx: &App,
)
pub fn handle_input( &mut self, focus_handle: &FocusHandle, input_handler: impl InputHandler, cx: &App, )
Sets an input handler, such as ElementInputHandler, which interfaces with the
platform to receive textual input with proper integration with concerns such
as IME interactions. This handler will be active for the upcoming frame until the following frame is
rendered.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn notify_text_input_changed(&self, focus_handle: &FocusHandle)
pub fn notify_text_input_changed(&self, focus_handle: &FocusHandle)
Notifies native text services that the focused component’s text changed.
Text components should call this after application-driven edits, in addition to notifying GPUI to redraw. Unfocused or unregistered components are ignored.
Sourcepub fn notify_text_selection_changed(&self, focus_handle: &FocusHandle)
pub fn notify_text_selection_changed(&self, focus_handle: &FocusHandle)
Notifies native text services that the focused component’s selection changed.
Text components should call this after application-driven selection changes, in addition to notifying GPUI to redraw.
Sourcepub fn on_mouse_event<Event: MouseEvent>(
&mut self,
listener: impl FnMut(&Event, DispatchPhase, &mut Window, &mut App) + 'static,
)
pub fn on_mouse_event<Event: MouseEvent>( &mut self, listener: impl FnMut(&Event, DispatchPhase, &mut Window, &mut App) + 'static, )
Register a mouse event listener on the window for the next frame. The type of event is determined by the first parameter of the given listener. When the next frame is rendered the listener will be cleared.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn on_key_event<Event: KeyEvent>(
&mut self,
listener: impl Fn(&Event, DispatchPhase, &mut Window, &mut App) + 'static,
)
pub fn on_key_event<Event: KeyEvent>( &mut self, listener: impl Fn(&Event, DispatchPhase, &mut Window, &mut App) + 'static, )
Register a key event listener on this node for the next frame. The type of event is determined by the first parameter of the given listener. When the next frame is rendered the listener will be cleared.
This is a fairly low-level method, so prefer using event handlers on elements unless you have a specific need to register a listener yourself.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn on_modifiers_changed(
&mut self,
listener: impl Fn(&ModifiersChangedEvent, &mut Window, &mut App) + 'static,
)
pub fn on_modifiers_changed( &mut self, listener: impl Fn(&ModifiersChangedEvent, &mut Window, &mut App) + 'static, )
Register a modifiers changed event listener on the window for the next frame.
This is a fairly low-level method, so prefer using event handlers on elements unless you have a specific need to register a global listener.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn on_focus_in(
&mut self,
handle: &FocusHandle,
cx: &mut App,
listener: impl FnMut(&mut Window, &mut App) + 'static,
) -> Subscription
pub fn on_focus_in( &mut self, handle: &FocusHandle, cx: &mut App, listener: impl FnMut(&mut Window, &mut App) + 'static, ) -> Subscription
Register a listener to be called when the given focus handle or one of its descendants receives focus. This does not fire if the given focus handle - or one of its descendants - was previously focused. Returns a subscription and persists until the subscription is dropped.
Sourcepub fn on_focus_out(
&mut self,
handle: &FocusHandle,
cx: &mut App,
listener: impl FnMut(FocusOutEvent, &mut Window, &mut App) + 'static,
) -> Subscription
pub fn on_focus_out( &mut self, handle: &FocusHandle, cx: &mut App, listener: impl FnMut(FocusOutEvent, &mut Window, &mut App) + 'static, ) -> Subscription
Register a listener to be called when the given focus handle or one of its descendants loses focus. Returns a subscription and persists until the subscription is dropped.
Sourcepub fn dispatch_keystroke(&mut self, keystroke: Keystroke, cx: &mut App) -> bool
pub fn dispatch_keystroke(&mut self, keystroke: Keystroke, cx: &mut App) -> bool
Dispatch a given keystroke as though the user had typed it. You can create a keystroke with Keystroke::parse(“”).
Sourcepub fn keystroke_text_for(&self, action: &dyn Action, cx: &App) -> String
pub fn keystroke_text_for(&self, action: &dyn Action, cx: &App) -> String
Return a key binding string for an action, to display in the UI. Uses the highest precedence binding for the action (last binding added to the keymap).
Sourcepub fn set_input_interceptor(
&mut self,
interceptor: Option<Rc<dyn Fn(&PlatformInput, &mut Window, &mut App) -> bool>>,
)
pub fn set_input_interceptor( &mut self, interceptor: Option<Rc<dyn Fn(&PlatformInput, &mut Window, &mut App) -> bool>>, )
Installs a modal input interceptor. Return true to consume the event before normal dispatch. Passing None restores the ordinary input path. The callback may remove itself. No callback runs while it is absent.
Sourcepub fn dispatch_event(
&mut self,
event: PlatformInput,
cx: &mut App,
) -> DispatchEventResult
pub fn dispatch_event( &mut self, event: PlatformInput, cx: &mut App, ) -> DispatchEventResult
Dispatch a mouse, keyboard, or touch event on the window.
Sourcepub fn touch_prediction_enabled(&self) -> bool
pub fn touch_prediction_enabled(&self) -> bool
Whether recognized touch pans may use the platform’s predicted touch
positions (TouchEvent::predicted_position) to compensate for input
latency. Defaults to true.
Sourcepub fn set_touch_prediction_enabled(&mut self, enabled: bool)
pub fn set_touch_prediction_enabled(&mut self, enabled: bool)
Sets whether recognized touch pans may use the platform’s predicted
touch positions. Disabling drops TouchEvent::predicted_position
before gesture recognition, so pans track only raw touch positions.
Sourcepub fn has_pending_keystrokes(&self) -> bool
pub fn has_pending_keystrokes(&self) -> bool
Determine whether a potential multi-stroke key binding is in progress on this window.
Sourcepub fn pending_input(&self) -> Option<PendingInputStatus<'_>>
pub fn pending_input(&self) -> Option<PendingInputStatus<'_>>
Returns pending input that can still complete a multi-stroke key binding. Input left over from a previous focus can never complete one.
Sourcepub fn set_pending_input_timeout_paused<T: 'static>(
&mut self,
owner: &Entity<T>,
paused: bool,
cx: &mut App,
) -> bool
pub fn set_pending_input_timeout_paused<T: 'static>( &mut self, owner: &Entity<T>, paused: bool, cx: &mut App, ) -> bool
Pauses or resumes the current pending input timeout on behalf of owner.
A paused timeout resumes automatically if owner is released. Returns whether the timeout
state changed. A timeout paused by one owner cannot be resumed by another.
Sourcepub fn pending_input_keystrokes(&self) -> Option<&[Keystroke]>
pub fn pending_input_keystrokes(&self) -> Option<&[Keystroke]>
Returns the currently pending input keystrokes that might result in a multi-stroke key binding.
Sourcepub fn observe_global<G: Global>(
&mut self,
cx: &mut App,
f: impl Fn(&mut Window, &mut App) + 'static,
) -> Subscription
pub fn observe_global<G: Global>( &mut self, cx: &mut App, f: impl Fn(&mut Window, &mut App) + 'static, ) -> Subscription
Register the given handler to be invoked whenever the global of the given type is updated.
Sourcepub fn activate_window(&self)
pub fn activate_window(&self)
Focus the current window and bring it to the foreground at the platform level.
Sourcepub fn show_window(
&self,
activate: bool,
should_show: impl FnOnce() -> bool + 'static,
completed: impl FnOnce(bool) + 'static,
) -> bool
pub fn show_window( &self, activate: bool, should_show: impl FnOnce() -> bool + 'static, completed: impl FnOnce(bool) + 'static, ) -> bool
Shows a previously hidden window, optionally requesting focus. Returns
false if unsupported; otherwise completed reports the native result.
Sourcepub fn request_attention(&self)
pub fn request_attention(&self)
Requests that the operating system draw attention to this window.
Sourcepub fn minimize_window(&self)
pub fn minimize_window(&self)
Minimize the current window at the platform level.
Sourcepub fn toggle_fullscreen(&self)
pub fn toggle_fullscreen(&self)
Toggle full screen status on the current window at the platform level.
Sourcepub fn toggle_simple_fullscreen(&self)
pub fn toggle_simple_fullscreen(&self)
Toggle simple (borderless) fullscreen, where the window covers the entire
screen including the menu bar and, on notched displays, the area around the
notch. Unlike Window::toggle_fullscreen, this does not move the window
into its own Mission Control space. Only has an effect on macOS.
Sourcepub fn invalidate_character_coordinates(&self)
pub fn invalidate_character_coordinates(&self)
Updates the IME panel position suggestions for languages like japanese, chinese.
Sourcepub fn prompt<T>(
&mut self,
level: PromptLevel,
message: &str,
detail: Option<&str>,
answers: &[T],
cx: &mut App,
) -> Receiver<usize> ⓘ
pub fn prompt<T>( &mut self, level: PromptLevel, message: &str, detail: Option<&str>, answers: &[T], cx: &mut App, ) -> Receiver<usize> ⓘ
Present a platform dialog. The provided message will be presented, along with buttons for each answer. When a button is clicked, the returned Receiver will receive the index of the clicked button.
Sourcepub fn has_active_prompt(&self) -> bool
pub fn has_active_prompt(&self) -> bool
Returns whether a prompt rendered by GPUI is currently active in this window.
This is only true for prompts rendered in the window (see
App::set_prompt_builder), not for platform-native prompt dialogs.
Sourcepub fn context_stack(&self) -> Vec<KeyContext>
pub fn context_stack(&self) -> Vec<KeyContext>
Returns the current context stack.
Sourcepub fn available_actions(&self, cx: &App) -> Vec<Box<dyn Action>>
pub fn available_actions(&self, cx: &App) -> Vec<Box<dyn Action>>
Returns all available actions for the focused element.
Sourcepub fn bindings_for_action(&self, action: &dyn Action) -> Vec<KeyBinding>
pub fn bindings_for_action(&self, action: &dyn Action) -> Vec<KeyBinding>
Returns key bindings that invoke an action on the currently focused element. Bindings are returned in the order they were added. For display, the last binding should take precedence.
Sourcepub fn highest_precedence_binding_for_action(
&self,
action: &dyn Action,
) -> Option<KeyBinding>
pub fn highest_precedence_binding_for_action( &self, action: &dyn Action, ) -> Option<KeyBinding>
Returns the highest precedence key binding that invokes an action on the currently focused
element. This is more efficient than getting the last result of bindings_for_action.
Sourcepub fn bindings_for_action_in_context(
&self,
action: &dyn Action,
context: KeyContext,
) -> Vec<KeyBinding>
pub fn bindings_for_action_in_context( &self, action: &dyn Action, context: KeyContext, ) -> Vec<KeyBinding>
Returns the key bindings for an action in a context.
Sourcepub fn highest_precedence_binding_for_action_in_context(
&self,
action: &dyn Action,
context: KeyContext,
) -> Option<KeyBinding>
pub fn highest_precedence_binding_for_action_in_context( &self, action: &dyn Action, context: KeyContext, ) -> Option<KeyBinding>
Returns the highest precedence key binding for an action in a context. This is more
efficient than getting the last result of bindings_for_action_in_context.
Sourcepub fn bindings_for_action_in(
&self,
action: &dyn Action,
focus_handle: &FocusHandle,
) -> Vec<KeyBinding>
pub fn bindings_for_action_in( &self, action: &dyn Action, focus_handle: &FocusHandle, ) -> Vec<KeyBinding>
Returns any bindings that would invoke an action on the given focus handle if it were focused. Bindings are returned in the order they were added. For display, the last binding should take precedence.
Sourcepub fn highest_precedence_binding_for_action_in(
&self,
action: &dyn Action,
focus_handle: &FocusHandle,
) -> Option<KeyBinding>
pub fn highest_precedence_binding_for_action_in( &self, action: &dyn Action, focus_handle: &FocusHandle, ) -> Option<KeyBinding>
Returns the highest precedence key binding that would invoke an action on the given focus
handle if it were focused. This is more efficient than getting the last result of
bindings_for_action_in.
Sourcepub fn possible_bindings_for_input(
&self,
input: &[Keystroke],
) -> Vec<KeyBinding>
pub fn possible_bindings_for_input( &self, input: &[Keystroke], ) -> Vec<KeyBinding>
Find the bindings that can follow the current input sequence for the current context stack.
Sourcepub fn listener_for<T: 'static, E>(
&self,
view: &Entity<T>,
f: impl Fn(&mut T, &E, &mut Window, &mut Context<'_, T>) + 'static,
) -> impl Fn(&E, &mut Window, &mut App) + 'static
pub fn listener_for<T: 'static, E>( &self, view: &Entity<T>, f: impl Fn(&mut T, &E, &mut Window, &mut Context<'_, T>) + 'static, ) -> impl Fn(&E, &mut Window, &mut App) + 'static
Returns a generic event listener that invokes the given listener with the view and context associated with the given view handle.
Sourcepub fn handler_for<E: 'static, Callback: Fn(&mut E, &mut Window, &mut Context<'_, E>) + 'static>(
&self,
entity: &Entity<E>,
f: Callback,
) -> impl Fn(&mut Window, &mut App) + 'static
pub fn handler_for<E: 'static, Callback: Fn(&mut E, &mut Window, &mut Context<'_, E>) + 'static>( &self, entity: &Entity<E>, f: Callback, ) -> impl Fn(&mut Window, &mut App) + 'static
Returns a generic handler that invokes the given handler with the view and context associated with the given view handle.
Sourcepub fn on_window_should_close(
&self,
cx: &App,
f: impl Fn(&mut Window, &mut App) -> bool + 'static,
)
pub fn on_window_should_close( &self, cx: &App, f: impl Fn(&mut Window, &mut App) -> bool + 'static, )
Register a callback that can interrupt the closing of the current window based the returned boolean. If the callback returns false, the window won’t be closed.
Sourcepub fn on_action(
&mut self,
action_type: TypeId,
listener: impl Fn(&dyn Any, DispatchPhase, &mut Window, &mut App) + 'static,
)
pub fn on_action( &mut self, action_type: TypeId, listener: impl Fn(&dyn Any, DispatchPhase, &mut Window, &mut App) + 'static, )
Register an action listener on this node for the next frame. The type of action is determined by the first parameter of the given listener. When the next frame is rendered the listener will be cleared.
This is a fairly low-level method, so prefer using action handlers on elements unless you have a specific need to register a listener yourself.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn on_action_when(
&mut self,
condition: bool,
action_type: TypeId,
listener: impl Fn(&dyn Any, DispatchPhase, &mut Window, &mut App) + 'static,
)
pub fn on_action_when( &mut self, condition: bool, action_type: TypeId, listener: impl Fn(&dyn Any, DispatchPhase, &mut Window, &mut App) + 'static, )
Register a capturing action listener on this node for the next frame if the condition is true. The type of action is determined by the first parameter of the given listener. When the next frame is rendered the listener will be cleared.
This is a fairly low-level method, so prefer using action handlers on elements unless you have a specific need to register a listener yourself.
This method should only be called as part of the paint phase of element drawing.
Sourcepub fn gpu_specs(&self) -> Option<GpuSpecs>
pub fn gpu_specs(&self) -> Option<GpuSpecs>
Read information about the GPU backing this window. Currently returns None on Mac and Windows.
Sourcepub fn titlebar_double_click(&self)
pub fn titlebar_double_click(&self)
Perform titlebar double-click action. This is macOS specific.
Sourcepub fn window_title(&self) -> String
pub fn window_title(&self) -> String
Gets the window’s title at the platform level. This is macOS specific.
Sourcepub fn tabbed_windows(&self) -> Option<Vec<SystemWindowTab>>
pub fn tabbed_windows(&self) -> Option<Vec<SystemWindowTab>>
Returns a list of all tabbed windows and their titles. This is macOS specific.
Sourcepub fn tab_bar_visible(&self) -> bool
pub fn tab_bar_visible(&self) -> bool
Returns the tab bar visibility. This is macOS specific.
Sourcepub fn merge_all_windows(&self)
pub fn merge_all_windows(&self)
Merges all open windows into a single tabbed window. This is macOS specific.
Sourcepub fn move_tab_to_new_window(&self)
pub fn move_tab_to_new_window(&self)
Moves the tab to a new containing window. This is macOS specific.
Sourcepub fn toggle_window_tab_overview(&self)
pub fn toggle_window_tab_overview(&self)
Shows or hides the window tab overview. This is macOS specific.
Sourcepub fn set_tabbing_identifier(&self, tabbing_identifier: Option<String>)
pub fn set_tabbing_identifier(&self, tabbing_identifier: Option<String>)
Sets the tabbing identifier for the window. This is macOS specific.
Sourcepub fn play_system_bell(&self)
pub fn play_system_bell(&self)
Request the OS to play an alert sound. On some platforms this is associated with the window, for others it’s just a simple global function call.
Sourcepub fn is_a11y_enabled(&self) -> bool
pub fn is_a11y_enabled(&self) -> bool
Returns whether accessibility support is enabled for this window.
This is false when the app was created with crate::Application::new_inaccessible.
Unlike Self::is_a11y_active, this does not depend on whether assistive
technology is currently connected, so it can be used to gate subscriptions
that are only needed for accessibility.
Sourcepub fn is_a11y_active(&self) -> bool
pub fn is_a11y_active(&self) -> bool
Returns whether accessibility features are active for this frame, i.e. whether assistive technology (such as a screen reader) is connected and an accessibility tree is being built.
Use this to skip computing data during rendering that is only observable through the accessibility tree. When accessibility is activated, a redraw is forced, so gated work is recomputed before the next tree update is sent to the platform.
See the accessibility guide for an overview.
Sourcepub fn debug_a11y_tree_json(&self) -> Option<String>
pub fn debug_a11y_tree_json(&self) -> Option<String>
Debug representation of the last frame’s accessibility information.
Sourcepub fn on_a11y_action(
&mut self,
node_id: NodeId,
action: Action,
listener: impl FnMut(Option<&ActionData>, &mut Window, &mut App) + 'static,
)
pub fn on_a11y_action( &mut self, node_id: NodeId, action: Action, listener: impl FnMut(Option<&ActionData>, &mut Window, &mut App) + 'static, )
Register a listener for an accessibility action on a specific node.
The listener will be called when a screen reader requests the given
action on the node identified by node_id.
See the accessibility guide for an overview.
Sourcepub fn toggle_inspector(&mut self, cx: &mut App)
pub fn toggle_inspector(&mut self, cx: &mut App)
Toggles the inspector mode on this window.
Sourcepub fn is_inspector_picking(&self, _cx: &App) -> bool
pub fn is_inspector_picking(&self, _cx: &App) -> bool
Returns true if the window is in inspector mode.
Sourcepub fn with_inspector_state<T: 'static, R>(
&mut self,
inspector_id: Option<&InspectorElementId>,
cx: &mut App,
f: impl FnOnce(&mut Option<T>, &mut Self) -> R,
) -> Option<R>
pub fn with_inspector_state<T: 'static, R>( &mut self, inspector_id: Option<&InspectorElementId>, cx: &mut App, f: impl FnOnce(&mut Option<T>, &mut Self) -> R, ) -> Option<R>
Executes the provided function with mutable access to an inspector state.
Sourcepub fn insert_inspector_hitbox(
&mut self,
hitbox_id: HitboxId,
inspector_id: Option<&InspectorElementId>,
cx: &App,
)
pub fn insert_inspector_hitbox( &mut self, hitbox_id: HitboxId, inspector_id: Option<&InspectorElementId>, cx: &App, )
Registers a hitbox that can be used for inspector picking mode, allowing users to select and inspect UI elements by clicking on them.
Trait Implementations§
Source§impl HasDisplayHandle for Window
impl HasDisplayHandle for Window
Source§fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
Source§impl HasWindowHandle for Window
impl HasWindowHandle for Window
Source§fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
Auto Trait Implementations§
impl !Freeze for Window
impl !RefUnwindSafe for Window
impl !Send for Window
impl !Sync for Window
impl !UnwindSafe for Window
impl Forget for Window
impl Move for Window
impl Unpin for Window
impl UnsafeUnpin for Window
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> HasRawDisplayHandle for Twhere
T: HasDisplayHandle + ?Sized,
impl<T> HasRawDisplayHandle for Twhere
T: HasDisplayHandle + ?Sized,
Source§fn raw_display_handle(&self) -> Result<RawDisplayHandle, HandleError>
fn raw_display_handle(&self) -> Result<RawDisplayHandle, HandleError>
Use HasDisplayHandle instead
Source§impl<T> HasRawWindowHandle for Twhere
T: HasWindowHandle + ?Sized,
impl<T> HasRawWindowHandle for Twhere
T: HasWindowHandle + ?Sized,
Source§fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>
fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>
Use HasWindowHandle instead
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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