diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rs index 214c46551f..b241b76184 100644 --- a/crates/editor2/src/editor.rs +++ b/crates/editor2/src/editor.rs @@ -9376,7 +9376,7 @@ impl FocusableView for Editor { } } -impl Render for Editor { +impl Render for Editor { type Element = EditorElement; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { diff --git a/crates/editor2/src/element.rs b/crates/editor2/src/element.rs index 0ee710da47..3140008bc3 100644 --- a/crates/editor2/src/element.rs +++ b/crates/editor2/src/element.rs @@ -21,7 +21,7 @@ use gpui::{ div, point, px, relative, size, transparent_black, Action, AnyElement, AvailableSpace, BorrowWindow, Bounds, Component, ContentMask, Corners, DispatchPhase, Edges, Element, ElementId, ElementInputHandler, Entity, EntityId, Hsla, InteractiveElement, LineLayout, - MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, + MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, RenderOnce, ScrollWheelEvent, ShapedLine, SharedString, Size, StatefulInteractiveElement, Style, Styled, TextRun, TextStyle, View, ViewContext, WindowContext, WrappedLine, }; @@ -2466,9 +2466,11 @@ impl Element for EditorElement { } } -impl Component for EditorElement { - fn render(self) -> AnyElement { - AnyElement::new(self) +impl RenderOnce for EditorElement { + type Element = Self; + + fn render_once(self) -> Self::Element { + self } } diff --git a/crates/storybook3/src/storybook3.rs b/crates/storybook3/src/storybook3.rs index 291f8ce2ac..e8f1827e01 100644 --- a/crates/storybook3/src/storybook3.rs +++ b/crates/storybook3/src/storybook3.rs @@ -59,7 +59,7 @@ struct TestView { story: AnyView, } -impl Render for TestView { +impl Render for TestView { type Element = Div; fn render(&mut self, _cx: &mut ViewContext) -> Self::Element { diff --git a/crates/workspace2/src/dock.rs b/crates/workspace2/src/dock.rs index 406a7a33d1..d6b8d9ae79 100644 --- a/crates/workspace2/src/dock.rs +++ b/crates/workspace2/src/dock.rs @@ -1,8 +1,8 @@ use crate::{status_bar::StatusItemView, Axis, Workspace}; use gpui::{ div, px, Action, AnchorCorner, AnyView, AppContext, Component, Div, Entity, EntityId, - EventEmitter, FocusHandle, FocusableView, ParentElement, Render, SharedString, Styled, - Subscription, View, ViewContext, VisualContext, WeakView, WindowContext, + EventEmitter, FocusHandle, FocusableView, ParentElement, Render, RenderOnce, SharedString, + Styled, Subscription, View, ViewContext, VisualContext, WeakView, WindowContext, }; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -426,7 +426,7 @@ impl Dock { } } -impl Render for Dock { +impl Render for Dock { type Element = Div; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { @@ -612,7 +612,7 @@ impl PanelButtons { // } // here be kittens -impl Render for PanelButtons { +impl Render for PanelButtons { type Element = Div; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { @@ -706,7 +706,7 @@ pub mod test { } } - impl Render for TestPanel { + impl Render for TestPanel { type Element = Div; fn render(&mut self, _cx: &mut ViewContext) -> Self::Element { diff --git a/crates/workspace2/src/modal_layer.rs b/crates/workspace2/src/modal_layer.rs index 8afd8317f9..3cbd8458f4 100644 --- a/crates/workspace2/src/modal_layer.rs +++ b/crates/workspace2/src/modal_layer.rs @@ -71,7 +71,7 @@ impl ModalLayer { } } -impl Render for ModalLayer { +impl Render for ModalLayer { type Element = Div; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { diff --git a/crates/workspace2/src/notifications.rs b/crates/workspace2/src/notifications.rs index 7277cc6fc4..bb00973d5c 100644 --- a/crates/workspace2/src/notifications.rs +++ b/crates/workspace2/src/notifications.rs @@ -13,7 +13,7 @@ pub enum NotificationEvent { Dismiss, } -pub trait Notification: EventEmitter + Render {} +pub trait Notification: EventEmitter + Render {} pub trait NotificationHandle: Send { fn id(&self) -> EntityId; @@ -251,7 +251,7 @@ pub mod simple_message_notification { // } } - impl Render for MessageNotification { + impl Render for MessageNotification { type Element = Div; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rs index d44d347114..4ab78d8bca 100644 --- a/crates/workspace2/src/pane.rs +++ b/crates/workspace2/src/pane.rs @@ -593,7 +593,7 @@ impl Pane { self.items.iter() } - pub fn items_of_type(&self) -> impl '_ + Iterator> { + pub fn items_of_type>(&self) -> impl '_ + Iterator> { self.items .iter() .filter_map(|item| item.to_any().downcast().ok()) @@ -1343,7 +1343,7 @@ impl Pane { item: &Box, detail: usize, cx: &mut ViewContext<'_, Pane>, - ) -> impl Component { + ) -> impl RenderOnce { let label = item.tab_content(Some(detail), cx); let close_icon = || { let id = item.item_id(); @@ -1436,7 +1436,7 @@ impl Pane { ) } - fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl Component { + fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl RenderOnce { div() .group("tab_bar") .id("tab_bar") @@ -1895,7 +1895,7 @@ impl FocusableView for Pane { } } -impl Render for Pane { +impl Render for Pane { type Element = Focusable>; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { @@ -2949,7 +2949,7 @@ struct DraggedTab { title: String, } -impl Render for DraggedTab { +impl Render for DraggedTab { type Element = Div; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { diff --git a/crates/workspace2/src/pane_group.rs b/crates/workspace2/src/pane_group.rs index d46757ff9f..68f26295dc 100644 --- a/crates/workspace2/src/pane_group.rs +++ b/crates/workspace2/src/pane_group.rs @@ -6,7 +6,10 @@ use db2::sqlez::{ bindable::{Bind, Column, StaticColumnCount}, statement::Statement, }; -use gpui::{point, size, AnyElement, AnyWeakView, Bounds, Model, Pixels, Point, View, ViewContext}; +use gpui::{ + point, size, AnyElement, AnyWeakView, Bounds, Div, Model, Pixels, Point, RenderOnce, View, + ViewContext, +}; use parking_lot::Mutex; use project2::Project; use serde::Deserialize; @@ -130,7 +133,7 @@ impl PaneGroup { zoomed: Option<&AnyWeakView>, app_state: &Arc, cx: &mut ViewContext, - ) -> impl Component { + ) -> impl RenderOnce { self.root.render( project, 0, @@ -202,7 +205,7 @@ impl Member { zoomed: Option<&AnyWeakView>, app_state: &Arc, cx: &mut ViewContext, - ) -> impl Component { + ) -> impl RenderOnce { match self { Member::Pane(pane) => { // todo!() @@ -212,7 +215,7 @@ impl Member { // Some(pane) // }; - div().size_full().child(pane.clone()).render() + div().size_full().child(pane.clone()) // Stack::new() // .with_child(pane_element.contained().with_border(leader_border)) @@ -559,7 +562,7 @@ impl PaneAxis { zoomed: Option<&AnyWeakView>, app_state: &Arc, cx: &mut ViewContext, - ) -> AnyElement { + ) -> Div { debug_assert!(self.members.len() == self.flexes.lock().len()); div() @@ -582,11 +585,10 @@ impl PaneAxis { app_state, cx, ) - .render(), - Member::Pane(pane) => pane.clone().render(), + .render_into_any(), + Member::Pane(pane) => pane.clone().render_into_any(), } })) - .render() // let mut pane_axis = PaneAxisElement::new( // self.axis, diff --git a/crates/workspace2/src/status_bar.rs b/crates/workspace2/src/status_bar.rs index b0f905f845..f961cac8f0 100644 --- a/crates/workspace2/src/status_bar.rs +++ b/crates/workspace2/src/status_bar.rs @@ -2,14 +2,14 @@ use std::any::TypeId; use crate::{ItemHandle, Pane}; use gpui::{ - div, AnyView, Component, Div, ParentElement, Render, Styled, Subscription, View, + div, AnyView, Component, Div, ParentElement, Render, RenderOnce, Styled, Subscription, View, ViewContext, WindowContext, }; use theme2::ActiveTheme; use ui::h_stack; use util::ResultExt; -pub trait StatusItemView: Render { +pub trait StatusItemView: Render { fn set_active_pane_item( &mut self, active_pane_item: Option<&dyn crate::ItemHandle>, @@ -34,7 +34,7 @@ pub struct StatusBar { _observe_active_pane: Subscription, } -impl Render for StatusBar { +impl Render for StatusBar { type Element = Div; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { @@ -53,14 +53,14 @@ impl Render for StatusBar { } impl StatusBar { - fn render_left_tools(&self, cx: &mut ViewContext) -> impl Component { + fn render_left_tools(&self, cx: &mut ViewContext) -> impl RenderOnce { h_stack() .items_center() .gap_1() .children(self.left_items.iter().map(|item| item.to_any())) } - fn render_right_tools(&self, cx: &mut ViewContext) -> impl Component { + fn render_right_tools(&self, cx: &mut ViewContext) -> impl RenderOnce { h_stack() .items_center() .gap_2() diff --git a/crates/workspace2/src/toolbar.rs b/crates/workspace2/src/toolbar.rs index 1d67da06b2..072c67fda8 100644 --- a/crates/workspace2/src/toolbar.rs +++ b/crates/workspace2/src/toolbar.rs @@ -7,7 +7,7 @@ pub enum ToolbarItemEvent { ChangeLocation(ToolbarItemLocation), } -pub trait ToolbarItemView: Render + EventEmitter { +pub trait ToolbarItemView: Render + EventEmitter { fn set_active_pane_item( &mut self, active_pane_item: Option<&dyn crate::ItemHandle>, @@ -51,7 +51,7 @@ pub struct Toolbar { items: Vec<(Box, ToolbarItemLocation)>, } -impl Render for Toolbar { +impl Render for Toolbar { type Element = Div; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rs index af61091ce4..e6b3f1875f 100644 --- a/crates/workspace2/src/workspace2.rs +++ b/crates/workspace2/src/workspace2.rs @@ -3592,7 +3592,7 @@ impl FocusableView for Workspace { } } -impl Render for Workspace { +impl Render for Workspace { type Element = Div; fn render(&mut self, cx: &mut ViewContext) -> Self::Element {