diff --git a/crates/gpui3_macros/src/derive_element.rs b/crates/gpui3_macros/src/derive_element.rs index 08f50a92ba..6c57f6c966 100644 --- a/crates/gpui3_macros/src/derive_element.rs +++ b/crates/gpui3_macros/src/derive_element.rs @@ -21,30 +21,35 @@ pub fn derive_element(input: TokenStream) -> TokenStream { impl #impl_generics gpui3::Element for #type_name #ty_generics #where_clause { - type State = #state_type; - type FrameState = gpui3::AnyElement<#state_type>; + type ViewState = #state_type; + type ElementState = gpui3::AnyElement<#state_type>; + + fn element_id(&self) -> Option { + None + } fn layout( &mut self, state: &mut #state_type, - cx: &mut gpui3::ViewContext, - ) -> anyhow::Result<(gpui3::LayoutId, Self::FrameState)> { + element_state: Option, + cx: &mut gpui3::ViewContext, + ) -> (gpui3::LayoutId, Self::ElementState) { use gpui3::IntoAnyElement; let mut rendered_element = self.render(cx).into_any(); - let layout_id = rendered_element.layout(state, cx)?; - Ok((layout_id, rendered_element)) + let layout_id = rendered_element.layout(state, cx); + (layout_id, rendered_element) } fn paint( &mut self, bounds: gpui3::Bounds, - state: &mut Self::State, - rendered_element: &mut Self::FrameState, - cx: &mut gpui3::ViewContext, - ) -> anyhow::Result<()> { + state: &mut Self::ViewState, + element_state: &mut Self::ElementState, + cx: &mut gpui3::ViewContext, + ) { // TODO: Where do we get the `offset` from? - rendered_element.paint(state, None, cx) + element_state.paint(state, None, cx) } } }; diff --git a/crates/storybook2/src/stories/kitchen_sink.rs b/crates/storybook2/src/stories/kitchen_sink.rs index 325e84847f..91e34d3c69 100644 --- a/crates/storybook2/src/stories/kitchen_sink.rs +++ b/crates/storybook2/src/stories/kitchen_sink.rs @@ -18,7 +18,7 @@ impl KitchenSinkStory { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let element_stories = ElementStory::iter().map(|selector| selector.story()); let component_stories = ComponentStory::iter().map(|selector| selector.story()); diff --git a/crates/storybook2/src/stories/z_index.rs b/crates/storybook2/src/stories/z_index.rs index 17506484f1..89a146b4ec 100644 --- a/crates/storybook2/src/stories/z_index.rs +++ b/crates/storybook2/src/stories/z_index.rs @@ -19,7 +19,7 @@ impl ZIndexStory { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title(cx, "z-index")) .child( @@ -103,7 +103,7 @@ impl ZIndexExample { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { div() .relative() .size_full() diff --git a/crates/ui2/src/children.rs b/crates/ui2/src/children.rs index c7c81e9726..e9a55d1cc0 100644 --- a/crates/ui2/src/children.rs +++ b/crates/ui2/src/children.rs @@ -4,4 +4,4 @@ use gpui3::{AnyElement, ViewContext}; pub type HackyChildren = fn(&mut ViewContext, &dyn Any) -> Vec>; -pub type HackyChildrenPayload = Box; +pub type HackyChildrenPayload = Box; diff --git a/crates/ui2/src/components/assistant_panel.rs b/crates/ui2/src/components/assistant_panel.rs index def22af18b..0056251959 100644 --- a/crates/ui2/src/components/assistant_panel.rs +++ b/crates/ui2/src/components/assistant_panel.rs @@ -26,7 +26,7 @@ impl AssistantPanel { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); struct PanelPayload { @@ -110,7 +110,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, AssistantPanel>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/breadcrumb.rs b/crates/ui2/src/components/breadcrumb.rs index 8572859c31..207142cd35 100644 --- a/crates/ui2/src/components/breadcrumb.rs +++ b/crates/ui2/src/components/breadcrumb.rs @@ -31,7 +31,7 @@ impl Breadcrumb { .text_color(HighlightColor::Default.hsla(theme)) } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let symbols_len = self.symbols.len(); @@ -99,7 +99,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); Story::container(cx) diff --git a/crates/ui2/src/components/buffer.rs b/crates/ui2/src/components/buffer.rs index 89ecad19db..aadacd950b 100644 --- a/crates/ui2/src/components/buffer.rs +++ b/crates/ui2/src/components/buffer.rs @@ -162,7 +162,7 @@ impl Buffer { self } - fn render_row(row: BufferRow, cx: &WindowContext) -> impl Element { + fn render_row(row: BufferRow, cx: &WindowContext) -> impl Element { let theme = theme(cx); let system_color = SystemColor::new(); @@ -213,7 +213,7 @@ impl Buffer { })) } - fn render_rows(&self, cx: &WindowContext) -> Vec> { + fn render_rows(&self, cx: &WindowContext) -> Vec> { match &self.rows { Some(rows) => rows .rows @@ -224,7 +224,7 @@ impl Buffer { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let rows = self.render_rows(cx); @@ -263,7 +263,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); Story::container(cx) diff --git a/crates/ui2/src/components/chat_panel.rs b/crates/ui2/src/components/chat_panel.rs index ab4f5853ce..c603576c78 100644 --- a/crates/ui2/src/components/chat_panel.rs +++ b/crates/ui2/src/components/chat_panel.rs @@ -25,7 +25,7 @@ impl ChatPanel { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -89,7 +89,7 @@ impl ChatMessage { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { div() .flex() .flex_col() @@ -130,7 +130,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, ChatPanel>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/collab_panel.rs b/crates/ui2/src/components/collab_panel.rs index 1900b7e2ac..22a41af12f 100644 --- a/crates/ui2/src/components/collab_panel.rs +++ b/crates/ui2/src/components/collab_panel.rs @@ -23,7 +23,7 @@ impl CollabPanel { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let color = ThemeColor::new(cx); @@ -103,7 +103,7 @@ impl CollabPanel { label: impl Into>, expanded: bool, theme: &Theme, - ) -> impl Element { + ) -> impl Element { div() .h_7() .px_2() @@ -131,7 +131,7 @@ impl CollabPanel { avatar_uri: impl Into>, label: impl Into>, theme: &Theme, - ) -> impl Element { + ) -> impl Element { div() .h_7() .px_2() @@ -180,7 +180,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, CollabPanel>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/command_palette.rs b/crates/ui2/src/components/command_palette.rs index 6c29a787f5..2d96d35df2 100644 --- a/crates/ui2/src/components/command_palette.rs +++ b/crates/ui2/src/components/command_palette.rs @@ -17,7 +17,7 @@ impl CommandPalette { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { div().child( Palette::new(self.scroll_state.clone()) .items(example_editor_actions()) @@ -49,7 +49,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, CommandPalette>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rs index f3ef79e920..895ea71ea3 100644 --- a/crates/ui2/src/components/context_menu.rs +++ b/crates/ui2/src/components/context_menu.rs @@ -43,7 +43,7 @@ impl ContextMenu { items: items.into_iter().collect(), } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); v_stack() @@ -87,7 +87,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, ContextMenu>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/editor_pane.rs b/crates/ui2/src/components/editor_pane.rs index 4460a6f7cd..bb9c5c2623 100644 --- a/crates/ui2/src/components/editor_pane.rs +++ b/crates/ui2/src/components/editor_pane.rs @@ -20,7 +20,7 @@ impl EditorPane { Self { editor } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { struct LeftItemsPayload { path: PathBuf, symbols: Vec, diff --git a/crates/ui2/src/components/facepile.rs b/crates/ui2/src/components/facepile.rs index 3a0aa055c2..77fc95bc14 100644 --- a/crates/ui2/src/components/facepile.rs +++ b/crates/ui2/src/components/facepile.rs @@ -17,7 +17,7 @@ impl Facepile { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let player_count = self.players.len(); let player_list = self.players.iter().enumerate().map(|(ix, player)| { @@ -52,7 +52,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let players = static_players(); Story::container(cx) diff --git a/crates/ui2/src/components/icon_button.rs b/crates/ui2/src/components/icon_button.rs index c7a6329ff3..91bb920811 100644 --- a/crates/ui2/src/components/icon_button.rs +++ b/crates/ui2/src/components/icon_button.rs @@ -66,7 +66,7 @@ impl IconButton { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let icon_color = match (self.state, self.color) { diff --git a/crates/ui2/src/components/keybinding.rs b/crates/ui2/src/components/keybinding.rs index 3830d1a3e5..67124a9414 100644 --- a/crates/ui2/src/components/keybinding.rs +++ b/crates/ui2/src/components/keybinding.rs @@ -35,7 +35,7 @@ impl Keybinding { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { div() .flex() .gap_2() @@ -72,7 +72,7 @@ impl Key { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -189,7 +189,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let all_modifier_permutations = ModifierKey::iter().permutations(2); Story::container(cx) diff --git a/crates/ui2/src/components/language_selector.rs b/crates/ui2/src/components/language_selector.rs index 41e33596b8..6b6d16f4af 100644 --- a/crates/ui2/src/components/language_selector.rs +++ b/crates/ui2/src/components/language_selector.rs @@ -17,7 +17,7 @@ impl LanguageSelector { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { div().child( Palette::new(self.scroll_state.clone()) .items(vec![ @@ -60,7 +60,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, LanguageSelector>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rs index 3897394a78..a9cc070272 100644 --- a/crates/ui2/src/components/list.rs +++ b/crates/ui2/src/components/list.rs @@ -92,7 +92,7 @@ impl ListHeader { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let token = token(); let system_color = SystemColor::new(); @@ -164,7 +164,7 @@ impl ListSubHeader { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let token = token(); @@ -237,7 +237,7 @@ impl From> for ListItem { } impl ListItem { - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { match self { ListItem::Entry(entry) => div().child(entry.render(cx)), ListItem::Separator(separator) => div().child(separator.render(cx)), @@ -346,7 +346,7 @@ impl ListEntry { } } - fn disclosure_control(&mut self, cx: &mut ViewContext) -> Option> { + fn disclosure_control(&mut self, cx: &mut ViewContext) -> Option> { let theme = theme(cx); let token = token(); @@ -369,7 +369,7 @@ impl ListEntry { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let token = token(); let system_color = SystemColor::new(); @@ -437,7 +437,7 @@ impl ListSeparator { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let color = ThemeColor::new(cx); div().h_px().w_full().fill(color.border) @@ -477,7 +477,7 @@ impl List { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let token = token(); let is_toggleable = self.toggleable != Toggleable::NotToggleable; diff --git a/crates/ui2/src/components/multi_buffer.rs b/crates/ui2/src/components/multi_buffer.rs index d5a3d8f539..8ab399732c 100644 --- a/crates/ui2/src/components/multi_buffer.rs +++ b/crates/ui2/src/components/multi_buffer.rs @@ -17,7 +17,7 @@ impl MultiBuffer { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); v_stack() @@ -62,7 +62,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); Story::container(cx) diff --git a/crates/ui2/src/components/palette.rs b/crates/ui2/src/components/palette.rs index 0ee359db6a..d498fb53aa 100644 --- a/crates/ui2/src/components/palette.rs +++ b/crates/ui2/src/components/palette.rs @@ -47,7 +47,7 @@ impl Palette { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); v_stack() @@ -134,7 +134,7 @@ impl PaletteItem { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -172,7 +172,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Palette>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/panel.rs b/crates/ui2/src/components/panel.rs index f82dbad3e4..7c796aac4f 100644 --- a/crates/ui2/src/components/panel.rs +++ b/crates/ui2/src/components/panel.rs @@ -100,7 +100,7 @@ impl Panel { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let token = token(); let theme = theme(cx); @@ -165,7 +165,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Panel>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/panes.rs b/crates/ui2/src/components/panes.rs index 4c1ec66099..ddad72348b 100644 --- a/crates/ui2/src/components/panes.rs +++ b/crates/ui2/src/components/panes.rs @@ -48,7 +48,7 @@ impl Pane { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -89,7 +89,7 @@ impl PaneGroup { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); if !self.panes.is_empty() { diff --git a/crates/ui2/src/components/player_stack.rs b/crates/ui2/src/components/player_stack.rs index e88470da38..37c0db5fec 100644 --- a/crates/ui2/src/components/player_stack.rs +++ b/crates/ui2/src/components/player_stack.rs @@ -17,7 +17,7 @@ impl PlayerStack { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let system_color = SystemColor::new(); let player = self.player_with_call_status.get_player(); self.player_with_call_status.get_call_status(); diff --git a/crates/ui2/src/components/project_panel.rs b/crates/ui2/src/components/project_panel.rs index fb24dcd37e..07e8f12058 100644 --- a/crates/ui2/src/components/project_panel.rs +++ b/crates/ui2/src/components/project_panel.rs @@ -20,7 +20,7 @@ impl ProjectPanel { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let color = ThemeColor::new(cx); @@ -78,7 +78,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, ProjectPanel>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/recent_projects.rs b/crates/ui2/src/components/recent_projects.rs index 44f5bcbaf1..4e28cbd80d 100644 --- a/crates/ui2/src/components/recent_projects.rs +++ b/crates/ui2/src/components/recent_projects.rs @@ -17,7 +17,7 @@ impl RecentProjects { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { div().child( Palette::new(self.scroll_state.clone()) .items(vec![ @@ -56,7 +56,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, RecentProjects>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/status_bar.rs b/crates/ui2/src/components/status_bar.rs index 06e55bd9a6..43cfed88d9 100644 --- a/crates/ui2/src/components/status_bar.rs +++ b/crates/ui2/src/components/status_bar.rs @@ -83,7 +83,7 @@ impl StatusBar { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -98,7 +98,7 @@ impl StatusBar { .child(self.right_tools(&theme)) } - fn left_tools(&self, theme: &Theme) -> impl Element { + fn left_tools(&self, theme: &Theme) -> impl Element { let workspace_state = get_workspace_state(); div() @@ -129,7 +129,7 @@ impl StatusBar { .child(IconButton::new(Icon::XCircle)) } - fn right_tools(&self, theme: &Theme) -> impl Element { + fn right_tools(&self, theme: &Theme) -> impl Element { let workspace_state = get_workspace_state(); div() diff --git a/crates/ui2/src/components/tab.rs b/crates/ui2/src/components/tab.rs index 8ed34580c9..4757b24301 100644 --- a/crates/ui2/src/components/tab.rs +++ b/crates/ui2/src/components/tab.rs @@ -74,7 +74,7 @@ impl Tab { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let has_fs_conflict = self.fs_status == FileSystemStatus::Conflict; let is_deleted = self.fs_status == FileSystemStatus::Deleted; @@ -157,7 +157,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let git_statuses = GitStatus::iter(); let fs_statuses = FileSystemStatus::iter(); diff --git a/crates/ui2/src/components/tab_bar.rs b/crates/ui2/src/components/tab_bar.rs index 451dd858a0..da958b5f40 100644 --- a/crates/ui2/src/components/tab_bar.rs +++ b/crates/ui2/src/components/tab_bar.rs @@ -23,7 +23,7 @@ impl TabBar { self.scroll_state = scroll_state; } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let can_navigate_back = true; let can_navigate_forward = false; @@ -105,7 +105,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, TabBar>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/terminal.rs b/crates/ui2/src/components/terminal.rs index 18fdc40f45..d7cd12a00a 100644 --- a/crates/ui2/src/components/terminal.rs +++ b/crates/ui2/src/components/terminal.rs @@ -18,7 +18,7 @@ impl Terminal { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let can_navigate_back = true; @@ -109,7 +109,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Terminal>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/theme_selector.rs b/crates/ui2/src/components/theme_selector.rs index 7bb49601df..d25f1ac8d2 100644 --- a/crates/ui2/src/components/theme_selector.rs +++ b/crates/ui2/src/components/theme_selector.rs @@ -17,7 +17,7 @@ impl ThemeSelector { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { div().child( Palette::new(self.scroll_state.clone()) .items(vec![ @@ -61,7 +61,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, ThemeSelector>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/title_bar.rs b/crates/ui2/src/components/title_bar.rs index 1ab9efdd61..0b9f57d378 100644 --- a/crates/ui2/src/components/title_bar.rs +++ b/crates/ui2/src/components/title_bar.rs @@ -46,7 +46,7 @@ impl TitleBar { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); // let has_focus = cx.window_is_active(); let has_focus = true; @@ -139,7 +139,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, TitleBar>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/toast.rs b/crates/ui2/src/components/toast.rs index be165b4646..ea7f9a1f10 100644 --- a/crates/ui2/src/components/toast.rs +++ b/crates/ui2/src/components/toast.rs @@ -41,7 +41,7 @@ impl Toast { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let color = ThemeColor::new(cx); let mut div = div(); @@ -89,7 +89,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Toast>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/toolbar.rs b/crates/ui2/src/components/toolbar.rs index 0c1d998d28..6ab85ae815 100644 --- a/crates/ui2/src/components/toolbar.rs +++ b/crates/ui2/src/components/toolbar.rs @@ -27,7 +27,7 @@ impl Toolbar { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -74,7 +74,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); struct LeftItemsPayload { diff --git a/crates/ui2/src/components/traffic_lights.rs b/crates/ui2/src/components/traffic_lights.rs index fd7f67b904..0e6bca2bd1 100644 --- a/crates/ui2/src/components/traffic_lights.rs +++ b/crates/ui2/src/components/traffic_lights.rs @@ -26,7 +26,7 @@ impl TrafficLight { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let system_color = SystemColor::new(); @@ -60,7 +60,7 @@ impl TrafficLights { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let token = token(); @@ -104,7 +104,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, TrafficLights>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/workspace.rs b/crates/ui2/src/components/workspace.rs index 24417ae7ff..49045e3725 100644 --- a/crates/ui2/src/components/workspace.rs +++ b/crates/ui2/src/components/workspace.rs @@ -125,7 +125,7 @@ impl WorkspaceElement { } } - pub fn render(&mut self, cx: &mut ViewContext) -> impl Element { + pub fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx).clone(); let workspace_state = get_workspace_state(); @@ -353,7 +353,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { // Just render the workspace without any story boilerplate. WorkspaceElement::new() } diff --git a/crates/ui2/src/element_ext.rs b/crates/ui2/src/element_ext.rs index 41c91c0450..82bad3496a 100644 --- a/crates/ui2/src/element_ext.rs +++ b/crates/ui2/src/element_ext.rs @@ -1,6 +1,6 @@ use gpui3::Element; -pub trait ElementExt: Element { +pub trait ElementExt: Element { /// Applies a given function `then` to the current element if `condition` is true. /// This function is used to conditionally modify the element based on a given condition. /// If `condition` is false, it just returns the current element as it is. @@ -15,4 +15,4 @@ pub trait ElementExt: Element { } } -impl> ElementExt for E {} +impl> ElementExt for E {} diff --git a/crates/ui2/src/elements/avatar.rs b/crates/ui2/src/elements/avatar.rs index bb43d37e18..3f6031ece1 100644 --- a/crates/ui2/src/elements/avatar.rs +++ b/crates/ui2/src/elements/avatar.rs @@ -26,7 +26,7 @@ impl Avatar { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let mut img = img(); @@ -64,7 +64,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Avatar>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/elements/button.rs b/crates/ui2/src/elements/button.rs index 67b7770d06..9708aec23e 100644 --- a/crates/ui2/src/elements/button.rs +++ b/crates/ui2/src/elements/button.rs @@ -160,7 +160,7 @@ impl Button { self.icon.map(|i| IconElement::new(i).color(icon_color)) } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let icon_color = self.icon_color(); let system_color = SystemColor::new(); @@ -229,7 +229,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let states = InteractionState::iter(); Story::container(cx) diff --git a/crates/ui2/src/elements/details.rs b/crates/ui2/src/elements/details.rs index 50b361ea8b..22fa453198 100644 --- a/crates/ui2/src/elements/details.rs +++ b/crates/ui2/src/elements/details.rs @@ -24,7 +24,7 @@ impl Details { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -60,7 +60,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Details>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/elements/icon.rs b/crates/ui2/src/elements/icon.rs index b63eca561a..4ea9b8c57b 100644 --- a/crates/ui2/src/elements/icon.rs +++ b/crates/ui2/src/elements/icon.rs @@ -170,7 +170,7 @@ impl IconElement { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let fill = self.color.color(theme); @@ -206,7 +206,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let icons = Icon::iter(); Story::container(cx) diff --git a/crates/ui2/src/elements/input.rs b/crates/ui2/src/elements/input.rs index d63f116ca3..9040f4847c 100644 --- a/crates/ui2/src/elements/input.rs +++ b/crates/ui2/src/elements/input.rs @@ -45,7 +45,7 @@ impl Input { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let text_el; @@ -128,7 +128,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Input>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/elements/label.rs b/crates/ui2/src/elements/label.rs index a937468a35..e63cef7d21 100644 --- a/crates/ui2/src/elements/label.rs +++ b/crates/ui2/src/elements/label.rs @@ -90,7 +90,7 @@ impl Label { self } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); let highlight_color = theme.lowest.accent.default.foreground; @@ -185,7 +185,7 @@ mod stories { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { Story::container(cx) .child(Story::title_for::<_, Label>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/elements/stack.rs b/crates/ui2/src/elements/stack.rs index e8e547e006..17d693dd48 100644 --- a/crates/ui2/src/elements/stack.rs +++ b/crates/ui2/src/elements/stack.rs @@ -14,18 +14,18 @@ pub trait Stack: StyleHelpers { } } -impl Stack for Div {} +impl Stack for Div {} /// Horizontally stacks elements. /// /// Sets `flex()`, `flex_row()`, `items_center()` -pub fn h_stack() -> Div { +pub fn h_stack() -> Div { div().h_stack() } /// Vertically stacks elements. /// /// Sets `flex()`, `flex_col()` -pub fn v_stack() -> Div { +pub fn v_stack() -> Div { div().v_stack() } diff --git a/crates/ui2/src/elements/tool_divider.rs b/crates/ui2/src/elements/tool_divider.rs index 96c730c2f6..215a567609 100644 --- a/crates/ui2/src/elements/tool_divider.rs +++ b/crates/ui2/src/elements/tool_divider.rs @@ -15,7 +15,7 @@ impl ToolDivider { } } - fn render(&mut self, cx: &mut ViewContext) -> impl Element { + fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div().w_px().h_3().fill(theme.lowest.base.default.border) diff --git a/crates/ui2/src/story.rs b/crates/ui2/src/story.rs index f1a3b1ab70..a6fac40425 100644 --- a/crates/ui2/src/story.rs +++ b/crates/ui2/src/story.rs @@ -22,7 +22,7 @@ impl Story { pub fn title( cx: &mut ViewContext, title: &str, - ) -> impl Element { + ) -> impl Element { let theme = theme(cx); div() @@ -33,14 +33,14 @@ impl Story { pub fn title_for( cx: &mut ViewContext, - ) -> impl Element { + ) -> impl Element { Self::title(cx, std::any::type_name::()) } pub fn label( cx: &mut ViewContext, label: &str, - ) -> impl Element { + ) -> impl Element { let theme = theme(cx); div()