Struct gpui2::ViewContext

source ·
pub struct ViewContext<'a, V> { /* private fields */ }

Implementations§

source§

impl<'a, V: 'static> ViewContext<'a, V>

source

pub fn entity_id(&self) -> EntityId

source

pub fn view(&self) -> &View<V>

source

pub fn model(&self) -> &Model<V>

source

pub fn window_context(&mut self) -> &mut WindowContext<'a>

Access the underlying window context.

source

pub fn with_z_index<R>( &mut self, z_index: u32, f: impl FnOnce(&mut Self) -> R ) -> R

source

pub fn on_next_frame( &mut self, f: impl FnOnce(&mut V, &mut ViewContext<'_, V>) + 'static )where V: 'static,

source

pub fn defer( &mut self, f: impl FnOnce(&mut V, &mut ViewContext<'_, V>) + '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.

source

pub fn observe<V2, E>( &mut self, entity: &E, on_notify: impl FnMut(&mut V, E, &mut ViewContext<'_, V>) + 'static ) -> Subscriptionwhere V2: 'static, V: 'static, E: Entity<V2>,

source

pub fn subscribe<V2, E, Evt>( &mut self, entity: &E, on_event: impl FnMut(&mut V, E, &Evt, &mut ViewContext<'_, V>) + 'static ) -> Subscriptionwhere V2: EventEmitter<Evt>, E: Entity<V2>, Evt: 'static,

source

pub fn on_release( &mut self, on_release: impl FnOnce(&mut V, &mut WindowContext<'_>) + 'static ) -> Subscription

source

pub fn observe_release<V2, E>( &mut self, entity: &E, on_release: impl FnMut(&mut V, &mut V2, &mut ViewContext<'_, V>) + 'static ) -> Subscriptionwhere V: 'static, V2: 'static, E: Entity<V2>,

source

pub fn notify(&mut self)

source

pub fn observe_window_bounds( &mut self, callback: impl FnMut(&mut V, &mut ViewContext<'_, V>) + 'static ) -> Subscription

source

pub fn observe_window_activation( &mut self, callback: impl FnMut(&mut V, &mut ViewContext<'_, V>) + 'static ) -> Subscription

source

pub fn on_focus( &mut self, handle: &FocusHandle, listener: impl FnMut(&mut V, &mut ViewContext<'_, V>) + 'static ) -> Subscription

Register a listener to be called when the given focus handle receives focus. Unlike [on_focus_changed], returns a subscription and persists until the subscription is dropped.

source

pub fn on_focus_in( &mut self, handle: &FocusHandle, listener: impl FnMut(&mut V, &mut ViewContext<'_, V>) + 'static ) -> Subscription

Register a listener to be called when the given focus handle or one of its descendants receives focus. Unlike [on_focus_changed], returns a subscription and persists until the subscription is dropped.

source

pub fn on_blur( &mut self, handle: &FocusHandle, listener: impl FnMut(&mut V, &mut ViewContext<'_, V>) + 'static ) -> Subscription

Register a listener to be called when the given focus handle loses focus. Unlike [on_focus_changed], returns a subscription and persists until the subscription is dropped.

source

pub fn on_focus_out( &mut self, handle: &FocusHandle, listener: impl FnMut(&mut V, &mut ViewContext<'_, V>) + 'static ) -> Subscription

Register a listener to be called when the given focus handle or one of its descendants loses focus. Unlike [on_focus_changed], returns a subscription and persists until the subscription is dropped.

source

pub fn spawn<Fut, R>( &mut self, f: impl FnOnce(WeakView<V>, AsyncWindowContext) -> Fut ) -> Task<R> where R: 'static, Fut: Future<Output = R> + 'static,

source

pub fn update_global<G, R>( &mut self, f: impl FnOnce(&mut G, &mut Self) -> R ) -> Rwhere G: 'static,

source

pub fn observe_global<G: 'static>( &mut self, f: impl FnMut(&mut V, &mut ViewContext<'_, V>) + 'static ) -> Subscription

source

pub fn on_mouse_event<Event: 'static>( &mut self, handler: impl Fn(&mut V, &Event, DispatchPhase, &mut ViewContext<'_, V>) + 'static )

source

pub fn on_key_event<Event: 'static>( &mut self, handler: impl Fn(&mut V, &Event, DispatchPhase, &mut ViewContext<'_, V>) + 'static )

source

pub fn on_action( &mut self, action_type: TypeId, handler: impl Fn(&mut V, &dyn Any, DispatchPhase, &mut ViewContext<'_, V>) + 'static )

source

pub fn emit<Evt>(&mut self, event: Evt)where Evt: 'static, V: EventEmitter<Evt>,

source

pub fn focus_self(&mut self)where V: FocusableView,

source

pub fn dismiss_self(&mut self)where V: ManagedView,

source

pub fn listener<E>( &self, f: impl Fn(&mut V, &E, &mut ViewContext<'_, V>) + 'static ) -> impl Fn(&E, &mut WindowContext<'_>) + 'static

Methods from Deref<Target = WindowContext<'a>>§

source

pub fn window_handle(&self) -> AnyWindowHandle

Obtain a handle to the window that belongs to this context.

source

pub fn notify(&mut self)

Mark the window as dirty, scheduling it to be redrawn on the next frame.

source

pub fn remove_window(&mut self)

Close this window.

source

pub fn focus_handle(&mut self) -> FocusHandle

Obtain a new FocusHandle, which allows you to track and manipulate the keyboard focus for elements rendered within this window.

source

pub fn focused(&self) -> Option<FocusHandle>

Obtain the currently focused FocusHandle. If no elements are focused, returns None.

source

pub fn focus(&mut self, handle: &FocusHandle)

Move focus to the element associated with the given FocusHandle.

source

pub fn blur(&mut self)

Remove focus from all elements within this context’s window.

source

pub fn dispatch_action(&mut self, action: Box<dyn Action>)

source

pub fn defer(&mut self, f: impl FnOnce(&mut WindowContext<'_>) + '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.

source

pub fn subscribe<Emitter, E, Evt>( &mut self, entity: &E, on_event: impl FnMut(E, &Evt, &mut WindowContext<'_>) + 'static ) -> Subscriptionwhere Emitter: EventEmitter<Evt>, E: Entity<Emitter>, Evt: 'static,

source

pub fn to_async(&self) -> AsyncWindowContext

Create an AsyncWindowContext, which has a static lifetime and can be held across await points in async code.

source

pub fn on_next_frame( &mut self, callback: impl FnOnce(&mut WindowContext<'_>) + 'static )

Schedule the given closure to be run directly after the current frame is rendered.

source

pub fn spawn<Fut, R>( &mut self, f: impl FnOnce(AsyncWindowContext) -> Fut ) -> Task<R> where R: 'static, Fut: Future<Output = 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.

source

pub fn update_global<G, R>( &mut self, f: impl FnOnce(&mut G, &mut Self) -> R ) -> Rwhere G: 'static,

Update the global of the given type. The given closure is given simultaneous mutable access both to the global and the context.

source

pub fn request_layout( &mut self, style: &Style, children: impl IntoIterator<Item = LayoutId> ) -> 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::layout trait method and enables any element to participate in layout.

source

pub fn request_measured_layout<F: Fn(Size<Option<Pixels>>, Size<AvailableSpace>) -> Size<Pixels> + Send + Sync + 'static>( &mut self, style: Style, rem_size: Pixels, 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.

source

pub fn compute_layout( &mut self, layout_id: LayoutId, available_space: Size<AvailableSpace> )

source

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 should not be invoked until the paint phase begins, and will usually be invoked by GPUI itself automatically in order to pass your element its Bounds automatically.

source

pub fn window_bounds(&self) -> WindowBounds

source

pub fn viewport_size(&self) -> Size<Pixels>

source

pub fn is_window_active(&self) -> bool

source

pub fn zoom_window(&self)

source

pub fn display(&self) -> Option<Rc<dyn PlatformDisplay>>

source

pub fn show_character_palette(&self)

source

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.

source

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.

source

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.

source

pub fn line_height(&self) -> Pixels

The line height associated with the current text style.

source

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.

source

pub fn default_prevented(&self) -> bool

Obtain whether default has been prevented for the event currently being dispatched.

source

pub fn on_mouse_event<Event: 'static>( &mut self, handler: impl Fn(&Event, DispatchPhase, &mut WindowContext<'_>) + 'static )

Register a mouse event listener on the window for the current 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 global listener.

source

pub fn on_key_event<Event: 'static>( &mut self, handler: impl Fn(&Event, DispatchPhase, &mut WindowContext<'_>) + 'static )

Register a key event listener on the window for the current 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 global listener.

source

pub fn on_action( &mut self, action_type: TypeId, handler: impl Fn(&dyn Any, DispatchPhase, &mut WindowContext<'_>) + 'static )

Register an action listener on the window for the current 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 global listener.

source

pub fn mouse_position(&self) -> Point<Pixels>

The position of the mouse relative to the window.

source

pub fn set_cursor_style(&mut self, style: CursorStyle)

source

pub fn with_z_index<R>( &mut self, z_index: u32, f: impl FnOnce(&mut Self) -> R ) -> R

Called during painting to invoke the given closure in a new stacking context. The given z-index is interpreted relative to the previous call to stack.

source

pub fn paint_shadows( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, shadows: &[BoxShadow] )

Paint one or more drop shadows into the scene for the current frame at the current z-index.

source

pub fn paint_quad( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, background: impl Into<Hsla>, border_widths: Edges<Pixels>, border_color: impl Into<Hsla> )

Paint one or more quads into the scene for the current frame at the current stacking context. Quads are colored rectangular regions with an optional background, border, and corner radius.

source

pub fn paint_path(&mut self, path: Path<Pixels>, color: impl Into<Hsla>)

Paint the given Path into the scene for the current frame at the current z-index.

source

pub fn paint_underline( &mut self, origin: Point<Pixels>, width: Pixels, style: &UnderlineStyle ) -> Result<()>

Paint an underline into the scene for the current frame at the current z-index.

source

pub fn paint_glyph( &mut self, origin: Point<Pixels>, font_id: FontId, glyph_id: GlyphId, font_size: Pixels, color: Hsla ) -> Result<()>

Paint a monochrome (non-emoji) glyph into the scene for the current frame at the current z-index. The y component of the origin is the baseline of the glyph.

source

pub fn paint_emoji( &mut self, origin: Point<Pixels>, font_id: FontId, glyph_id: GlyphId, font_size: Pixels ) -> Result<()>

Paint an emoji glyph into the scene for the current frame at the current z-index. The y component of the origin is the baseline of the glyph.

source

pub fn paint_svg( &mut self, bounds: Bounds<Pixels>, path: SharedString, color: Hsla ) -> Result<()>

Paint a monochrome SVG into the scene for the current frame at the current stacking context.

source

pub fn paint_image( &mut self, bounds: Bounds<Pixels>, corner_radii: Corners<Pixels>, data: Arc<ImageData>, grayscale: bool ) -> Result<()>

Paint an image into the scene for the current frame at the current z-index.

source

pub fn dispatch_event(&mut self, event: InputEvent) -> bool

Dispatch a mouse or keyboard event on the window.

source

pub fn observe_global<G: 'static>( &mut self, f: impl Fn(&mut WindowContext<'_>) + 'static ) -> Subscription

Register the given handler to be invoked whenever the global of the given type is updated.

source

pub fn activate_window(&self)

source

pub fn minimize_window(&self)

source

pub fn toggle_full_screen(&self)

source

pub fn prompt( &self, level: PromptLevel, msg: &str, answers: &[&str] ) -> Receiver<usize>

source

pub fn available_actions(&self) -> Vec<Box<dyn Action>>

source

pub fn bindings_for_action(&self, action: &dyn Action) -> Vec<KeyBinding>

source

pub fn listener_for<V: Render, E>( &self, view: &View<V>, f: impl Fn(&mut V, &E, &mut ViewContext<'_, V>) + 'static ) -> impl Fn(&E, &mut WindowContext<'_>) + 'static

source

pub fn constructor_for<V: Render, R>( &self, view: &View<V>, f: impl Fn(&mut V, &mut ViewContext<'_, V>) -> R + 'static ) -> impl Fn(&mut WindowContext<'_>) -> R + 'static

source

pub fn with_key_dispatch<R>( &mut self, context: KeyContext, focus_handle: Option<FocusHandle>, f: impl FnOnce(Option<FocusHandle>, &mut Self) -> R ) -> R

source

pub fn on_focus_changed( &mut self, listener: impl Fn(&FocusEvent, &mut WindowContext<'_>) + 'static )

Register a focus listener for the current frame only. It will be cleared on the next frame render. You should use this method only from within elements, and we may want to enforce that better via a different context type.

source

pub fn handle_input( &mut self, focus_handle: &FocusHandle, input_handler: impl PlatformInputHandler )

Set an input handler, such as [ElementInputHandler], which interfaces with the platform to receive textual input with proper integration with concerns such as IME interactions.

Methods from Deref<Target = AppContext>§

source

pub fn shutdown(&mut self)

Quit the application gracefully. Handlers registered with ModelContext::on_app_quit will be given 100ms to complete before exiting.

source

pub fn quit(&mut self)

source

pub fn app_metadata(&self) -> AppMetadata

source

pub fn refresh(&mut self)

Schedules all windows in the application to be redrawn. This can be called multiple times in an update cycle and still result in a single redraw.

source

pub fn observe<W, E>( &mut self, entity: &E, on_notify: impl FnMut(E, &mut AppContext) + 'static ) -> Subscriptionwhere W: 'static, E: Entity<W>,

source

pub fn observe_internal<W, E>( &mut self, entity: &E, on_notify: impl FnMut(E, &mut AppContext) -> bool + 'static ) -> Subscriptionwhere W: 'static, E: Entity<W>,

source

pub fn subscribe<T, E, Evt>( &mut self, entity: &E, on_event: impl FnMut(E, &Evt, &mut AppContext) + 'static ) -> Subscriptionwhere T: 'static + EventEmitter<Evt>, E: Entity<T>, Evt: 'static,

source

pub fn windows(&self) -> Vec<AnyWindowHandle>

source

pub fn open_window<V: 'static + Render>( &mut self, options: WindowOptions, build_root_view: impl FnOnce(&mut WindowContext<'_>) -> View<V> ) -> WindowHandle<V>

Opens a new window with the given option and the root view returned by the given function. The function is invoked with a WindowContext, which can be used to interact with window-specific functionality.

source

pub fn activate(&self, ignoring_other_apps: bool)

Instructs the platform to activate the application by bringing it to the foreground.

source

pub fn hide(&self)

source

pub fn hide_other_apps(&self)

source

pub fn unhide_other_apps(&self)

source

pub fn displays(&self) -> Vec<Rc<dyn PlatformDisplay>>

Returns the list of currently active displays.

source

pub fn write_to_clipboard(&self, item: ClipboardItem)

Writes data to the platform clipboard.

source

pub fn read_from_clipboard(&self) -> Option<ClipboardItem>

Reads data from the platform clipboard.

source

pub fn write_credentials( &self, url: &str, username: &str, password: &[u8] ) -> Result<()>

Writes credentials to the platform keychain.

source

pub fn read_credentials(&self, url: &str) -> Result<Option<(String, Vec<u8>)>>

Reads credentials from the platform keychain.

source

pub fn delete_credentials(&self, url: &str) -> Result<()>

Deletes credentials from the platform keychain.

source

pub fn open_url(&self, url: &str)

Directs the platform’s default browser to open the given URL.

source

pub fn app_path(&self) -> Result<PathBuf>

source

pub fn path_for_auxiliary_executable(&self, name: &str) -> Result<PathBuf>

source

pub fn prompt_for_paths( &self, options: PathPromptOptions ) -> Receiver<Option<Vec<PathBuf>>>

source

pub fn prompt_for_new_path(&self, directory: &Path) -> Receiver<Option<PathBuf>>

source

pub fn reveal_path(&self, path: &Path)

source

pub fn should_auto_hide_scrollbars(&self) -> bool

source

pub fn to_async(&self) -> AsyncAppContext

Creates an AsyncAppContext, which can be cloned and has a static lifetime so it can be held across await points.

source

pub fn background_executor(&self) -> &BackgroundExecutor

Obtains a reference to the executor, which can be used to spawn futures.

source

pub fn foreground_executor(&self) -> &ForegroundExecutor

Obtains a reference to the executor, which can be used to spawn futures.

source

pub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncAppContext) -> Fut) -> Task<R> where Fut: Future<Output = R> + 'static, R: 'static,

Spawns the future returned by the given function on the thread pool. The closure will be invoked with AsyncAppContext, which allows the application state to be accessed across await points.

source

pub fn defer(&mut self, f: impl FnOnce(&mut AppContext) + '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.

source

pub fn asset_source(&self) -> &Arc<dyn AssetSource>

Accessor for the application’s asset source, which is provided when constructing the App.

source

pub fn text_system(&self) -> &Arc<TextSystem>

Accessor for the text system.

source

pub fn text_style(&self) -> TextStyle

The current text style. Which is composed of all the style refinements provided to with_text_style.

source

pub fn has_global<G: 'static>(&self) -> bool

Check whether a global of the given type has been assigned.

source

pub fn global<G: 'static>(&self) -> &G

Access the global of the given type. Panics if a global for that type has not been assigned.

source

pub fn try_global<G: 'static>(&self) -> Option<&G>

Access the global of the given type if a value has been assigned.

source

pub fn global_mut<G: 'static>(&mut self) -> &mut G

Access the global of the given type mutably. Panics if a global for that type has not been assigned.

source

pub fn default_global<G: 'static + Default>(&mut self) -> &mut G

Access the global of the given type mutably. A default value is assigned if a global of this type has not yet been assigned.

source

pub fn set_global<G: Any>(&mut self, global: G)

Set the value of the global of the given type.

source

pub fn update_global<G: 'static, R>( &mut self, f: impl FnOnce(&mut G, &mut Self) -> R ) -> R

Update the global of the given type with a closure. Unlike global_mut, this method provides your closure with mutable access to the AppContext and the global simultaneously.

source

pub fn observe_global<G: 'static>( &mut self, f: impl FnMut(&mut Self) + 'static ) -> Subscription

Register a callback to be invoked when a global of the given type is updated.

source

pub fn observe_new_views<V: 'static>( &mut self, on_new: impl 'static + Fn(&mut V, &mut ViewContext<'_, V>) ) -> Subscription

source

pub fn observe_release<E, T>( &mut self, handle: &E, on_release: impl FnOnce(&mut T, &mut AppContext) + 'static ) -> Subscriptionwhere E: Entity<T>, T: 'static,

source

pub fn bind_keys(&mut self, bindings: impl IntoIterator<Item = KeyBinding>)

Register key bindings.

source

pub fn on_action<A: Action>( &mut self, listener: impl Fn(&A, &mut Self) + 'static )

Register a global listener for actions invoked via the keyboard.

source

pub fn stop_propagation(&mut self)

Event handlers propagate events by default. Call this method to stop dispatching to event handlers with a lower z-index (mouse) or higher in the tree (keyboard). This is the opposite of [propagate]. It’s also possible to cancel a call to [propagate] by calling this method before effects are flushed.

source

pub fn propagate(&mut self)

Action handlers stop propagation by default during the bubble phase of action dispatch dispatching to action handlers higher in the element tree. This is the opposite of [stop_propagation]. It’s also possible to cancel a call to [stop_propagate] by calling this method before effects are flushed.

source

pub fn build_action( &self, name: &str, data: Option<Value> ) -> Result<Box<dyn Action>>

source

pub fn all_action_names(&self) -> &[SharedString]

Trait Implementations§

source§

impl<V> Borrow<AppContext> for ViewContext<'_, V>

source§

fn borrow(&self) -> &AppContext

Immutably borrows from an owned value. Read more
source§

impl<V> Borrow<Window> for ViewContext<'_, V>

source§

fn borrow(&self) -> &Window

Immutably borrows from an owned value. Read more
source§

impl<V> BorrowMut<AppContext> for ViewContext<'_, V>

source§

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

Mutably borrows from an owned value. Read more
source§

impl<V> BorrowMut<Window> for ViewContext<'_, V>

source§

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

Mutably borrows from an owned value. Read more
source§

impl<V> Context for ViewContext<'_, V>

§

type Result<U> = U

source§

fn build_model<T: 'static>( &mut self, build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T ) -> Model<T>

source§

fn update_model<T: 'static, R>( &mut self, model: &Model<T>, update: impl FnOnce(&mut T, &mut ModelContext<'_, T>) -> R ) -> R

source§

fn update_window<T, F>( &mut self, window: AnyWindowHandle, update: F ) -> Result<T>where F: FnOnce(AnyView, &mut WindowContext<'_>) -> T,

source§

fn read_model<T, R>( &self, handle: &Model<T>, read: impl FnOnce(&T, &AppContext) -> R ) -> Self::Result<R>where T: 'static,

source§

fn read_window<T, R>( &self, window: &WindowHandle<T>, read: impl FnOnce(View<T>, &AppContext) -> R ) -> Result<R>where T: 'static,

source§

impl<'a, V> Deref for ViewContext<'a, V>

§

type Target = WindowContext<'a>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a, V> DerefMut for ViewContext<'a, V>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<V: 'static> VisualContext for ViewContext<'_, V>

source§

fn build_view<W: Render + 'static>( &mut self, build_view_state: impl FnOnce(&mut ViewContext<'_, W>) -> W ) -> Self::Result<View<W>>

source§

fn update_view<V2: 'static, R>( &mut self, view: &View<V2>, update: impl FnOnce(&mut V2, &mut ViewContext<'_, V2>) -> R ) -> Self::Result<R>

source§

fn replace_root_view<W>( &mut self, build_view: impl FnOnce(&mut ViewContext<'_, W>) -> W ) -> Self::Result<View<W>>where W: 'static + Render,

source§

fn focus_view<W: FocusableView>(&mut self, view: &View<W>) -> Self::Result<()>

source§

fn dismiss_view<W: ManagedView>(&mut self, view: &View<W>) -> Self::Result<()>

Auto Trait Implementations§

§

impl<'a, V> !RefUnwindSafe for ViewContext<'a, V>

§

impl<'a, V> !Send for ViewContext<'a, V>

§

impl<'a, V> !Sync for ViewContext<'a, V>

§

impl<'a, V> Unpin for ViewContext<'a, V>

§

impl<'a, V> !UnwindSafe for ViewContext<'a, V>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<C> BorrowAppContext for Cwhere C: BorrowMut<AppContext>,

source§

fn with_text_style<F, R>( &mut self, style: Option<TextStyleRefinement>, f: F ) -> Rwhere F: FnOnce(&mut C) -> R,

source§

fn set_global<G>(&mut self, global: G)where G: 'static,

source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowWindow for Twhere T: BorrowMut<AppContext> + BorrowMut<Window>,

source§

fn app_mut(&mut self) -> &mut AppContext

source§

fn app(&self) -> &AppContext

source§

fn window(&self) -> &Window

source§

fn window_mut(&mut self) -> &mut Window

source§

fn with_element_id<R>( &mut self, id: Option<impl Into<ElementId>>, f: impl FnOnce(&mut Self) -> R ) -> R

Pushes the given element id onto the global stack and invokes the given closure with a GlobalElementId, which disambiguates the given id in the context of its ancestor ids. Because elements are discarded and recreated on each frame, the GlobalElementId is used to associate state with identified elements across separate frames.
source§

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.
source§

fn with_element_offset<R>( &mut self, offset: Point<Pixels>, f: impl FnOnce(&mut Self) -> R ) -> R

Update the global element offset relative to the current offset. This is used to implement scrolling.
source§

fn with_absolute_element_offset<R>( &mut self, offset: Point<Pixels>, f: impl FnOnce(&mut Self) -> R ) -> R

Update the global element offset based on the given offset. This is used to implement drag handles and other manual painting of elements.
source§

fn element_offset(&self) -> Point<Pixels>

Obtain the current element offset.
source§

fn with_element_state<S, R>( &mut self, id: ElementId, f: impl FnOnce(Option<S>, &mut Self) -> (R, S) ) -> Rwhere S: 'static,

Update or intialize state for an element with the given id that lives across multiple frames. If an element with this id existed in the previous 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.
source§

fn with_optional_element_state<S, R>( &mut self, element_id: Option<ElementId>, f: impl FnOnce(Option<S>, &mut Self) -> (R, S) ) -> Rwhere S: 'static,

Like with_element_state, but for situations where the element_id is optional. If the id is None, no state will be retrieved or stored.
source§

fn content_mask(&self) -> ContentMask<Pixels>

Obtain the current content mask.
source§

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.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

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

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> WithSubscriber for T

source§

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

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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