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§
fn app_mut(&mut self) -> &mut AppContext
fn app(&self) -> &AppContext
fn window(&self) -> &Window
fn window_mut(&mut self) -> &mut Window
sourcefn with_element_id<R>(
&mut self,
id: Option<impl Into<ElementId>>,
f: impl FnOnce(&mut Self) -> R
) -> R
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.
sourcefn with_content_mask<R>(
&mut self,
mask: Option<ContentMask<Pixels>>,
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
Invoke the given function with the given content mask after intersecting it with the current mask.
sourcefn with_element_offset<R>(
&mut self,
offset: Point<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
Update the global element offset relative to the current offset. This is used to implement scrolling.
sourcefn with_absolute_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
Update the global element offset based on the given offset. This is used to implement drag handles and other manual painting of elements.
sourcefn element_offset(&self) -> Point<Pixels>
fn element_offset(&self) -> Point<Pixels>
Obtain the current element offset.
sourcefn with_element_state<S, R>(
&mut self,
id: ElementId,
f: impl FnOnce(Option<S>, &mut Self) -> (R, S)
) -> Rwhere
S: 'static,
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.
sourcefn with_optional_element_state<S, R>(
&mut self,
element_id: Option<ElementId>,
f: impl FnOnce(Option<S>, &mut Self) -> (R, S)
) -> Rwhere
S: 'static,
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.
sourcefn content_mask(&self) -> ContentMask<Pixels>
fn content_mask(&self) -> ContentMask<Pixels>
Obtain the current content mask.