WIP

Nathan Sobo created

Change summary

crates/copilot/src/sign_in.rs                      | 57 ++++++++-------
crates/gpui/src/elements.rs                        |  2 
crates/workspace/src/dock.rs                       |  2 
crates/workspace/src/dock/toggle_dock_button.rs    |  2 
crates/workspace/src/item.rs                       | 33 ++++++--
crates/workspace/src/notifications.rs              |  2 
crates/workspace/src/pane.rs                       | 35 ++++++---
crates/workspace/src/pane/dragged_item_receiver.rs | 12 +-
crates/workspace/src/pane_group.rs                 |  6 
crates/workspace/src/shared_screen.rs              |  6 
crates/workspace/src/sidebar.rs                    |  4 
crates/workspace/src/status_bar.rs                 | 26 +++---
crates/workspace/src/toolbar.rs                    |  4 
crates/workspace/src/workspace.rs                  | 11 +-
14 files changed, 119 insertions(+), 83 deletions(-)

Detailed changes

crates/copilot/src/sign_in.rs 🔗

@@ -3,7 +3,8 @@ use gpui::{
     elements::*,
     geometry::rect::RectF,
     platform::{WindowBounds, WindowKind, WindowOptions},
-    AppContext, ClipboardItem, Element, Entity, View, ViewContext, ViewHandle,
+    AnyViewHandle, AppContext, ClipboardItem, Element, ElementBox, Entity, View, ViewContext,
+    ViewHandle,
 };
 use settings::Settings;
 use theme::ui::modal;
