gpui: Update docs to reflect removal of View, ViewContext, WindowContext (#24008)

This PR updates function signatures, docstrings, and gpui's other
documentation to reflect it's new state following the merge of `Model`
and `View` into `Entity` as well as the removal of `WindowContext`.

Release Notes:

- N/A
This commit is contained in:
someone13574
2025-01-31 11:40:42 -08:00
committed by GitHub
parent 027fe1b4b5
commit 0c94bdc8e4
25 changed files with 330 additions and 329 deletions
+45 -45
View File
@@ -84,7 +84,7 @@ impl Interactivity {
/// Bind the given callback to the mouse down event for the given mouse button, during the bubble phase
/// The imperative API equivalent of [`InteractiveElement::on_mouse_down`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to the view state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to the view state from this callback.
pub fn on_mouse_down(
&mut self,
button: MouseButton,
@@ -104,7 +104,7 @@ impl Interactivity {
/// Bind the given callback to the mouse down event for any button, during the capture phase
/// The imperative API equivalent of [`InteractiveElement::capture_any_mouse_down`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn capture_any_mouse_down(
&mut self,
listener: impl Fn(&MouseDownEvent, &mut Window, &mut App) + 'static,
@@ -120,7 +120,7 @@ impl Interactivity {
/// Bind the given callback to the mouse down event for any button, during the bubble phase
/// the imperative API equivalent to [`InteractiveElement::on_any_mouse_down`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_any_mouse_down(
&mut self,
listener: impl Fn(&MouseDownEvent, &mut Window, &mut App) + 'static,
@@ -136,7 +136,7 @@ impl Interactivity {
/// Bind the given callback to the mouse up event for the given button, during the bubble phase
/// the imperative API equivalent to [`InteractiveElement::on_mouse_up`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_mouse_up(
&mut self,
button: MouseButton,
@@ -156,7 +156,7 @@ impl Interactivity {
/// Bind the given callback to the mouse up event for any button, during the capture phase
/// the imperative API equivalent to [`InteractiveElement::capture_any_mouse_up`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn capture_any_mouse_up(
&mut self,
listener: impl Fn(&MouseUpEvent, &mut Window, &mut App) + 'static,
@@ -172,7 +172,7 @@ impl Interactivity {
/// Bind the given callback to the mouse up event for any button, during the bubble phase
/// the imperative API equivalent to [`Interactivity::on_any_mouse_up`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_any_mouse_up(
&mut self,
listener: impl Fn(&MouseUpEvent, &mut Window, &mut App) + 'static,
@@ -189,7 +189,7 @@ impl Interactivity {
/// when the mouse is outside of the bounds of this element.
/// The imperative API equivalent to [`InteractiveElement::on_mouse_down_out`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_mouse_down_out(
&mut self,
listener: impl Fn(&MouseDownEvent, &mut Window, &mut App) + 'static,
@@ -206,7 +206,7 @@ impl Interactivity {
/// when the mouse is outside of the bounds of this element.
/// The imperative API equivalent to [`InteractiveElement::on_mouse_up_out`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_mouse_up_out(
&mut self,
button: MouseButton,
@@ -226,7 +226,7 @@ impl Interactivity {
/// Bind the given callback to the mouse move event, during the bubble phase
/// The imperative API equivalent to [`InteractiveElement::on_mouse_move`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_mouse_move(
&mut self,
listener: impl Fn(&MouseMoveEvent, &mut Window, &mut App) + 'static,
@@ -245,7 +245,7 @@ impl Interactivity {
/// UIs that don't conform to a drag and drop style interaction, like resizing.
/// The imperative API equivalent to [`InteractiveElement::on_drag_move`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_drag_move<T>(
&mut self,
listener: impl Fn(&DragMoveEvent<T>, &mut Window, &mut App) + 'static,
@@ -276,7 +276,7 @@ impl Interactivity {
/// Bind the given callback to scroll wheel events during the bubble phase
/// The imperative API equivalent to [`InteractiveElement::on_scroll_wheel`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_scroll_wheel(
&mut self,
listener: impl Fn(&ScrollWheelEvent, &mut Window, &mut App) + 'static,
@@ -292,7 +292,7 @@ impl Interactivity {
/// Bind the given callback to an action dispatch during the capture phase
/// The imperative API equivalent to [`InteractiveElement::capture_action`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn capture_action<A: Action>(
&mut self,
listener: impl Fn(&A, &mut Window, &mut App) + 'static,
@@ -313,7 +313,7 @@ impl Interactivity {
/// Bind the given callback to an action dispatch during the bubble phase
/// The imperative API equivalent to [`InteractiveElement::on_action`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_action<A: Action>(&mut self, listener: impl Fn(&A, &mut Window, &mut App) + 'static) {
self.action_listeners.push((
TypeId::of::<A>(),
@@ -331,7 +331,7 @@ impl Interactivity {
/// action bindings to their users.
/// The imperative API equivalent to [`InteractiveElement::on_boxed_action`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_boxed_action(
&mut self,
action: &dyn Action,
@@ -351,7 +351,7 @@ impl Interactivity {
/// Bind the given callback to key down events during the bubble phase
/// The imperative API equivalent to [`InteractiveElement::on_key_down`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_key_down(
&mut self,
listener: impl Fn(&KeyDownEvent, &mut Window, &mut App) + 'static,
@@ -367,7 +367,7 @@ impl Interactivity {
/// Bind the given callback to key down events during the capture phase
/// The imperative API equivalent to [`InteractiveElement::capture_key_down`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn capture_key_down(
&mut self,
listener: impl Fn(&KeyDownEvent, &mut Window, &mut App) + 'static,
@@ -383,7 +383,7 @@ impl Interactivity {
/// Bind the given callback to key up events during the bubble phase
/// The imperative API equivalent to [`InteractiveElement::on_key_up`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_key_up(&mut self, listener: impl Fn(&KeyUpEvent, &mut Window, &mut App) + 'static) {
self.key_up_listeners
.push(Box::new(move |event, phase, window, cx| {
@@ -396,7 +396,7 @@ impl Interactivity {
/// Bind the given callback to key up events during the capture phase
/// The imperative API equivalent to [`InteractiveElement::on_key_up`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn capture_key_up(
&mut self,
listener: impl Fn(&KeyUpEvent, &mut Window, &mut App) + 'static,
@@ -412,7 +412,7 @@ impl Interactivity {
/// Bind the given callback to modifiers changing events.
/// The imperative API equivalent to [`InteractiveElement::on_modifiers_changed`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_modifiers_changed(
&mut self,
listener: impl Fn(&ModifiersChangedEvent, &mut Window, &mut App) + 'static,
@@ -426,7 +426,7 @@ impl Interactivity {
/// Bind the given callback to drop events of the given type, whether or not the drag started on this element
/// The imperative API equivalent to [`InteractiveElement::on_drop`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_drop<T: 'static>(&mut self, listener: impl Fn(&T, &mut Window, &mut App) + 'static) {
self.drop_listeners.push((
TypeId::of::<T>(),
@@ -448,7 +448,7 @@ impl Interactivity {
/// Bind the given callback to click events of this element
/// The imperative API equivalent to [`StatefulInteractiveElement::on_click`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_click(&mut self, listener: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static)
where
Self: Sized,
@@ -464,7 +464,7 @@ impl Interactivity {
/// the [`Self::on_drag_move`] API
/// The imperative API equivalent to [`StatefulInteractiveElement::on_drag`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_drag<T, W>(
&mut self,
value: T,
@@ -490,7 +490,7 @@ impl Interactivity {
/// passed to the callback is true when the hover starts and false when it ends.
/// The imperative API equivalent to [`StatefulInteractiveElement::on_drag`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
pub fn on_hover(&mut self, listener: impl Fn(&bool, &mut Window, &mut App) + 'static)
where
Self: Sized,
@@ -611,7 +611,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to the mouse down event for the given mouse button,
/// the fluent API equivalent to [`Interactivity::on_mouse_down`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to the view state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to the view state from this callback.
fn on_mouse_down(
mut self,
button: MouseButton,
@@ -642,7 +642,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to the mouse down event for any button, during the capture phase
/// the fluent API equivalent to [`Interactivity::capture_any_mouse_down`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn capture_any_mouse_down(
mut self,
listener: impl Fn(&MouseDownEvent, &mut Window, &mut App) + 'static,
@@ -654,7 +654,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to the mouse down event for any button, during the capture phase
/// the fluent API equivalent to [`Interactivity::on_any_mouse_down`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_any_mouse_down(
mut self,
listener: impl Fn(&MouseDownEvent, &mut Window, &mut App) + 'static,
@@ -666,7 +666,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to the mouse up event for the given button, during the bubble phase
/// the fluent API equivalent to [`Interactivity::on_mouse_up`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_mouse_up(
mut self,
button: MouseButton,
@@ -679,7 +679,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to the mouse up event for any button, during the capture phase
/// the fluent API equivalent to [`Interactivity::capture_any_mouse_up`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn capture_any_mouse_up(
mut self,
listener: impl Fn(&MouseUpEvent, &mut Window, &mut App) + 'static,
@@ -692,7 +692,7 @@ pub trait InteractiveElement: Sized {
/// when the mouse is outside of the bounds of this element.
/// The fluent API equivalent to [`Interactivity::on_mouse_down_out`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_mouse_down_out(
mut self,
listener: impl Fn(&MouseDownEvent, &mut Window, &mut App) + 'static,
@@ -705,7 +705,7 @@ pub trait InteractiveElement: Sized {
/// when the mouse is outside of the bounds of this element.
/// The fluent API equivalent to [`Interactivity::on_mouse_up_out`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_mouse_up_out(
mut self,
button: MouseButton,
@@ -718,7 +718,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to the mouse move event, during the bubble phase
/// The fluent API equivalent to [`Interactivity::on_mouse_move`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_mouse_move(
mut self,
listener: impl Fn(&MouseMoveEvent, &mut Window, &mut App) + 'static,
@@ -733,7 +733,7 @@ pub trait InteractiveElement: Sized {
/// UIs that don't conform to a drag and drop style interaction, like resizing.
/// The fluent API equivalent to [`Interactivity::on_drag_move`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_drag_move<T: 'static>(
mut self,
listener: impl Fn(&DragMoveEvent<T>, &mut Window, &mut App) + 'static,
@@ -745,7 +745,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to scroll wheel events during the bubble phase
/// The fluent API equivalent to [`Interactivity::on_scroll_wheel`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_scroll_wheel(
mut self,
listener: impl Fn(&ScrollWheelEvent, &mut Window, &mut App) + 'static,
@@ -757,7 +757,7 @@ pub trait InteractiveElement: Sized {
/// Capture the given action, before normal action dispatch can fire
/// The fluent API equivalent to [`Interactivity::on_scroll_wheel`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn capture_action<A: Action>(
mut self,
listener: impl Fn(&A, &mut Window, &mut App) + 'static,
@@ -769,7 +769,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to an action dispatch during the bubble phase
/// The fluent API equivalent to [`Interactivity::on_action`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_action<A: Action>(
mut self,
listener: impl Fn(&A, &mut Window, &mut App) + 'static,
@@ -783,7 +783,7 @@ pub trait InteractiveElement: Sized {
/// action bindings to their users.
/// The fluent API equivalent to [`Interactivity::on_boxed_action`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_boxed_action(
mut self,
action: &dyn Action,
@@ -796,7 +796,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to key down events during the bubble phase
/// The fluent API equivalent to [`Interactivity::on_key_down`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_key_down(
mut self,
listener: impl Fn(&KeyDownEvent, &mut Window, &mut App) + 'static,
@@ -808,7 +808,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to key down events during the capture phase
/// The fluent API equivalent to [`Interactivity::capture_key_down`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn capture_key_down(
mut self,
listener: impl Fn(&KeyDownEvent, &mut Window, &mut App) + 'static,
@@ -820,7 +820,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to key up events during the bubble phase
/// The fluent API equivalent to [`Interactivity::on_key_up`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_key_up(
mut self,
listener: impl Fn(&KeyUpEvent, &mut Window, &mut App) + 'static,
@@ -832,7 +832,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to key up events during the capture phase
/// The fluent API equivalent to [`Interactivity::capture_key_up`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn capture_key_up(
mut self,
listener: impl Fn(&KeyUpEvent, &mut Window, &mut App) + 'static,
@@ -844,7 +844,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to modifiers changing events.
/// The fluent API equivalent to [`Interactivity::on_modifiers_changed`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_modifiers_changed(
mut self,
listener: impl Fn(&ModifiersChangedEvent, &mut Window, &mut App) + 'static,
@@ -891,7 +891,7 @@ pub trait InteractiveElement: Sized {
/// Bind the given callback to drop events of the given type, whether or not the drag started on this element
/// The fluent API equivalent to [`Interactivity::on_drop`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_drop<T: 'static>(
mut self,
listener: impl Fn(&T, &mut Window, &mut App) + 'static,
@@ -992,7 +992,7 @@ pub trait StatefulInteractiveElement: InteractiveElement {
/// Bind the given callback to click events of this element
/// The fluent API equivalent to [`Interactivity::on_click`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_click(mut self, listener: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static) -> Self
where
Self: Sized,
@@ -1007,7 +1007,7 @@ pub trait StatefulInteractiveElement: InteractiveElement {
/// The callback also has access to the offset of triggering click from the origin of parent element.
/// The fluent API equivalent to [`Interactivity::on_drag`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_drag<T, W>(
mut self,
value: T,
@@ -1026,7 +1026,7 @@ pub trait StatefulInteractiveElement: InteractiveElement {
/// passed to the callback is true when the hover starts and false when it ends.
/// The fluent API equivalent to [`Interactivity::on_hover`]
///
/// See [`ViewContext::listener`](crate::ViewContext::listener) to get access to a view's state from this callback.
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
fn on_hover(mut self, listener: impl Fn(&bool, &mut Window, &mut App) + 'static) -> Self
where
Self: Sized,