Trait gpui2::BorrowWindow

source ·
pub trait BorrowWindow: BorrowMut<Window> + BorrowMut<AppContext> {
Show 13 methods // Provided methods fn app_mut(&mut self) -> &mut AppContext { ... } fn app(&self) -> &AppContext { ... } fn window(&self) -> &Window { ... } fn window_mut(&mut self) -> &mut Window { ... } fn with_element_id<R>( &mut self, id: Option<impl Into<ElementId>>, f: impl FnOnce(&mut Self) -> R ) -> R { ... } fn with_content_mask<R>( &mut self, mask: Option<ContentMask<Pixels>>, f: impl FnOnce(&mut Self) -> R ) -> R { ... } fn with_element_offset<R>( &mut self, offset: Point<Pixels>, f: impl FnOnce(&mut Self) -> R ) -> R { ... } fn with_absolute_element_offset<R>( &mut self, offset: Point<Pixels>, f: impl FnOnce(&mut Self) -> R ) -> R { ... } fn element_offset(&self) -> Point<Pixels> { ... } fn with_element_state<S, R>( &mut self, id: ElementId, f: impl FnOnce(Option<S>, &mut Self) -> (R, S) ) -> R where S: 'static { ... } fn with_optional_element_state<S, R>( &mut self, element_id: Option<ElementId>, f: impl FnOnce(Option<S>, &mut Self) -> (R, S) ) -> R where S: 'static { ... } fn content_mask(&self) -> ContentMask<Pixels> { ... } fn rem_size(&self) -> Pixels { ... }
}

Provided Methods§

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.

Implementors§