@@ -28,9 +29,9 @@ pub fn init(cx: &mut AppContext) {
                 if let Some(code_verification_handle) = code_verification.as_mut() {
                     if cx.has_window(code_verification_handle.window_id()) {
                         code_verification_handle.update(cx, |code_verification_view, cx| {
-                            code_verification_view.set_status(status, cx)
+                            code_verification_view.set_status(status, cx);
+                            cx.activate_window();
                         });
-                        cx.activate_window(code_verification_handle.window_id());
                     } else {
                         create_copilot_auth_window(cx, &status, &mut code_verification);
                     }
@@ -41,11 +42,11 @@ pub fn init(cx: &mut AppContext) {
             Status::Authorized | Status::Unauthorized => {
                 if let Some(code_verification) = code_verification.as_ref() {
                     code_verification.update(cx, |code_verification, cx| {
-                        code_verification.set_status(status, cx)
+                        code_verification.set_status(status, cx);
+                        cx.activate_window();
                     });
 
                     cx.platform().activate(true);
-                    cx.activate_window(code_verification.window_id());
                 }
             }
             _ => {
@@ -96,8 +97,8 @@ impl CopilotCodeVerification {
     fn render_device_code(
         data: &PromptUserDeviceFlow,
         style: &theme::Copilot,
-        cx: &mut gpui::ViewContext<Self>,
-    ) -> ElementBox {
+        cx: &mut ViewContext<Self>,
+    ) -> ElementBox<Self> {
         let copied = cx
             .read_from_clipboard()
             .map(|item| item.text() == &data.user_code)
@@ -105,7 +106,7 @@ impl CopilotCodeVerification {
 
         let device_code_style = &style.auth.prompting.device_code;
 
-        MouseEventHandler::<Self>::new(0, cx, |state, _cx| {
+        MouseEventHandler::<Self, _>::new(0, cx, |state, _cx| {
             Flex::row()
                 .with_children([
                     Label::new(data.user_code.clone(), device_code_style.text.clone())
@@ -132,7 +133,7 @@ impl CopilotCodeVerification {
         })
         .on_click(gpui::platform::MouseButton::Left, {
             let user_code = data.user_code.clone();
-            move |_, cx| {
+            move |_, _, cx| {
                 cx.platform()
                     .write_to_clipboard(ClipboardItem::new(user_code.clone()));
                 cx.notify();
@@ -145,8 +146,10 @@ impl CopilotCodeVerification {
     fn render_prompting_modal(
         data: &PromptUserDeviceFlow,
         style: &theme::Copilot,
-        cx: &mut gpui::ViewContext<Self>,
-    ) -> ElementBox {
+        cx: &mut ViewContext<Self>,
+    ) -> ElementBox<Self> {
+        enum ConnectButton {}
+
         Flex::column()
             .with_children([
                 Flex::column()
@@ -188,14 +191,14 @@ impl CopilotCodeVerification {
                     .contained()
                     .with_style(style.auth.prompting.hint.container.clone())
                     .boxed(),
-                theme::ui::cta_button_with_click(
+                theme::ui::cta_button_with_click::<ConnectButton, _, _, _>(
                     "Connect to GitHub",
                     style.auth.content_width,
                     &style.auth.cta_button,
                     cx,
                     {
                         let verification_uri = data.verification_uri.clone();
-                        move |_, cx| cx.platform().open_url(&verification_uri)
+                        move |_, _, cx| cx.platform().open_url(&verification_uri)
                     },
                 )
                 .boxed(),
@@ -205,8 +208,10 @@ impl CopilotCodeVerification {
     }
     fn render_enabled_modal(
         style: &theme::Copilot,
-        cx: &mut gpui::ViewContext<Self>,
-    ) -> ElementBox {
+        cx: &mut ViewContext<Self>,
+    ) -> ElementBox<Self> {
+        enum DoneButton {}
+
         let enabled_style = &style.auth.authorized;
         Flex::column()
             .with_children([
@@ -237,12 +242,12 @@ impl CopilotCodeVerification {
                     .contained()
                     .with_style(enabled_style.hint.container)
                     .boxed(),
-                theme::ui::cta_button_with_click(
+                theme::ui::cta_button_with_click::<DoneButton, _, _, _>(
                     "Done",
                     style.auth.content_width,
                     &style.auth.cta_button,
                     cx,
-                    |_, cx| {
+                    |_, _, cx| {
                         let window_id = cx.window_id();
                         cx.remove_window(window_id)
                     },
@@ -254,8 +259,8 @@ impl CopilotCodeVerification {
     }
     fn render_unauthorized_modal(
         style: &theme::Copilot,
-        cx: &mut gpui::ViewContext<Self>,
-    ) -> ElementBox {
+        cx: &mut ViewContext<Self>,
+    ) -> ElementBox<Self> {
         let unauthorized_style = &style.auth.not_authorized;
 
         Flex::column()
@@ -298,12 +303,12 @@ impl CopilotCodeVerification {
                     .contained()
                     .with_style(unauthorized_style.warning.container)
                     .boxed(),
-                theme::ui::cta_button_with_click(
+                theme::ui::cta_button_with_click::<CopilotCodeVerification, _, _, _>(
                     "Subscribe on GitHub",
                     style.auth.content_width,
                     &style.auth.cta_button,
                     cx,
-                    |_, cx| {
+                    |_, _, cx| {
                         let window_id = cx.window_id();
                         cx.remove_window(window_id);
                         cx.platform().open_url(COPILOT_SIGN_UP_URL)
@@ -325,18 +330,20 @@ impl View for CopilotCodeVerification {
         "CopilotCodeVerification"
     }
 
-    fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut gpui::ViewContext<Self>) {
+    fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
         cx.notify()
     }
 
-    fn focus_out(&mut self, _: gpui::AnyViewHandle, cx: &mut gpui::ViewContext<Self>) {
+    fn focus_out(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
         cx.notify()
     }
 
-    fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> gpui::ElementBox {
+    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
+        enum ConnectModal {}
+
         let style = cx.global::<Settings>().theme.clone();
 
-        modal("Connect Copilot to Zed", &style.copilot.modal, cx, |cx| {
+        modal::<ConnectModal, _, _, _>("Connect Copilot to Zed", &style.copilot.modal, cx, |cx| {
             Flex::column()
                 .with_children([
                     theme::ui::icon(&style.copilot.auth.header).boxed(),

crates/gpui/src/elements.rs 🔗

@@ -25,6 +25,8 @@ pub use self::{
     keystroke_label::*, label::*, list::*, mouse_event_handler::*, overlay::*, resizable::*,
     stack::*, svg::*, text::*, tooltip::*, uniform_list::*,
 };
+pub use crate::window::ChildView;
+
 use self::{clipped::Clipped, expanded::Expanded};
 use crate::{
     geometry::{

crates/workspace/src/dock.rs 🔗

@@ -315,7 +315,7 @@ impl Dock {
         theme: &Theme,
         anchor: DockAnchor,
         cx: &mut ViewContext<Workspace>,
-    ) -> Option<ElementBox> {
+    ) -> Option<ElementBox<Self>> {
         let style = &theme.workspace.dock;
 
         self.position

crates/workspace/src/dock/toggle_dock_button.rs 🔗

@@ -34,7 +34,7 @@ impl View for ToggleDockButton {
         "Dock Toggle"
     }
 
-    fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> ElementBox {
+    fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> ElementBox<Self> {
         let workspace = self.workspace.upgrade(cx);
 
         if workspace.is_none() {

crates/workspace/src/item.rs 🔗

@@ -47,8 +47,12 @@ pub trait Item: View {
     fn tab_description<'a>(&'a self, _: usize, _: &'a AppContext) -> Option<Cow<'a, str>> {
         None
     }
-    fn tab_content(&self, detail: Option<usize>, style: &theme::Tab, cx: &AppContext)
-        -> ElementBox;
+    fn tab_content(
+        &self,
+        detail: Option<usize>,
+        style: &theme::Tab,
+        cx: &AppContext,
+    ) -> ElementBox<Self>;
     fn for_each_project_item(&self, _: &AppContext, _: &mut dyn FnMut(usize, &dyn project::Item)) {}
     fn is_singleton(&self, _cx: &AppContext) -> bool {
         false
@@ -130,7 +134,7 @@ pub trait Item: View {
         ToolbarItemLocation::Hidden
     }
 
-    fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<ElementBox>> {
+    fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<ElementBox<Self>>> {
         None
     }
 
@@ -163,8 +167,12 @@ pub trait ItemHandle: 'static + fmt::Debug {
         handler: Box<dyn Fn(ItemEvent, &mut AppContext)>,
     ) -> gpui::Subscription;
     fn tab_description<'a>(&self, detail: usize, cx: &'a AppContext) -> Option<Cow<'a, str>>;
-    fn tab_content(&self, detail: Option<usize>, style: &theme::Tab, cx: &AppContext)
-        -> ElementBox;
+    fn tab_content(
+        &self,
+        detail: Option<usize>,
+        style: &theme::Tab,
+        cx: &AppContext,
+    ) -> ElementBox<Pane>;
     fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
     fn project_entry_ids(&self, cx: &AppContext) -> SmallVec<[ProjectEntryId; 3]>;
     fn project_item_model_ids(&self, cx: &AppContext) -> SmallVec<[usize; 3]>;
@@ -213,7 +221,7 @@ pub trait ItemHandle: 'static + fmt::Debug {
     ) -> gpui::Subscription;
     fn to_searchable_item_handle(&self, cx: &AppContext) -> Option<Box<dyn SearchableItemHandle>>;
     fn breadcrumb_location(&self, cx: &AppContext) -> ToolbarItemLocation;
-    fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<ElementBox>>;
+    fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<ElementBox<Pane>>>;
     fn serialized_item_kind(&self) -> Option<&'static str>;
     fn show_toolbar(&self, cx: &AppContext) -> bool;
 }
@@ -257,7 +265,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
         detail: Option<usize>,
         style: &theme::Tab,
         cx: &AppContext,
-    ) -> ElementBox {
+    ) -> ElementBox<Pane> {
         self.read(cx).tab_content(detail, style, cx)
     }
 
@@ -583,7 +591,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
         self.read(cx).breadcrumb_location()
     }
 
-    fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<ElementBox>> {
+    fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<ElementBox<Self>>> {
         self.read(cx).breadcrumbs(theme, cx)
     }
 
@@ -899,7 +907,7 @@ pub(crate) mod test {
             "TestItem"
         }
 
-        fn render(&mut self, _: &mut ViewContext<Self>) -> ElementBox {
+        fn render(&mut self, _: &mut ViewContext<Self>) -> ElementBox<Self> {
             Empty::new().boxed()
         }
     }
@@ -912,7 +920,12 @@ pub(crate) mod test {
             })
         }
 
-        fn tab_content(&self, detail: Option<usize>, _: &theme::Tab, _: &AppContext) -> ElementBox {
+        fn tab_content(
+            &self,
+            detail: Option<usize>,
+            _: &theme::Tab,
+            _: &AppContext,
+        ) -> ElementBox<Self> {
             self.tab_detail.set(detail);
             Empty::new().boxed()
         }

crates/workspace/src/notifications.rs 🔗

@@ -229,7 +229,7 @@ pub mod simple_message_notification {
             "MessageNotification"
         }
 
-        fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> gpui::ElementBox {
+        fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> gpui::ElementBox<Self> {
             let theme = cx.global::<Settings>().theme.clone();
             let theme = &theme.simple_message_notification;
 

crates/workspace/src/pane.rs 🔗

@@ -1383,8 +1383,8 @@ impl Pane {
         detail: Option<usize>,
         hovered: bool,
         tab_style: &theme::Tab,
-        cx: &mut ViewContext<V>,
-    ) -> ElementBox {
+        cx: &mut ViewContext<Self>,
+    ) -> ElementBox<Self> {
         let title = item.tab_content(detail, &tab_style, cx);
         let mut container = tab_style.container.clone();
         if first {
@@ -1404,7 +1404,7 @@ impl Pane {
                     };
 
                     ConstrainedBox::new(
-                        Canvas::new(move |bounds, _, cx| {
+                        Canvas::new(move |scene, bounds, _, cx| {
                             if let Some(color) = icon_color {
                                 let square = RectF::new(bounds.origin(), vec2f(diameter, diameter));
                                 scene.push_quad(Quad {
@@ -1475,7 +1475,11 @@ impl Pane {
             .boxed()
     }
 
-    fn render_tab_bar_buttons(&mut self, theme: &Theme, cx: &mut ViewContext<Self>) -> ElementBox {
+    fn render_tab_bar_buttons(
+        &mut self,
+        theme: &Theme,
+        cx: &mut ViewContext<Self>,
+    ) -> ElementBox<Self> {
         Flex::row()
             // New menu
             .with_child(render_tab_bar_button(
@@ -1524,7 +1528,11 @@ impl Pane {
             .boxed()
     }
 
-    fn render_blank_pane(&mut self, theme: &Theme, _cx: &mut ViewContext<Self>) -> ElementBox {
+    fn render_blank_pane(
+        &mut self,
+        theme: &Theme,
+        _cx: &mut ViewContext<Self>,
+    ) -> ElementBox<Self> {
         let background = theme.workspace.background;
         Empty::new()
             .contained()
@@ -1542,7 +1550,7 @@ impl View for Pane {
         "Pane"
     }
 
-    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
+    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
         let this = cx.handle();
 
         enum MouseNavigationHandler {}
@@ -1703,7 +1711,7 @@ fn render_tab_bar_button<A: Action + Clone>(
     cx: &mut ViewContext<Pane>,
     action: A,
     context_menu: Option<ViewHandle<ContextMenu>>,
-) -> ElementBox {
+) -> ElementBox<Pane> {
     enum TabBarButton {}
 
     Stack::new()
@@ -1837,10 +1845,11 @@ impl NavHistory {
 
 pub struct PaneBackdrop {
     child_view: usize,
-    child: ElementBox,
+    child: ElementBox<Pane>,
 }
+
 impl PaneBackdrop {
-    pub fn new(pane_item_view: usize, child: ElementBox) -> Self {
+    pub fn new(pane_item_view: usize, child: ElementBox<Pane>) -> Self {
         PaneBackdrop {
             child,
             child_view: pane_item_view,
@@ -1906,8 +1915,8 @@ impl Element<Pane> for PaneBackdrop {
         _visible_bounds: RectF,
         _layout: &Self::LayoutState,
         _paint: &Self::PaintState,
-        view: &V,
-        cx: &gpui::ViewContext<V>,
+        view: &Pane,
+        cx: &gpui::ViewContext<Pane>,
     ) -> Option<RectF> {
         self.child.rect_for_text_range(range_utf16, view, cx)
     }
@@ -1917,8 +1926,8 @@ impl Element<Pane> for PaneBackdrop {
         _bounds: RectF,
         _layout: &Self::LayoutState,
         _paint: &Self::PaintState,
-        view: &V,
-        cx: &gpui::ViewContext<V>,
+        view: &Pane,
+        cx: &gpui::ViewContext<Pane>,
     ) -> serde_json::Value {
         gpui::json::json!({
             "type": "Pane Back Drop",

crates/workspace/src/pane/dragged_item_receiver.rs 🔗

@@ -5,7 +5,7 @@ use gpui::{
     geometry::{rect::RectF, vector::Vector2F},
     platform::MouseButton,
     scene::MouseUp,
-    AppContext, Element, ElementBox, EventContext, MouseState, Quad, ViewContext, WeakViewHandle,
+    AppContext, Element, ElementBox, MouseState, Quad, ViewContext, WeakViewHandle,
 };
 use project::ProjectEntryId;
 use settings::Settings;
@@ -24,10 +24,10 @@ pub fn dragged_item_receiver<Tag, F>(
     split_margin: Option<f32>,
     cx: &mut ViewContext<Pane>,
     render_child: F,
-) -> MouseEventHandler<Tag>
+) -> MouseEventHandler<Tag, Pane>
 where
     Tag: 'static,
-    F: FnOnce(&mut MouseState, &mut ViewContext<Pane>) -> ElementBox,
+    F: FnOnce(&mut MouseState, &mut ViewContext<Pane>) -> ElementBox<Pane>,
 {
     MouseEventHandler::<Tag>::above(region_id, cx, |state, _, cx| {
         // Observing hovered will cause a render when the mouse enters regardless
@@ -48,7 +48,7 @@ where
         Stack::new()
             .with_child(render_child(state, cx))
             .with_children(drag_position.map(|drag_position| {
-                Canvas::new(move |bounds, _, cx| {
+                Canvas::new(move |scene, bounds, _, cx| {
                     if bounds.contains_point(drag_position) {
                         let overlay_region = split_margin
                             .and_then(|split_margin| {
@@ -58,7 +58,7 @@ where
                             .map(|(dir, margin)| dir.along_edge(bounds, margin))
                             .unwrap_or(bounds);
 
-                        cx.paint_stacking_context(None, None, |cx| {
+                        scene.paint_stacking_context(None, None, |cx| {
                             scene.push_quad(Quad {
                                 bounds: overlay_region,
                                 background: Some(overlay_color(cx)),
@@ -102,7 +102,7 @@ pub fn handle_dropped_item(
     index: usize,
     allow_same_pane: bool,
     split_margin: Option<f32>,
-    cx: &mut ViewContext<Self>,
+    cx: &mut ViewContext<Pane>,
 ) {
     enum Action {
         Move(WeakViewHandle<Pane>, usize),

crates/workspace/src/pane_group.rs 🔗

@@ -71,7 +71,7 @@ impl PaneGroup {
         active_call: Option<&ModelHandle<ActiveCall>>,
         active_pane: &ViewHandle<Pane>,
         cx: &mut ViewContext<Workspace>,
-    ) -> ElementBox {
+    ) -> ElementBox<Workspace> {
         self.root.render(
             project,
             theme,
@@ -132,7 +132,7 @@ impl Member {
         active_call: Option<&ModelHandle<ActiveCall>>,
         active_pane: &ViewHandle<Pane>,
         cx: &mut ViewContext<Workspace>,
-    ) -> ElementBox {
+    ) -> ElementBox<Workspace> {
         enum FollowIntoExternalProject {}
 
         match self {
@@ -367,7 +367,7 @@ impl PaneAxis {
         active_call: Option<&ModelHandle<ActiveCall>>,
         active_pane: &ViewHandle<Pane>,
         cx: &mut ViewContext<Workspace>,
-    ) -> ElementBox {
+    ) -> ElementBox<Workspace> {
         let last_member_ix = self.members.len() - 1;
         Flex::new(self.axis)
             .with_children(self.members.iter().enumerate().map(|(ix, member)| {

crates/workspace/src/shared_screen.rs 🔗

@@ -64,12 +64,12 @@ impl View for SharedScreen {
         "SharedScreen"
     }
 
-    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
+    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
         enum Focus {}
 
         let frame = self.frame.clone();
         MouseEventHandler::<Focus>::new(0, cx, |_, cx| {
-            Canvas::new(move |bounds, _, cx| {
+            Canvas::new(move |scene, bounds, _, cx| {
                 if let Some(frame) = frame.clone() {
                     let size = constrain_size_preserving_aspect_ratio(
                         bounds.size(),
@@ -103,7 +103,7 @@ impl Item for SharedScreen {
         _: Option<usize>,
         style: &theme::Tab,
         _: &AppContext,
-    ) -> gpui::ElementBox {
+    ) -> gpui::ElementBox<Self> {
         Flex::row()
             .with_child(
                 Svg::new("icons/disable_screen_sharing_12.svg")

crates/workspace/src/sidebar.rs 🔗

@@ -188,7 +188,7 @@ impl View for Sidebar {
         "Sidebar"
     }
 
-    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
+    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
         if let Some(active_item) = self.active_item() {
             enum ResizeHandleTag {}
             let style = &cx.global::<Settings>().theme.workspace.sidebar;
@@ -225,7 +225,7 @@ impl View for SidebarButtons {
         "SidebarToggleButton"
     }
 
-    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
+    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
         let theme = &cx.global::<Settings>().theme;
         let tooltip_style = theme.tooltip.clone();
         let theme = &theme.workspace.status_bar.sidebar_buttons;

crates/workspace/src/status_bar.rs 🔗

@@ -8,8 +8,8 @@ use gpui::{
         vector::{vec2f, Vector2F},
     },
     json::{json, ToJson},
-    AnyViewHandle, AppContext, DebugContext, ElementBox, Entity, LayoutContext, MeasurementContext,
-    PaintContext, SceneBuilder, SizeConstraint, Subscription, View, ViewContext, ViewHandle,
+    AnyViewHandle, AppContext, ElementBox, Entity, SceneBuilder, SizeConstraint, Subscription,
+    View, ViewContext, ViewHandle,
 };
 use settings::Settings;
 
@@ -42,7 +42,7 @@ impl View for StatusBar {
         "StatusBar"
     }
 
-    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
+    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
         let theme = &cx.global::<Settings>().theme.workspace.status_bar;
 
         StatusBarElement {
@@ -139,19 +139,19 @@ impl From<&dyn StatusItemViewHandle> for AnyViewHandle {
 }
 
 struct StatusBarElement {
-    left: ElementBox,
-    right: ElementBox,
+    left: ElementBox<StatusBar>,
+    right: ElementBox<StatusBar>,
 }
 
-impl<V: View> Element<V> for StatusBarElement {
+impl Element<StatusBar> for StatusBarElement {
     type LayoutState = ();
     type PaintState = ();
 
     fn layout(
         &mut self,
         mut constraint: SizeConstraint,
-        view: &mut V,
-        cx: &mut ViewContext<V>,
+        view: &mut StatusBar,
+        cx: &mut ViewContext<StatusBar>,
     ) -> (Vector2F, Self::LayoutState) {
         let max_width = constraint.max.x();
         constraint.min = vec2f(0., constraint.min.y());
@@ -173,8 +173,8 @@ impl<V: View> Element<V> for StatusBarElement {
         bounds: RectF,
         visible_bounds: RectF,
         _: &mut Self::LayoutState,
-        view: &mut V,
-        cx: &mut ViewContext<V>,
+        view: &mut StatusBar,
+        cx: &mut ViewContext<StatusBar>,
     ) -> Self::PaintState {
         let origin_y = bounds.upper_right().y();
         let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default();
@@ -195,7 +195,8 @@ impl<V: View> Element<V> for StatusBarElement {
         _: RectF,
         _: &Self::LayoutState,
         _: &Self::PaintState,
-        _: &MeasurementContext,
+        _: &StatusBar,
+        _: &ViewContext<StatusBar>,
     ) -> Option<RectF> {
         None
     }
@@ -205,7 +206,8 @@ impl<V: View> Element<V> for StatusBarElement {
         bounds: RectF,
         _: &Self::LayoutState,
         _: &Self::PaintState,
-        _: &DebugContext,
+        _: &StatusBar,
+        _: &ViewContext<StatusBar>,
     ) -> serde_json::Value {
         json!({
             "type": "StatusBarElement",

crates/workspace/src/toolbar.rs 🔗

@@ -59,7 +59,7 @@ impl View for Toolbar {
         "Toolbar"
     }
 
-    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
+    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
         let theme = &cx.global::<Settings>().theme.workspace.toolbar;
 
         let mut primary_left_items = Vec::new();
@@ -169,7 +169,7 @@ fn nav_button<A: Action + Clone>(
     tooltip_action: A,
     action_name: &str,
     cx: &mut ViewContext<Toolbar>,
-) -> ElementBox {
+) -> ElementBox<Toolbar> {
     MouseEventHandler::<A>::new(0, cx, |state, _| {
         let style = if enabled {
             style.style_for(state, false)

crates/workspace/src/workspace.rs 🔗

@@ -2053,7 +2053,7 @@ impl Workspace {
         self.leader_state.followers.contains(&peer_id)
     }
 
-    fn render_titlebar(&self, theme: &Theme, cx: &mut ViewContext<Self>) -> ElementBox {
+    fn render_titlebar(&self, theme: &Theme, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
         // TODO: There should be a better system in place for this
         // (https://github.com/zed-industries/zed/issues/1290)
         let is_fullscreen = cx.window_is_fullscreen();
@@ -2153,7 +2153,10 @@ impl Workspace {
         }
     }
 
-    fn render_disconnected_overlay(&self, cx: &mut ViewContext<Workspace>) -> Option<ElementBox> {
+    fn render_disconnected_overlay(
+        &self,
+        cx: &mut ViewContext<Workspace>,
+    ) -> Option<ElementBox<Workspace>> {
         if self.project.read(cx).is_read_only() {
             enum DisconnectedOverlay {}
             Some(
@@ -2181,7 +2184,7 @@ impl Workspace {
         &self,
         theme: &theme::Workspace,
         cx: &AppContext,
-    ) -> Option<ElementBox> {
+    ) -> Option<ElementBox<Workspace>> {
         if self.notifications.is_empty() {
             None
         } else {
@@ -2809,7 +2812,7 @@ impl View for Workspace {
         "Workspace"
     }
 
-    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
+    fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
         let theme = cx.global::<Settings>().theme.clone();
         Stack::new()
             .with_child(