diff --git a/crates/activity_indicator2/src/activity_indicator.rs b/crates/activity_indicator2/src/activity_indicator.rs index ffb11da21d4e65d89245e652853597b16ade8528..4b990fa430cf5c652457ee42a1dc57915a7a1b8c 100644 --- a/crates/activity_indicator2/src/activity_indicator.rs +++ b/crates/activity_indicator2/src/activity_indicator.rs @@ -304,7 +304,7 @@ impl ActivityIndicator { impl EventEmitter for ActivityIndicator {} impl Render for ActivityIndicator { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let content = self.content_to_render(cx); let mut result = h_stack() diff --git a/crates/assistant2/src/assistant_panel.rs b/crates/assistant2/src/assistant_panel.rs index f93f33d539bdb20484d1d6c8942a69bad2832033..7b19ad130c4c42316f6ca65c8063be9c3842b42b 100644 --- a/crates/assistant2/src/assistant_panel.rs +++ b/crates/assistant2/src/assistant_panel.rs @@ -1101,7 +1101,7 @@ fn build_api_key_editor(cx: &mut ViewContext) -> View { } impl Render for AssistantPanel { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { if let Some(api_key_editor) = self.api_key_editor.clone() { v_stack() .on_action(cx.listener(AssistantPanel::save_credentials)) diff --git a/crates/auto_update2/src/update_notification.rs b/crates/auto_update2/src/update_notification.rs index 009972b7ee97656abf8bf2e40a9b15b76047da5f..f00172591ecf37221e34cf4ff3b5b330b72fba28 100644 --- a/crates/auto_update2/src/update_notification.rs +++ b/crates/auto_update2/src/update_notification.rs @@ -1,5 +1,5 @@ use gpui::{ - div, DismissEvent, Element, EventEmitter, InteractiveElement, ParentElement, Render, + div, DismissEvent, EventEmitter, InteractiveElement, IntoElement, ParentElement, Render, SemanticVersion, StatefulInteractiveElement, Styled, ViewContext, }; use menu::Cancel; @@ -13,7 +13,7 @@ pub struct UpdateNotification { impl EventEmitter for UpdateNotification {} impl Render for UpdateNotification { - fn render(&mut self, cx: &mut gpui::ViewContext) -> impl Element { + fn render(&mut self, cx: &mut gpui::ViewContext) -> impl IntoElement { let app_name = cx.global::().display_name(); v_stack() diff --git a/crates/breadcrumbs2/src/breadcrumbs.rs b/crates/breadcrumbs2/src/breadcrumbs.rs index fa9e330468bbd9ff34b51043180092760b4f84ff..2e4306f0bc2b3694b9b4312f7a8458ed96ba44d7 100644 --- a/crates/breadcrumbs2/src/breadcrumbs.rs +++ b/crates/breadcrumbs2/src/breadcrumbs.rs @@ -30,7 +30,7 @@ impl Breadcrumbs { impl EventEmitter for Breadcrumbs {} impl Render for Breadcrumbs { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let element = h_stack().text_ui(); let Some(active_item) = self.active_item.as_ref() else { return element; diff --git a/crates/collab_ui2/src/channel_view.rs b/crates/collab_ui2/src/channel_view.rs index 6674c2f056a0f386d615ed335fa64195df80bebe..df2adbaabe962192b97c1c9ea456328a5e58ec7b 100644 --- a/crates/collab_ui2/src/channel_view.rs +++ b/crates/collab_ui2/src/channel_view.rs @@ -222,7 +222,7 @@ impl ChannelView { impl EventEmitter for ChannelView {} impl Render for ChannelView { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { self.editor.clone() } } diff --git a/crates/collab_ui2/src/chat_panel.rs b/crates/collab_ui2/src/chat_panel.rs index 2e161df9f41d418cb35b04c9e3f68684e2cde844..19acb17673cedd92def75e8edf82a6258ceb940b 100644 --- a/crates/collab_ui2/src/chat_panel.rs +++ b/crates/collab_ui2/src/chat_panel.rs @@ -549,7 +549,7 @@ impl ChatPanel { impl EventEmitter for ChatPanel {} impl Render for ChatPanel { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { div() .full() .child(if self.client.user_id().is_some() { diff --git a/crates/collab_ui2/src/chat_panel/message_editor.rs b/crates/collab_ui2/src/chat_panel/message_editor.rs index 1b52d6eed9051a9ecb6f41c1993f07da431a3c69..522db1042d45a757be1541cbdb2bacb5e86266ef 100644 --- a/crates/collab_ui2/src/chat_panel/message_editor.rs +++ b/crates/collab_ui2/src/chat_panel/message_editor.rs @@ -3,7 +3,7 @@ use client::UserId; use collections::HashMap; use editor::{AnchorRangeExt, Editor}; use gpui::{ - AsyncWindowContext, Element, FocusableView, Model, Render, SharedString, Task, View, + AsyncWindowContext, FocusableView, IntoElement, Model, Render, SharedString, Task, View, ViewContext, WeakView, }; use language::{language_settings::SoftWrap, Buffer, BufferSnapshot, LanguageRegistry}; @@ -196,7 +196,7 @@ impl MessageEditor { } impl Render for MessageEditor { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { self.editor.to_any() } } diff --git a/crates/collab_ui2/src/collab_panel.rs b/crates/collab_ui2/src/collab_panel.rs index c8119d21279571de3f664e72d61bbbf33fc4cdd9..3ed07e5bd1b8b3985f58d8ca89dd04e676f5425a 100644 --- a/crates/collab_ui2/src/collab_panel.rs +++ b/crates/collab_ui2/src/collab_panel.rs @@ -2323,7 +2323,7 @@ fn render_tree_branch(is_last: bool, cx: &mut WindowContext) -> impl IntoElement } impl Render for CollabPanel { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { v_stack() .key_context("CollabPanel") .on_action(cx.listener(CollabPanel::cancel)) diff --git a/crates/collab_ui2/src/collab_panel/channel_modal.rs b/crates/collab_ui2/src/collab_panel/channel_modal.rs index 2c659a55d0c8e5f6bd51684aac1171edb08240fe..114e89f1c4df54930b49c18235ead6f6fbec0af1 100644 --- a/crates/collab_ui2/src/collab_panel/channel_modal.rs +++ b/crates/collab_ui2/src/collab_panel/channel_modal.rs @@ -142,7 +142,7 @@ impl FocusableView for ChannelModal { } impl Render for ChannelModal { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let channel_store = self.channel_store.read(cx); let Some(channel) = channel_store.channel_for_id(self.channel_id) else { return div(); diff --git a/crates/collab_ui2/src/collab_panel/contact_finder.rs b/crates/collab_ui2/src/collab_panel/contact_finder.rs index cb916ba96188dd821a278e3a05a27381b65c765f..dbcacef7d645de6e30959b7b4d0b91b2f41aceed 100644 --- a/crates/collab_ui2/src/collab_panel/contact_finder.rs +++ b/crates/collab_ui2/src/collab_panel/contact_finder.rs @@ -35,7 +35,7 @@ impl ContactFinder { } impl Render for ContactFinder { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { v_stack() .elevation_3(cx) .child( diff --git a/crates/collab_ui2/src/collab_titlebar_item.rs b/crates/collab_ui2/src/collab_titlebar_item.rs index 8d6f495ad58a8d3242cd3a1e1b4b756dbd0bbf3a..60bb35a8d58e65bede02ba5c7305eb7be923bda4 100644 --- a/crates/collab_ui2/src/collab_titlebar_item.rs +++ b/crates/collab_ui2/src/collab_titlebar_item.rs @@ -56,7 +56,7 @@ pub struct CollabTitlebarItem { } impl Render for CollabTitlebarItem { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let room = ActiveCall::global(cx).read(cx).room().cloned(); let current_user = self.user_store.read(cx).current_user(); let client = self.client.clone(); diff --git a/crates/collab_ui2/src/face_pile.rs b/crates/collab_ui2/src/face_pile.rs index 1c0d8100d85cd2eb3adb14fd59ffef8d092ecc0f..55f4efffac5354effa1da2cbc0ee2c05f8e65ad8 100644 --- a/crates/collab_ui2/src/face_pile.rs +++ b/crates/collab_ui2/src/face_pile.rs @@ -1,5 +1,5 @@ use gpui::{ - div, AnyElement, Div, ElementId, IntoElement, ParentElement, RenderOnce, Styled, WindowContext, + div, AnyElement, ElementId, IntoElement, ParentElement, RenderOnce, Styled, WindowContext, }; use smallvec::SmallVec; @@ -9,9 +9,7 @@ pub struct FacePile { } impl RenderOnce for FacePile { - type Output = Div; - - fn render(self, _: &mut WindowContext) -> Self::Output { + fn render(self, _: &mut WindowContext) -> impl IntoElement { let player_count = self.faces.len(); let player_list = self.faces.into_iter().enumerate().map(|(ix, player)| { let isnt_last = ix < player_count - 1; diff --git a/crates/collab_ui2/src/notification_panel.rs b/crates/collab_ui2/src/notification_panel.rs index e000921cdafc56908fb6f47ece85b419dff24a76..b7a18365bee610cbfa1cdebe1410fe9dda1f2891 100644 --- a/crates/collab_ui2/src/notification_panel.rs +++ b/crates/collab_ui2/src/notification_panel.rs @@ -540,7 +540,7 @@ impl NotificationPanel { } impl Render for NotificationPanel { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { v_stack() .size_full() .child( @@ -708,7 +708,7 @@ impl NotificationToast { } impl Render for NotificationToast { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let user = self.actor.clone(); h_stack() diff --git a/crates/collab_ui2/src/notifications/incoming_call_notification.rs b/crates/collab_ui2/src/notifications/incoming_call_notification.rs index dab33328cd799ce3bc5ea4532e02d68c00d91bb1..fa28ef9a6030d4009e96d170e7f7aefc46e52783 100644 --- a/crates/collab_ui2/src/notifications/incoming_call_notification.rs +++ b/crates/collab_ui2/src/notifications/incoming_call_notification.rs @@ -117,7 +117,7 @@ impl IncomingCallNotification { } impl Render for IncomingCallNotification { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { // TODO: Is there a better place for us to initialize the font? let (ui_font, ui_font_size) = { let theme_settings = ThemeSettings::get_global(cx); diff --git a/crates/collab_ui2/src/notifications/project_shared_notification.rs b/crates/collab_ui2/src/notifications/project_shared_notification.rs index 3be50515e8fece01bc833cc4fe409560cfc75fd9..982214c3e596e7290a4837264cc570c5aa786c94 100644 --- a/crates/collab_ui2/src/notifications/project_shared_notification.rs +++ b/crates/collab_ui2/src/notifications/project_shared_notification.rs @@ -118,7 +118,7 @@ impl ProjectSharedNotification { } impl Render for ProjectSharedNotification { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { // TODO: Is there a better place for us to initialize the font? let (ui_font, ui_font_size) = { let theme_settings = ThemeSettings::get_global(cx); diff --git a/crates/command_palette2/src/command_palette.rs b/crates/command_palette2/src/command_palette.rs index 5d069967bab751f44a27b4928bd115b296936043..b7a1dbfd3dd48abc08a05e6a151a24fa3ef4af83 100644 --- a/crates/command_palette2/src/command_palette.rs +++ b/crates/command_palette2/src/command_palette.rs @@ -83,7 +83,7 @@ impl FocusableView for CommandPalette { } impl Render for CommandPalette { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { v_stack().w(rems(34.)).child(self.picker.clone()) } } diff --git a/crates/copilot2/src/sign_in.rs b/crates/copilot2/src/sign_in.rs index cef87d63a11c4982d920a3fd41dd8b013c135b43..ba5dbe0e315828ac1761cf1d76ac37bb8211ea4c 100644 --- a/crates/copilot2/src/sign_in.rs +++ b/crates/copilot2/src/sign_in.rs @@ -181,7 +181,7 @@ impl CopilotCodeVerification { } impl Render for CopilotCodeVerification { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let prompt = match &self.status { Status::SigningIn { prompt: Some(prompt), diff --git a/crates/copilot_button2/src/copilot_button.rs b/crates/copilot_button2/src/copilot_button.rs index 06cacb0b07640eec61f2c1395ac8d5f4c319199e..60b25fee12ab8c32ca6894fb2363f271f27246a4 100644 --- a/crates/copilot_button2/src/copilot_button.rs +++ b/crates/copilot_button2/src/copilot_button.rs @@ -3,7 +3,7 @@ use copilot::{Copilot, SignOut, Status}; use editor::{scroll::autoscroll::Autoscroll, Editor}; use fs::Fs; use gpui::{ - div, Action, AnchorCorner, AppContext, AsyncWindowContext, Element, Entity, ParentElement, + div, Action, AnchorCorner, AppContext, AsyncWindowContext, Entity, IntoElement, ParentElement, Render, Subscription, View, ViewContext, WeakView, WindowContext, }; use language::{ @@ -34,7 +34,7 @@ pub struct CopilotButton { } impl Render for CopilotButton { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let all_language_settings = all_language_settings(None, cx); if !all_language_settings.copilot.feature_enabled { return div(); diff --git a/crates/diagnostics2/src/items.rs b/crates/diagnostics2/src/items.rs index 959cf14fdbfc5f2f18e3067031027a5a3731b6e1..9f7be0c04f2ca27413953cd5a133139cba4e10ea 100644 --- a/crates/diagnostics2/src/items.rs +++ b/crates/diagnostics2/src/items.rs @@ -21,7 +21,7 @@ pub struct DiagnosticIndicator { } impl Render for DiagnosticIndicator { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) { (0, 0) => h_stack().child( IconElement::new(Icon::Check) diff --git a/crates/diagnostics2/src/toolbar_controls.rs b/crates/diagnostics2/src/toolbar_controls.rs index 0dc17f9320cd66142df1c6511a5bf42d725dbb3f..897e2ccf40f573591d7b9e712e65928a17b28413 100644 --- a/crates/diagnostics2/src/toolbar_controls.rs +++ b/crates/diagnostics2/src/toolbar_controls.rs @@ -9,7 +9,7 @@ pub struct ToolbarControls { } impl Render for ToolbarControls { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let include_warnings = self .editor .as_ref() diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rs index 4e9a1dee90c624a99f4754f0a685a9b9e42ba9b6..85a156a8eb9014728a4a2ad1598082e990f45ef7 100644 --- a/crates/editor2/src/editor.rs +++ b/crates/editor2/src/editor.rs @@ -9287,7 +9287,7 @@ impl FocusableView for Editor { } impl Render for Editor { - fn render<'a>(&mut self, cx: &mut ViewContext<'a, Self>) -> impl 'static + Element { + fn render<'a>(&mut self, cx: &mut ViewContext<'a, Self>) -> impl IntoElement { let settings = ThemeSettings::get_global(cx); let text_style = match self.mode { EditorMode::SingleLine | EditorMode::AutoHeight { .. } => TextStyle { diff --git a/crates/editor2/src/items.rs b/crates/editor2/src/items.rs index f72915492f541c480156864065bdf933fdc2f2cb..31c4e24659fb5a691f379e0979ce4cc5a7546aa1 100644 --- a/crates/editor2/src/items.rs +++ b/crates/editor2/src/items.rs @@ -1193,7 +1193,7 @@ impl CursorPosition { } impl Render for CursorPosition { - fn render(&mut self, _: &mut ViewContext) -> impl Element { + fn render(&mut self, _: &mut ViewContext) -> impl IntoElement { div().when_some(self.position, |el, position| { let mut text = format!( "{}{FILE_ROW_COLUMN_DELIMITER}{}", diff --git a/crates/feedback2/src/deploy_feedback_button.rs b/crates/feedback2/src/deploy_feedback_button.rs index 0e0dae30ff440a35d3caea4557d6909a515dfd1a..a02540bc5b3339e576f1a1eae336db119bd845ed 100644 --- a/crates/feedback2/src/deploy_feedback_button.rs +++ b/crates/feedback2/src/deploy_feedback_button.rs @@ -17,7 +17,7 @@ impl DeployFeedbackButton { } impl Render for DeployFeedbackButton { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let is_open = self .workspace .upgrade() diff --git a/crates/feedback2/src/feedback_modal.rs b/crates/feedback2/src/feedback_modal.rs index c8bb7b86673a46a816d11cab9019a52d9304f298..0f5b26eae9927e86e27a6e4e8a02bcc5f8e4bbc9 100644 --- a/crates/feedback2/src/feedback_modal.rs +++ b/crates/feedback2/src/feedback_modal.rs @@ -396,7 +396,7 @@ impl FeedbackModal { } impl Render for FeedbackModal { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { self.update_submission_state(cx); let submit_button_text = if self.awaiting_submission() { diff --git a/crates/file_finder2/src/file_finder.rs b/crates/file_finder2/src/file_finder.rs index 88ebd6331c7e02b94458b014e4a64cbe191030bb..589f634d01b7db8c5889f134e9707eabad4943bc 100644 --- a/crates/file_finder2/src/file_finder.rs +++ b/crates/file_finder2/src/file_finder.rs @@ -118,7 +118,7 @@ impl FocusableView for FileFinder { } } impl Render for FileFinder { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { v_stack().w(rems(34.)).child(self.picker.clone()) } } diff --git a/crates/go_to_line2/src/go_to_line.rs b/crates/go_to_line2/src/go_to_line.rs index 4845c9306871cd14d8c354f6df79dd1bad6469e4..ec58cbdc60556742414cc3692ef79f0658fbc750 100644 --- a/crates/go_to_line2/src/go_to_line.rs +++ b/crates/go_to_line2/src/go_to_line.rs @@ -152,7 +152,7 @@ impl GoToLine { } impl Render for GoToLine { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { div() .elevation_2(cx) .key_context("GoToLine") diff --git a/crates/gpui2/src/app/test_context.rs b/crates/gpui2/src/app/test_context.rs index e5bb6e73e1cb4fe7d60daa337cae6d64b57dae9b..44f303ac0bebfde1ded9c4deb1eebef40ad06633 100644 --- a/crates/gpui2/src/app/test_context.rs +++ b/crates/gpui2/src/app/test_context.rs @@ -1,7 +1,7 @@ use crate::{ div, Action, AnyView, AnyWindowHandle, AppCell, AppContext, AsyncAppContext, - BackgroundExecutor, Bounds, ClipboardItem, Context, Element, Entity, EventEmitter, - ForegroundExecutor, InputEvent, KeyDownEvent, Keystroke, Model, ModelContext, Pixels, Platform, + BackgroundExecutor, Bounds, ClipboardItem, Context, Entity, EventEmitter, ForegroundExecutor, + InputEvent, IntoElement, KeyDownEvent, Keystroke, Model, ModelContext, Pixels, Platform, PlatformWindow, Point, Render, Result, Size, Task, TestDispatcher, TestPlatform, TestWindow, TestWindowHandlers, TextSystem, View, ViewContext, VisualContext, WindowBounds, WindowContext, WindowHandle, WindowOptions, @@ -731,7 +731,7 @@ impl AnyWindowHandle { pub struct EmptyView {} impl Render for EmptyView { - fn render(&mut self, _cx: &mut crate::ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut crate::ViewContext) -> impl IntoElement { div() } } diff --git a/crates/gpui2/src/element.rs b/crates/gpui2/src/element.rs index 73ea66042e456e685600b2d5c209f05d038c096e..30456f14a7ffeb35df54442e15304dcc68ed1958 100644 --- a/crates/gpui2/src/element.rs +++ b/crates/gpui2/src/element.rs @@ -6,6 +6,10 @@ use derive_more::{Deref, DerefMut}; pub(crate) use smallvec::SmallVec; use std::{any::Any, fmt::Debug}; +/// Implemented by types that participate in laying out and painting the contents of a window. +/// Elements form a tree and are laid out according to web-based layout rules. +/// Rather than calling methods on implementers of this trait directly, you'll usually call `into_any` to convert them into an AnyElement, which manages state internally. +/// You can create custom elements by implementing this trait. pub trait Element: 'static + IntoElement { type State: 'static; @@ -107,15 +111,13 @@ pub trait IntoElement: Sized { } pub trait Render: 'static + Sized { - fn render(&mut self, cx: &mut ViewContext) -> impl Element; + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement; } /// You can derive [IntoElement] on any type that implements this trait. /// It is used to allow views to be expressed in terms of abstract data. pub trait RenderOnce: 'static { - type Output: IntoElement; - - fn render(self, cx: &mut WindowContext) -> Self::Output; + fn render(self, cx: &mut WindowContext) -> impl IntoElement; } pub trait ParentElement { @@ -139,62 +141,29 @@ pub trait ParentElement { } } -pub struct Component { - component: Option, -} - -pub struct ComponentState { - rendered_element: Option<::Element>, - rendered_element_state: Option<<::Element as Element>::State>, -} +pub struct Component(Option); -impl Component { +impl Component { pub fn new(component: C) -> Self { - Component { - component: Some(component), - } + Component(Some(component)) } } impl Element for Component { - type State = ComponentState; + type State = AnyElement; fn request_layout( &mut self, - state: Option, + _: Option, cx: &mut WindowContext, ) -> (LayoutId, Self::State) { - let mut element = self.component.take().unwrap().render(cx).into_element(); - if let Some(element_id) = element.element_id() { - let layout_id = - cx.with_element_state(element_id, |state, cx| element.request_layout(state, cx)); - let state = ComponentState { - rendered_element: Some(element), - rendered_element_state: None, - }; - (layout_id, state) - } else { - let (layout_id, state) = - element.request_layout(state.and_then(|s| s.rendered_element_state), cx); - let state = ComponentState { - rendered_element: Some(element), - rendered_element_state: Some(state), - }; - (layout_id, state) - } + let mut element = self.0.take().unwrap().render(cx).into_any_element(); + let layout_id = element.request_layout(cx); + (layout_id, element) } - fn paint(&mut self, bounds: Bounds, state: &mut Self::State, cx: &mut WindowContext) { - let mut element = state.rendered_element.take().unwrap(); - if let Some(element_id) = element.element_id() { - cx.with_element_state(element_id, |element_state, cx| { - let mut element_state = element_state.unwrap(); - element.paint(bounds, &mut element_state, cx); - ((), element_state) - }); - } else { - element.paint(bounds, state.rendered_element_state.as_mut().unwrap(), cx); - } + fn paint(&mut self, _: Bounds, element: &mut Self::State, cx: &mut WindowContext) { + element.paint(cx) } } @@ -216,7 +185,7 @@ pub struct GlobalElementId(SmallVec<[ElementId; 32]>); trait ElementObject { fn element_id(&self) -> Option; - fn layout(&mut self, cx: &mut WindowContext) -> LayoutId; + fn request_layout(&mut self, cx: &mut WindowContext) -> LayoutId; fn paint(&mut self, cx: &mut WindowContext); @@ -391,7 +360,7 @@ where self.as_ref().unwrap().element_id() } - fn layout(&mut self, cx: &mut WindowContext) -> LayoutId { + fn request_layout(&mut self, cx: &mut WindowContext) -> LayoutId { DrawableElement::request_layout(self.as_mut().unwrap(), cx) } @@ -431,8 +400,8 @@ impl AnyElement { AnyElement(element) } - pub fn layout(&mut self, cx: &mut WindowContext) -> LayoutId { - self.0.layout(cx) + pub fn request_layout(&mut self, cx: &mut WindowContext) -> LayoutId { + self.0.request_layout(cx) } pub fn paint(&mut self, cx: &mut WindowContext) { @@ -471,7 +440,7 @@ impl Element for AnyElement { _: Option, cx: &mut WindowContext, ) -> (LayoutId, Self::State) { - let layout_id = self.layout(cx); + let layout_id = self.request_layout(cx); (layout_id, ()) } diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rs index aa5fff8b3d950b86931c18a490db7ba30147dc17..45097411d13875c7b1a8fecc4888711dbc0d9dd3 100644 --- a/crates/gpui2/src/elements/div.rs +++ b/crates/gpui2/src/elements/div.rs @@ -781,7 +781,7 @@ impl Element for Div { child_layout_ids = self .children .iter_mut() - .map(|child| child.layout(cx)) + .map(|child| child.request_layout(cx)) .collect::>(); cx.request_layout(&style, child_layout_ids.iter().copied()) }) diff --git a/crates/gpui2/src/elements/overlay.rs b/crates/gpui2/src/elements/overlay.rs index 61f24a162bd321cd5fbb8f8489298b4ec0811406..eab3ee60b41ded0f39fa548285b3d6be572e2ba1 100644 --- a/crates/gpui2/src/elements/overlay.rs +++ b/crates/gpui2/src/elements/overlay.rs @@ -68,7 +68,7 @@ impl Element for Overlay { let child_layout_ids = self .children .iter_mut() - .map(|child| child.layout(cx)) + .map(|child| child.request_layout(cx)) .collect::>(); let overlay_style = Style { diff --git a/crates/gpui2/src/interactive.rs b/crates/gpui2/src/interactive.rs index 1a81e94df3898a440015cb577d1aef47db944342..6fc7cfc8e8dfcca3cf91bb35d4da06517a2c75f1 100644 --- a/crates/gpui2/src/interactive.rs +++ b/crates/gpui2/src/interactive.rs @@ -205,7 +205,7 @@ impl ExternalPaths { } impl Render for ExternalPaths { - fn render(&mut self, _: &mut ViewContext) -> impl Element { + fn render(&mut self, _: &mut ViewContext) -> impl IntoElement { div() // Intentionally left empty because the platform will render icons for the dragged files } } diff --git a/crates/gpui2/src/view.rs b/crates/gpui2/src/view.rs index 39b01c61e0f4a50e9f97df23f92744854fb7389c..6b9b452cbb196f43ca0d0b43c5a8cbc28ba3cffe 100644 --- a/crates/gpui2/src/view.rs +++ b/crates/gpui2/src/view.rs @@ -87,7 +87,7 @@ impl Element for View { cx: &mut WindowContext, ) -> (LayoutId, Self::State) { let mut element = self.update(cx, |view, cx| view.render(cx).into_any_element()); - let layout_id = element.layout(cx); + let layout_id = element.request_layout(cx); (layout_id, Some(element)) } @@ -321,7 +321,7 @@ mod any_view { ) -> (LayoutId, AnyElement) { let view = view.clone().downcast::().unwrap(); let mut element = view.update(cx, |view, cx| view.render(cx).into_any_element()); - let layout_id = element.layout(cx); + let layout_id = element.request_layout(cx); (layout_id, element) } diff --git a/crates/language_selector2/src/active_buffer_language.rs b/crates/language_selector2/src/active_buffer_language.rs index 434a6c44206842d37da7252d9c5d45dd5ea65cce..d5f177f7d61a649b6b438782e265c0e5eb9a4b77 100644 --- a/crates/language_selector2/src/active_buffer_language.rs +++ b/crates/language_selector2/src/active_buffer_language.rs @@ -1,7 +1,5 @@ use editor::Editor; -use gpui::{ - div, Element, IntoElement, ParentElement, Render, Subscription, View, ViewContext, WeakView, -}; +use gpui::{div, IntoElement, ParentElement, Render, Subscription, View, ViewContext, WeakView}; use std::sync::Arc; use ui::{Button, ButtonCommon, Clickable, LabelSize, Tooltip}; use workspace::{item::ItemHandle, StatusItemView, Workspace}; @@ -38,7 +36,7 @@ impl ActiveBufferLanguage { } impl Render for ActiveBufferLanguage { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { div().when_some(self.active_language.as_ref(), |el, active_language| { let active_language_text = if let Some(active_language_text) = active_language { active_language_text.to_string() diff --git a/crates/language_selector2/src/language_selector.rs b/crates/language_selector2/src/language_selector.rs index 8343cef03f5c9f9c7fe281ee2f812f5fa2aff170..33b2e481263e9fea84e77993668de16f5735726f 100644 --- a/crates/language_selector2/src/language_selector.rs +++ b/crates/language_selector2/src/language_selector.rs @@ -67,7 +67,7 @@ impl LanguageSelector { } impl Render for LanguageSelector { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { v_stack().w(rems(34.)).child(self.picker.clone()) } } diff --git a/crates/language_tools2/src/lsp_log.rs b/crates/language_tools2/src/lsp_log.rs index 13a2eab30c911defc6c1e488edd48385def5ec5c..e38de7d3734a9e95cb301c4139dc6b998f033bbd 100644 --- a/crates/language_tools2/src/lsp_log.rs +++ b/crates/language_tools2/src/lsp_log.rs @@ -2,9 +2,9 @@ use collections::{HashMap, VecDeque}; use editor::{Editor, EditorEvent, MoveToEnd}; use futures::{channel::mpsc, StreamExt}; use gpui::{ - actions, div, AnchorCorner, AnyElement, AppContext, Context, Element, EventEmitter, - FocusHandle, FocusableView, IntoElement, Model, ModelContext, ParentElement, Render, Styled, - Subscription, View, ViewContext, VisualContext, WeakModel, WindowContext, + actions, div, AnchorCorner, AnyElement, AppContext, Context, EventEmitter, FocusHandle, + FocusableView, IntoElement, Model, ModelContext, ParentElement, Render, Styled, Subscription, + View, ViewContext, VisualContext, WeakModel, WindowContext, }; use language::{LanguageServerId, LanguageServerName}; use lsp::IoKind; @@ -595,9 +595,9 @@ fn log_contents(lines: &VecDeque) -> String { } impl Render for LspLogView { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { self.editor - .update(cx, |editor, cx| editor.render(cx).into_any()) + .update(cx, |editor, cx| editor.render(cx).into_any_element()) } } @@ -708,7 +708,7 @@ impl ToolbarItemView for LspLogToolbarItemView { } impl Render for LspLogToolbarItemView { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let Some(log_view) = self.log_view.clone() else { return div(); }; diff --git a/crates/language_tools2/src/syntax_tree_view.rs b/crates/language_tools2/src/syntax_tree_view.rs index 20d6b6c82abc3813621833d1736cfedbe563532b..a36264261e8840a20ccb89c4ca7ca28fcd1b3851 100644 --- a/crates/language_tools2/src/syntax_tree_view.rs +++ b/crates/language_tools2/src/syntax_tree_view.rs @@ -1,6 +1,6 @@ use editor::{scroll::autoscroll::Autoscroll, Anchor, Editor, ExcerptId}; use gpui::{ - actions, canvas, div, rems, uniform_list, AnyElement, AppContext, AvailableSpace, Div, Element, + actions, canvas, div, rems, uniform_list, AnyElement, AppContext, AvailableSpace, Div, EventEmitter, FocusHandle, FocusableView, Hsla, InteractiveElement, IntoElement, Model, MouseButton, MouseDownEvent, MouseMoveEvent, ParentElement, Pixels, Render, Styled, UniformListScrollHandle, View, ViewContext, VisualContext, WeakView, WindowContext, @@ -305,7 +305,7 @@ impl SyntaxTreeView { } impl Render for SyntaxTreeView { - fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> impl Element { + fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> impl IntoElement { let settings = ThemeSettings::get_global(cx); let line_height = cx .text_style() @@ -505,7 +505,7 @@ fn format_node_range(node: Node) -> String { } impl Render for SyntaxTreeToolbarItemView { - fn render(&mut self, cx: &mut ViewContext<'_, Self>) -> impl Element { + fn render(&mut self, cx: &mut ViewContext<'_, Self>) -> impl IntoElement { self.render_menu(cx) .unwrap_or_else(|| popover_menu("Empty Syntax Tree")) } diff --git a/crates/outline2/src/outline.rs b/crates/outline2/src/outline.rs index e33d22c9edfae6a8629195d5c7288c71157c02bd..75d1a0935734c4d40226554202fb24c3a5ce2562 100644 --- a/crates/outline2/src/outline.rs +++ b/crates/outline2/src/outline.rs @@ -57,7 +57,7 @@ impl EventEmitter for OutlineView {} impl ModalView for OutlineView {} impl Render for OutlineView { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { v_stack().w(rems(34.)).child(self.picker.clone()) } } diff --git a/crates/picker2/src/picker2.rs b/crates/picker2/src/picker2.rs index cee8fb74ff9c168c1f186adc5d3313c525ab9920..ad7552052055be100bcd3d1cad9e398416387aa6 100644 --- a/crates/picker2/src/picker2.rs +++ b/crates/picker2/src/picker2.rs @@ -235,7 +235,7 @@ impl EventEmitter for Picker {} impl ModalView for Picker {} impl Render for Picker { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let picker_editor = h_stack() .overflow_hidden() .flex_none() diff --git a/crates/project_panel2/src/project_panel.rs b/crates/project_panel2/src/project_panel.rs index c125f76cd1aef9d95fd2c3b3e49c2bde3a65854e..8ab364e0c1ec78df405bbf43a8c8263206cd18cf 100644 --- a/crates/project_panel2/src/project_panel.rs +++ b/crates/project_panel2/src/project_panel.rs @@ -1480,7 +1480,7 @@ impl ProjectPanel { } impl Render for ProjectPanel { - fn render(&mut self, cx: &mut gpui::ViewContext) -> impl Element { + fn render(&mut self, cx: &mut gpui::ViewContext) -> impl IntoElement { let has_worktree = self.visible_entries.len() != 0; if has_worktree { diff --git a/crates/quick_action_bar2/src/quick_action_bar.rs b/crates/quick_action_bar2/src/quick_action_bar.rs index 44ca0150e85a108ca2b371fb7f345efd1823d3fc..d8c42589d63bea9775145f6efb211d64077d3af0 100644 --- a/crates/quick_action_bar2/src/quick_action_bar.rs +++ b/crates/quick_action_bar2/src/quick_action_bar.rs @@ -36,7 +36,7 @@ impl QuickActionBar { } impl Render for QuickActionBar { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let Some(editor) = self.active_editor() else { return div().id("empty quick action bar"); }; @@ -136,9 +136,7 @@ impl QuickActionBarButton { } impl RenderOnce for QuickActionBarButton { - type Output = IconButton; - - fn render(self, _: &mut WindowContext) -> Self::Output { + fn render(self, _: &mut WindowContext) -> impl IntoElement { let tooltip = self.tooltip.clone(); let action = self.action.boxed_clone(); diff --git a/crates/recent_projects2/src/highlighted_workspace_location.rs b/crates/recent_projects2/src/highlighted_workspace_location.rs index 2df4409a5fdc20b15ef8e14ccd3b56d082fd1745..b31dabe8bd85d48d8f516292850c171dcee66a13 100644 --- a/crates/recent_projects2/src/highlighted_workspace_location.rs +++ b/crates/recent_projects2/src/highlighted_workspace_location.rs @@ -43,9 +43,7 @@ impl HighlightedText { } impl RenderOnce for HighlightedText { - type Output = HighlightedLabel; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { HighlightedLabel::new(self.text, self.highlight_positions) } } diff --git a/crates/recent_projects2/src/recent_projects.rs b/crates/recent_projects2/src/recent_projects.rs index 4aded62ddf96fa2d0fb7f6ebd17f57717cfde1b5..c3b2c21d522ed3efdbf208433e6070b2b49dcf44 100644 --- a/crates/recent_projects2/src/recent_projects.rs +++ b/crates/recent_projects2/src/recent_projects.rs @@ -103,7 +103,7 @@ impl FocusableView for RecentProjects { } impl Render for RecentProjects { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { v_stack() .w(rems(self.rem_width)) .child(self.picker.clone()) diff --git a/crates/search2/src/buffer_search.rs b/crates/search2/src/buffer_search.rs index be01266eef3830fe183d97d5d4a5afe444e856c0..67aa4955bc692483faafb9b6291e9e8550dac859 100644 --- a/crates/search2/src/buffer_search.rs +++ b/crates/search2/src/buffer_search.rs @@ -101,7 +101,7 @@ impl BufferSearchBar { impl EventEmitter for BufferSearchBar {} impl EventEmitter for BufferSearchBar {} impl Render for BufferSearchBar { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { if self.dismissed { return div(); } diff --git a/crates/search2/src/project_search.rs b/crates/search2/src/project_search.rs index da0c9a4ca56280c818d9f0ad05b5435c99fae356..9a91d619a43cf2cd4e9c024006494f2aa9b19989 100644 --- a/crates/search2/src/project_search.rs +++ b/crates/search2/src/project_search.rs @@ -279,7 +279,7 @@ pub enum ViewEvent { impl EventEmitter for ProjectSearchView {} impl Render for ProjectSearchView { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { if self.has_matches() { div() .flex_1() @@ -1548,7 +1548,7 @@ impl ProjectSearchBar { } impl Render for ProjectSearchBar { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let Some(search) = self.active_project_search.clone() else { return div(); }; diff --git a/crates/story/src/story.rs b/crates/story/src/story.rs index 1a3e84c0d919d91caac5b0d6bc90654510237714..65bebfc423f3812f28a31c6c42d9d6307189fcf2 100644 --- a/crates/story/src/story.rs +++ b/crates/story/src/story.rs @@ -1,6 +1,5 @@ use gpui::{ - div, hsla, prelude::*, px, rems, AnyElement, Div, ElementId, Hsla, SharedString, Stateful, - WindowContext, + div, hsla, prelude::*, px, rems, AnyElement, Div, ElementId, Hsla, SharedString, WindowContext, }; use itertools::Itertools; use smallvec::SmallVec; @@ -74,9 +73,7 @@ impl ParentElement for StoryContainer { } impl RenderOnce for StoryContainer { - type Output = Stateful
; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { div() .size_full() .flex() @@ -294,9 +291,7 @@ impl StoryItem { } impl RenderOnce for StoryItem { - type Output = Div; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { div() .my_2() .flex() @@ -358,9 +353,7 @@ impl StorySection { } impl RenderOnce for StorySection { - type Output = Div; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { let children: SmallVec<[AnyElement; 2]> = SmallVec::from_iter(Itertools::intersperse_with( self.children.into_iter(), || Story::divider().into_any_element(), diff --git a/crates/storybook2/src/stories/auto_height_editor.rs b/crates/storybook2/src/stories/auto_height_editor.rs index a98050230b72732d76bf62f4522180337c7393ea..6d835155621c44993c701d83151f420b527de794 100644 --- a/crates/storybook2/src/stories/auto_height_editor.rs +++ b/crates/storybook2/src/stories/auto_height_editor.rs @@ -1,6 +1,6 @@ use editor::Editor; use gpui::{ - div, white, Element, KeyBinding, ParentElement, Render, Styled, View, ViewContext, + div, white, IntoElement, KeyBinding, ParentElement, Render, Styled, View, ViewContext, VisualContext, WindowContext, }; @@ -22,7 +22,7 @@ impl AutoHeightEditorStory { } impl Render for AutoHeightEditorStory { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { div() .size_full() .bg(white()) diff --git a/crates/storybook2/src/stories/cursor.rs b/crates/storybook2/src/stories/cursor.rs index ebd4d2d8e9654ca1dd22e250cd0924c7514573b1..834371bd87aee93f65b8bf3f49f91623dc487ab4 100644 --- a/crates/storybook2/src/stories/cursor.rs +++ b/crates/storybook2/src/stories/cursor.rs @@ -5,7 +5,7 @@ use ui::prelude::*; pub struct CursorStory; impl Render for CursorStory { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { let all_cursors: [(&str, Box) -> Stateful
>); 19] = [ ( "cursor_default", diff --git a/crates/storybook2/src/stories/focus.rs b/crates/storybook2/src/stories/focus.rs index ead6f701f9516680eb5e553f9cef069cd9abc5f8..4240aa6fd19c93e54f5389df7f7cec0ad97c099e 100644 --- a/crates/storybook2/src/stories/focus.rs +++ b/crates/storybook2/src/stories/focus.rs @@ -56,7 +56,7 @@ impl FocusStory { } impl Render for FocusStory { - fn render(&mut self, cx: &mut gpui::ViewContext) -> impl Element { + fn render(&mut self, cx: &mut gpui::ViewContext) -> impl IntoElement { let theme = cx.theme(); let color_1 = theme.status().created; let color_2 = theme.status().modified; diff --git a/crates/storybook2/src/stories/kitchen_sink.rs b/crates/storybook2/src/stories/kitchen_sink.rs index 97d46a2a74871278ccde5fe91e9d10c2c398e2c9..1966b9ffa837ab75000dc16e7b31228a4b3c2f6e 100644 --- a/crates/storybook2/src/stories/kitchen_sink.rs +++ b/crates/storybook2/src/stories/kitchen_sink.rs @@ -14,7 +14,7 @@ impl KitchenSinkStory { } impl Render for KitchenSinkStory { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let component_stories = ComponentStory::iter() .map(|selector| selector.story(cx)) .collect::>(); diff --git a/crates/storybook2/src/stories/overflow_scroll.rs b/crates/storybook2/src/stories/overflow_scroll.rs index bdd405eccf5c2ed17561adc69d93f3caa54ec524..32ab940be5d68fdf31681c5ae787e6a27a466a7f 100644 --- a/crates/storybook2/src/stories/overflow_scroll.rs +++ b/crates/storybook2/src/stories/overflow_scroll.rs @@ -6,7 +6,7 @@ use ui::prelude::*; pub struct OverflowScrollStory; impl Render for OverflowScrollStory { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { Story::container() .child(Story::title("Overflow Scroll")) .child(Story::label("`overflow_x_scroll`")) diff --git a/crates/storybook2/src/stories/picker.rs b/crates/storybook2/src/stories/picker.rs index 3ad04002b8495f832e7d818255628efc6ab3833d..515c967ae5a558928561ee458b4f2544f9659048 100644 --- a/crates/storybook2/src/stories/picker.rs +++ b/crates/storybook2/src/stories/picker.rs @@ -200,7 +200,7 @@ impl PickerStory { } impl Render for PickerStory { - fn render(&mut self, cx: &mut gpui::ViewContext) -> impl Element { + fn render(&mut self, cx: &mut gpui::ViewContext) -> impl IntoElement { div() .bg(cx.theme().styles.colors.background) .size_full() diff --git a/crates/storybook2/src/stories/scroll.rs b/crates/storybook2/src/stories/scroll.rs index a5f6c484c91baa7726e492c78664101e64f2cb3c..a0318dc30ea56d0739436ee467882b2f7f06a7d7 100644 --- a/crates/storybook2/src/stories/scroll.rs +++ b/crates/storybook2/src/stories/scroll.rs @@ -11,7 +11,7 @@ impl ScrollStory { } impl Render for ScrollStory { - fn render(&mut self, cx: &mut gpui::ViewContext) -> impl Element { + fn render(&mut self, cx: &mut gpui::ViewContext) -> impl IntoElement { let theme = cx.theme(); let color_1 = theme.status().created; let color_2 = theme.status().modified; diff --git a/crates/storybook2/src/stories/text.rs b/crates/storybook2/src/stories/text.rs index 49c10d6729d4295127b7db39989914e0c4d94a50..8bf35b04f2909d32917f4ff20979e3f8db08ae34 100644 --- a/crates/storybook2/src/stories/text.rs +++ b/crates/storybook2/src/stories/text.rs @@ -1,6 +1,6 @@ use gpui::{ - div, green, red, Element, HighlightStyle, InteractiveText, IntoElement, ParentElement, Render, - Styled, StyledText, View, VisualContext, WindowContext, + div, green, red, HighlightStyle, InteractiveText, IntoElement, ParentElement, Render, Styled, + StyledText, View, VisualContext, WindowContext, }; use indoc::indoc; use story::*; @@ -14,7 +14,7 @@ impl TextStory { } impl Render for TextStory { - fn render(&mut self, cx: &mut gpui::ViewContext) -> impl Element { + fn render(&mut self, cx: &mut gpui::ViewContext) -> impl IntoElement { StoryContainer::new("Text Story", "crates/storybook2/src/stories/text.rs") .children( vec![ diff --git a/crates/storybook2/src/stories/viewport_units.rs b/crates/storybook2/src/stories/viewport_units.rs index edd0a730605160e88df46f2762b46b077931b857..30782a1a1617e350863756fedf77179e459eea4d 100644 --- a/crates/storybook2/src/stories/viewport_units.rs +++ b/crates/storybook2/src/stories/viewport_units.rs @@ -6,7 +6,7 @@ use ui::prelude::*; pub struct ViewportUnitsStory; impl Render for ViewportUnitsStory { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { Story::container().child( div() .flex() diff --git a/crates/storybook2/src/stories/z_index.rs b/crates/storybook2/src/stories/z_index.rs index 4ae6279d75e69c3c2f40eb44f7cf009e0d4ac872..b6e49bfae32b046242e96a5de34d30c3be806b94 100644 --- a/crates/storybook2/src/stories/z_index.rs +++ b/crates/storybook2/src/stories/z_index.rs @@ -7,7 +7,7 @@ use ui::prelude::*; pub struct ZIndexStory; impl Render for ZIndexStory { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { Story::container().child(Story::title("z-index")).child( div() .flex() @@ -80,9 +80,7 @@ struct ZIndexExample { } impl RenderOnce for ZIndexExample { - type Output = Div; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { div() .relative() .size_full() diff --git a/crates/storybook2/src/storybook2.rs b/crates/storybook2/src/storybook2.rs index 1b9ddd4b9609f663518bbe7c6cd0ee907bc083a3..cbbe97f57fbd372f0c517f28d9a415310a3b9329 100644 --- a/crates/storybook2/src/storybook2.rs +++ b/crates/storybook2/src/storybook2.rs @@ -113,7 +113,7 @@ impl StoryWrapper { } impl Render for StoryWrapper { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { div() .flex() .flex_col() diff --git a/crates/terminal_view2/src/terminal_panel.rs b/crates/terminal_view2/src/terminal_panel.rs index 05e4198f21b9504510a640909885a847db557167..9e193e83b7d54cad1d7ca0d6a7cbc5ab857a95a8 100644 --- a/crates/terminal_view2/src/terminal_panel.rs +++ b/crates/terminal_view2/src/terminal_panel.rs @@ -3,9 +3,9 @@ use std::{path::PathBuf, sync::Arc}; use crate::TerminalView; use db::kvp::KEY_VALUE_STORE; use gpui::{ - actions, div, serde_json, AppContext, AsyncWindowContext, Element, Entity, EventEmitter, - ExternalPaths, FocusHandle, FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, - Subscription, Task, View, ViewContext, VisualContext, WeakView, WindowContext, + actions, div, serde_json, AppContext, AsyncWindowContext, Entity, EventEmitter, ExternalPaths, + FocusHandle, FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, Subscription, + Task, View, ViewContext, VisualContext, WeakView, WindowContext, }; use project::Fs; use serde::{Deserialize, Serialize}; @@ -329,7 +329,7 @@ impl TerminalPanel { impl EventEmitter for TerminalPanel {} impl Render for TerminalPanel { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { div().size_full().child(self.pane.clone()) } } diff --git a/crates/terminal_view2/src/terminal_view.rs b/crates/terminal_view2/src/terminal_view.rs index 46409d1102da45a80747ef3f1c5ff17af5b3d297..d4dea29b49e71e66604ec56799d166778792ae9a 100644 --- a/crates/terminal_view2/src/terminal_view.rs +++ b/crates/terminal_view2/src/terminal_view.rs @@ -617,7 +617,7 @@ impl TerminalView { } impl Render for TerminalView { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let terminal_handle = self.terminal.clone(); let focused = self.focus_handle.is_focused(cx); diff --git a/crates/theme2/src/styles/stories/color.rs b/crates/theme2/src/styles/stories/color.rs index f406f64cec839e79f6ac4a6519165e428bba1930..90e84bcf0f2ded0a2404526ff390281026f97b36 100644 --- a/crates/theme2/src/styles/stories/color.rs +++ b/crates/theme2/src/styles/stories/color.rs @@ -7,7 +7,7 @@ use crate::{default_color_scales, ColorScaleStep}; pub struct ColorsStory; impl Render for ColorsStory { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let color_scales = default_color_scales(); Story::container().child(Story::title("Colors")).child( diff --git a/crates/theme2/src/styles/stories/players.rs b/crates/theme2/src/styles/stories/players.rs index d7ab054b2d32f792f95f5ba9001209ca326d03ed..21af258641760da33e90e20d9089ba0416d48768 100644 --- a/crates/theme2/src/styles/stories/players.rs +++ b/crates/theme2/src/styles/stories/players.rs @@ -1,4 +1,4 @@ -use gpui::{div, img, px, Element, ParentElement, Render, Styled, ViewContext}; +use gpui::{div, img, px, IntoElement, ParentElement, Render, Styled, ViewContext}; use story::Story; use crate::{ActiveTheme, PlayerColors}; @@ -6,7 +6,7 @@ use crate::{ActiveTheme, PlayerColors}; pub struct PlayerStory; impl Render for PlayerStory { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { Story::container().child( div() .flex() diff --git a/crates/theme_selector2/src/theme_selector.rs b/crates/theme_selector2/src/theme_selector.rs index aa268c298983213d8c40a656daa2a6764e44dd58..44f2069694c421636e0714cd2f02093f577b02f7 100644 --- a/crates/theme_selector2/src/theme_selector.rs +++ b/crates/theme_selector2/src/theme_selector.rs @@ -69,7 +69,7 @@ impl FocusableView for ThemeSelector { } impl Render for ThemeSelector { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { v_stack().w(rems(34.)).child(self.picker.clone()) } } diff --git a/crates/ui2/src/components/avatar.rs b/crates/ui2/src/components/avatar.rs index 257e46989b6faf0b615d668aa3d18e3ede8dc83d..b1dba69520c4d02ac735885f69d84db5d653236b 100644 --- a/crates/ui2/src/components/avatar.rs +++ b/crates/ui2/src/components/avatar.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -use gpui::{img, Div, Hsla, ImageSource, Img, IntoElement, Styled}; +use gpui::{img, Hsla, ImageSource, Img, IntoElement, Styled}; #[derive(Debug, Default, PartialEq, Clone)] pub enum Shape { @@ -16,9 +16,7 @@ pub struct Avatar { } impl RenderOnce for Avatar { - type Output = Div; - - fn render(mut self, cx: &mut WindowContext) -> Self::Output { + fn render(mut self, cx: &mut WindowContext) -> impl IntoElement { if self.image.style().corner_radii.top_left.is_none() { self = self.shape(Shape::Circle); } diff --git a/crates/ui2/src/components/button/button.rs b/crates/ui2/src/components/button/button.rs index 2ad12919fba8a0daf31b3c7d54d0032ee5777e1b..d46273fb916d380eda66df9a4bb41fd951661f24 100644 --- a/crates/ui2/src/components/button/button.rs +++ b/crates/ui2/src/components/button/button.rs @@ -136,9 +136,8 @@ impl ButtonCommon for Button { } impl RenderOnce for Button { - type Output = ButtonLike; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + #[allow(refining_impl_trait)] + fn render(self, _cx: &mut WindowContext) -> ButtonLike { let is_disabled = self.base.disabled; let is_selected = self.base.selected; diff --git a/crates/ui2/src/components/button/button_icon.rs b/crates/ui2/src/components/button/button_icon.rs index a82aa14e6ed249d6615c01d6d4567510afdf9d9f..29b23747b22eed50a112ba2a378b9620c4021443 100644 --- a/crates/ui2/src/components/button/button_icon.rs +++ b/crates/ui2/src/components/button/button_icon.rs @@ -63,9 +63,7 @@ impl Selectable for ButtonIcon { } impl RenderOnce for ButtonIcon { - type Output = IconElement; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { let icon = self .selected_icon .filter(|_| self.selected) diff --git a/crates/ui2/src/components/button/button_like.rs b/crates/ui2/src/components/button/button_like.rs index 0f304ae15d970172825a0ae7f487da7b3ac555b1..f255104432816f090aad741fdcb5800d589ff74b 100644 --- a/crates/ui2/src/components/button/button_like.rs +++ b/crates/ui2/src/components/button/button_like.rs @@ -1,5 +1,5 @@ use gpui::{relative, DefiniteLength, MouseButton}; -use gpui::{rems, transparent_black, AnyElement, AnyView, ClickEvent, Div, Hsla, Rems, Stateful}; +use gpui::{rems, transparent_black, AnyElement, AnyView, ClickEvent, Hsla, Rems}; use smallvec::SmallVec; use crate::prelude::*; @@ -363,9 +363,7 @@ impl ParentElement for ButtonLike { } impl RenderOnce for ButtonLike { - type Output = Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { self.base .h_flex() .id(self.id.clone()) diff --git a/crates/ui2/src/components/button/icon_button.rs b/crates/ui2/src/components/button/icon_button.rs index 9dcb0c04d49f671331a2f0f8d0e1ed7620d98626..0a75f361cfe10eae59c7da0d0540cac46c81e9c8 100644 --- a/crates/ui2/src/components/button/icon_button.rs +++ b/crates/ui2/src/components/button/icon_button.rs @@ -106,9 +106,7 @@ impl VisibleOnHover for IconButton { } impl RenderOnce for IconButton { - type Output = ButtonLike; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { let is_disabled = self.base.disabled; let is_selected = self.base.selected; diff --git a/crates/ui2/src/components/button/toggle_button.rs b/crates/ui2/src/components/button/toggle_button.rs index 7ac642011f97299dabbd483abf0ed49f41a02ead..f97498b0d837539f7a46a9def47e8040d8a429dc 100644 --- a/crates/ui2/src/components/button/toggle_button.rs +++ b/crates/ui2/src/components/button/toggle_button.rs @@ -99,9 +99,7 @@ impl ButtonCommon for ToggleButton { } impl RenderOnce for ToggleButton { - type Output = ButtonLike; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { let is_disabled = self.base.disabled; let is_selected = self.base.selected; diff --git a/crates/ui2/src/components/checkbox.rs b/crates/ui2/src/components/checkbox.rs index fd92e9694608da5e273f32f262e55bd7b771b220..a793b8ca10f1e1b791052e5b8807db2e02874ffc 100644 --- a/crates/ui2/src/components/checkbox.rs +++ b/crates/ui2/src/components/checkbox.rs @@ -1,4 +1,4 @@ -use gpui::{div, prelude::*, Div, Element, ElementId, IntoElement, Styled, WindowContext}; +use gpui::{div, prelude::*, Element, ElementId, IntoElement, Styled, WindowContext}; use crate::prelude::*; use crate::{Color, Icon, IconElement, Selection}; @@ -19,9 +19,7 @@ pub struct Checkbox { } impl RenderOnce for Checkbox { - type Output = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { let group_id = format!("checkbox_group_{:?}", self.id); let icon = match self.checked { diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rs index 046fb26fb0a83f706d2604d0c935b78d21eca3eb..8666ec65651d6f00cbe225f7b065521673326037 100644 --- a/crates/ui2/src/components/context_menu.rs +++ b/crates/ui2/src/components/context_menu.rs @@ -232,7 +232,7 @@ impl ContextMenuItem { } impl Render for ContextMenu { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { div().elevation_2(cx).flex().flex_row().child( v_stack() .min_w(px(200.)) diff --git a/crates/ui2/src/components/disclosure.rs b/crates/ui2/src/components/disclosure.rs index 663fba30ca873536319f08680dcacaf9ba0bd7e7..d4349f61a0f53b7f70af3255576aaa4c715796ae 100644 --- a/crates/ui2/src/components/disclosure.rs +++ b/crates/ui2/src/components/disclosure.rs @@ -28,9 +28,7 @@ impl Disclosure { } impl RenderOnce for Disclosure { - type Output = IconButton; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { IconButton::new( self.id, match self.is_open { diff --git a/crates/ui2/src/components/divider.rs b/crates/ui2/src/components/divider.rs index dd30ce0ec57e60f78d37b764656c8507ca7bb242..2567c3fc3476c72819f0d30f5eae2a3e74f68059 100644 --- a/crates/ui2/src/components/divider.rs +++ b/crates/ui2/src/components/divider.rs @@ -1,4 +1,4 @@ -use gpui::{Div, Hsla, IntoElement}; +use gpui::{Hsla, IntoElement}; use crate::prelude::*; @@ -31,9 +31,7 @@ pub struct Divider { } impl RenderOnce for Divider { - type Output = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { div() .map(|this| match self.direction { DividerDirection::Horizontal => { diff --git a/crates/ui2/src/components/icon.rs b/crates/ui2/src/components/icon.rs index 0c618f291528f8f41bc6f22f428322ad1c67f20b..df1c82bb666d2a20084387f80a5896f73266d598 100644 --- a/crates/ui2/src/components/icon.rs +++ b/crates/ui2/src/components/icon.rs @@ -1,4 +1,4 @@ -use gpui::{rems, svg, IntoElement, Rems, Svg}; +use gpui::{rems, svg, IntoElement, Rems}; use strum::EnumIter; use crate::prelude::*; @@ -200,9 +200,7 @@ pub struct IconElement { } impl RenderOnce for IconElement { - type Output = Svg; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { svg() .size(self.size.rems()) .flex_none() diff --git a/crates/ui2/src/components/indicator.rs b/crates/ui2/src/components/indicator.rs index f3dc62d20f4d8b057320d74aa49e182d0869e7f9..97d38b1f22face4b38e97de9cf783206d3749e19 100644 --- a/crates/ui2/src/components/indicator.rs +++ b/crates/ui2/src/components/indicator.rs @@ -1,4 +1,4 @@ -use gpui::{Div, Position}; +use gpui::Position; use crate::prelude::*; @@ -45,9 +45,7 @@ impl Indicator { } impl RenderOnce for Indicator { - type Output = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { div() .flex_none() .map(|this| match self.style { diff --git a/crates/ui2/src/components/keybinding.rs b/crates/ui2/src/components/keybinding.rs index 6f6388548971baf317e1b9b287178c1dac7ebf7d..a07ce1116cebc9cf5bfb2be9a0c8948196be3e02 100644 --- a/crates/ui2/src/components/keybinding.rs +++ b/crates/ui2/src/components/keybinding.rs @@ -1,5 +1,5 @@ use crate::{h_stack, prelude::*, Icon, IconElement, IconSize}; -use gpui::{relative, rems, Action, Div, FocusHandle, IntoElement, Keystroke}; +use gpui::{relative, rems, Action, FocusHandle, IntoElement, Keystroke}; #[derive(IntoElement, Clone)] pub struct KeyBinding { @@ -11,9 +11,7 @@ pub struct KeyBinding { } impl RenderOnce for KeyBinding { - type Output = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { h_stack() .flex_none() .gap_2() @@ -87,9 +85,7 @@ pub struct Key { } impl RenderOnce for Key { - type Output = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { let single_char = self.key.len() == 1; div() @@ -121,9 +117,7 @@ pub struct KeyIcon { } impl RenderOnce for KeyIcon { - type Output = Div; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { div() .w(rems(14. / 16.)) .child(IconElement::new(self.icon).size(IconSize::Small)) diff --git a/crates/ui2/src/components/label/highlighted_label.rs b/crates/ui2/src/components/label/highlighted_label.rs index 08dfbe2391a270e9a019d8df59d9ececc413cd8c..d70c2d1b51c82e426a508fb413a35d4f4b9e3a70 100644 --- a/crates/ui2/src/components/label/highlighted_label.rs +++ b/crates/ui2/src/components/label/highlighted_label.rs @@ -46,9 +46,7 @@ impl LabelCommon for HighlightedLabel { } impl RenderOnce for HighlightedLabel { - type Output = LabelLike; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { let highlight_color = cx.theme().colors().text_accent; let mut highlight_indices = self.highlight_indices.iter().copied().peekable(); diff --git a/crates/ui2/src/components/label/label.rs b/crates/ui2/src/components/label/label.rs index 888cd506d78d77ec2314b31ca48c28f0c288a7af..61f463a531b85dc9a2780a334c8a771ab5c9f40b 100644 --- a/crates/ui2/src/components/label/label.rs +++ b/crates/ui2/src/components/label/label.rs @@ -40,9 +40,7 @@ impl LabelCommon for Label { } impl RenderOnce for Label { - type Output = LabelLike; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { self.base.child(self.label) } } diff --git a/crates/ui2/src/components/label/label_like.rs b/crates/ui2/src/components/label/label_like.rs index 54e383eb487e274140eb433b18c560f21f5daa20..436461fddeaffa9b6d87af0de11b11f48cafec68 100644 --- a/crates/ui2/src/components/label/label_like.rs +++ b/crates/ui2/src/components/label/label_like.rs @@ -1,4 +1,4 @@ -use gpui::{relative, AnyElement, Div, Styled}; +use gpui::{relative, AnyElement, Styled}; use smallvec::SmallVec; use crate::prelude::*; @@ -76,9 +76,7 @@ impl ParentElement for LabelLike { } impl RenderOnce for LabelLike { - type Output = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { div() .when(self.strikethrough, |this| { this.relative().child( diff --git a/crates/ui2/src/components/list/list.rs b/crates/ui2/src/components/list/list.rs index 23ebd8427c55932f6df6ad8e0a2b79fbac708096..8c657fdd92a4d35891e2cdae30193ac147741907 100644 --- a/crates/ui2/src/components/list/list.rs +++ b/crates/ui2/src/components/list/list.rs @@ -1,4 +1,4 @@ -use gpui::{AnyElement, Div}; +use gpui::AnyElement; use smallvec::SmallVec; use crate::{prelude::*, v_stack, Label, ListHeader}; @@ -46,9 +46,7 @@ impl ParentElement for List { } impl RenderOnce for List { - type Output = Div; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { v_stack().w_full().py_1().children(self.header).map(|this| { match (self.children.is_empty(), self.toggle) { (false, _) => this.children(self.children), diff --git a/crates/ui2/src/components/list/list_header.rs b/crates/ui2/src/components/list/list_header.rs index 9726ed2c2b524f999a9f178237faff51e8164866..1bed11601512348c7227b7e048468946145ffe41 100644 --- a/crates/ui2/src/components/list/list_header.rs +++ b/crates/ui2/src/components/list/list_header.rs @@ -1,6 +1,5 @@ -use gpui::{AnyElement, ClickEvent, Div, Stateful}; - use crate::{h_stack, prelude::*, Disclosure, Label}; +use gpui::{AnyElement, ClickEvent}; #[derive(IntoElement)] pub struct ListHeader { @@ -76,9 +75,7 @@ impl Selectable for ListHeader { } impl RenderOnce for ListHeader { - type Output = Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { h_stack() .id(self.label.clone()) .w_full() diff --git a/crates/ui2/src/components/list/list_item.rs b/crates/ui2/src/components/list/list_item.rs index 88ade283cc40a34b1ad3b40aa5db6c1a531f37fd..d43de18f9317e9f17d303294f1285d2d1c954b42 100644 --- a/crates/ui2/src/components/list/list_item.rs +++ b/crates/ui2/src/components/list/list_item.rs @@ -1,6 +1,4 @@ -use gpui::{ - px, AnyElement, AnyView, ClickEvent, Div, MouseButton, MouseDownEvent, Pixels, Stateful, -}; +use gpui::{px, AnyElement, AnyView, ClickEvent, MouseButton, MouseDownEvent, Pixels}; use smallvec::SmallVec; use crate::{prelude::*, Disclosure}; @@ -147,9 +145,7 @@ impl ParentElement for ListItem { } impl RenderOnce for ListItem { - type Output = Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { h_stack() .id(self.id) .w_full() diff --git a/crates/ui2/src/components/list/list_separator.rs b/crates/ui2/src/components/list/list_separator.rs index d7afb0ed930e260a8dba20cefd584e44b56a1593..59b85be5ce4a149ac9b3793cd029f8d420575f7b 100644 --- a/crates/ui2/src/components/list/list_separator.rs +++ b/crates/ui2/src/components/list/list_separator.rs @@ -1,14 +1,10 @@ -use gpui::Div; - use crate::prelude::*; #[derive(IntoElement)] pub struct ListSeparator; impl RenderOnce for ListSeparator { - type Output = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { div() .h_px() .w_full() diff --git a/crates/ui2/src/components/list/list_sub_header.rs b/crates/ui2/src/components/list/list_sub_header.rs index 9f49587a458eba5c8668bad17771609bbd7a493f..2e976b35178a2132cf1f0a6f2c154f03de249389 100644 --- a/crates/ui2/src/components/list/list_sub_header.rs +++ b/crates/ui2/src/components/list/list_sub_header.rs @@ -1,5 +1,3 @@ -use gpui::Div; - use crate::prelude::*; use crate::{h_stack, Icon, IconElement, IconSize, Label}; @@ -26,9 +24,7 @@ impl ListSubHeader { } impl RenderOnce for ListSubHeader { - type Output = Div; - - fn render(self, _cx: &mut WindowContext) -> Self::Output { + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { h_stack().flex_1().w_full().relative().py_1().child( div() .h_6() diff --git a/crates/ui2/src/components/popover.rs b/crates/ui2/src/components/popover.rs index 7d888ed3aa4f17dd68a14932102facbc606f0cca..e6fb8874449ec74db4d5d7dac605ec2821a966c2 100644 --- a/crates/ui2/src/components/popover.rs +++ b/crates/ui2/src/components/popover.rs @@ -1,5 +1,5 @@ use gpui::{ - div, AnyElement, Div, Element, ElementId, IntoElement, ParentElement, RenderOnce, Styled, + div, AnyElement, Element, ElementId, IntoElement, ParentElement, RenderOnce, Styled, WindowContext, }; use smallvec::SmallVec; @@ -41,9 +41,7 @@ pub struct Popover { } impl RenderOnce for Popover { - type Output = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Output { + fn render(self, cx: &mut WindowContext) -> impl IntoElement { div() .flex() .gap_1() diff --git a/crates/ui2/src/components/popover_menu.rs b/crates/ui2/src/components/popover_menu.rs index 3cc925e0b5f0db95cb04553fc330d82a124a4833..fb823b05dba3d18cea7992948abb50f827167e1c 100644 --- a/crates/ui2/src/components/popover_menu.rs +++ b/crates/ui2/src/components/popover_menu.rs @@ -153,7 +153,7 @@ impl Element for PopoverMenu { } let mut element = overlay.child(menu.clone()).into_any(); - menu_layout_id = Some(element.layout(cx)); + menu_layout_id = Some(element.request_layout(cx)); element }); @@ -164,7 +164,7 @@ impl Element for PopoverMenu { let child_layout_id = child_element .as_mut() - .map(|child_element| child_element.layout(cx)); + .map(|child_element| child_element.request_layout(cx)); let layout_id = cx.request_layout( &gpui::Style::default(), diff --git a/crates/ui2/src/components/right_click_menu.rs b/crates/ui2/src/components/right_click_menu.rs index 81f553a6a2cb2c2fdef829098e5ee5047358fb05..8bf40f61a8264ec3b00eec3ec844efa247876da7 100644 --- a/crates/ui2/src/components/right_click_menu.rs +++ b/crates/ui2/src/components/right_click_menu.rs @@ -81,7 +81,7 @@ impl Element for RightClickMenu { overlay = overlay.position(*position.borrow()); let mut element = overlay.child(menu.clone()).into_any(); - menu_layout_id = Some(element.layout(cx)); + menu_layout_id = Some(element.request_layout(cx)); element }); @@ -92,7 +92,7 @@ impl Element for RightClickMenu { let child_layout_id = child_element .as_mut() - .map(|child_element| child_element.layout(cx)); + .map(|child_element| child_element.request_layout(cx)); let layout_id = cx.request_layout( &gpui::Style::default(), diff --git a/crates/ui2/src/components/stories/avatar.rs b/crates/ui2/src/components/stories/avatar.rs index 99e370993a913454dde5553610db2ab881783866..e447486d69ca4a22a10e3d8975546b4ef661cf0d 100644 --- a/crates/ui2/src/components/stories/avatar.rs +++ b/crates/ui2/src/components/stories/avatar.rs @@ -7,7 +7,7 @@ use crate::Avatar; pub struct AvatarStory; impl Render for AvatarStory { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { Story::container() .child(Story::title_for::()) .child(Story::label("Default")) diff --git a/crates/ui2/src/components/stories/button.rs b/crates/ui2/src/components/stories/button.rs index 4ab8c33c8e9e8821889714b20084ee277d9d2422..7240812fa5a3a0d964a811795f925439def97670 100644 --- a/crates/ui2/src/components/stories/button.rs +++ b/crates/ui2/src/components/stories/button.rs @@ -7,7 +7,7 @@ use crate::{Button, ButtonStyle}; pub struct ButtonStory; impl Render for ButtonStory { - fn render(&mut self, _cx: &mut ViewContext) -> impl Element { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { Story::container() .child(Story::title_for::