From 8cd112110ea7e5d6491f3718914e3bc954052faf Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Thu, 12 Oct 2023 10:40:47 -0400 Subject: [PATCH] Reconcile with upstream changes --- crates/gpui3_macros/src/derive_element.rs | 27 +++++++++++-------- crates/storybook2/src/stories/kitchen_sink.rs | 2 +- crates/storybook2/src/stories/z_index.rs | 4 +-- crates/ui2/src/children.rs | 2 +- crates/ui2/src/components/assistant_panel.rs | 4 +-- crates/ui2/src/components/breadcrumb.rs | 4 +-- crates/ui2/src/components/buffer.rs | 8 +++--- crates/ui2/src/components/chat_panel.rs | 6 ++--- crates/ui2/src/components/collab_panel.rs | 8 +++--- crates/ui2/src/components/command_palette.rs | 4 +-- crates/ui2/src/components/context_menu.rs | 4 +-- crates/ui2/src/components/editor_pane.rs | 2 +- crates/ui2/src/components/facepile.rs | 4 +-- crates/ui2/src/components/icon_button.rs | 2 +- crates/ui2/src/components/keybinding.rs | 6 ++--- .../ui2/src/components/language_selector.rs | 4 +-- crates/ui2/src/components/list.rs | 14 +++++----- crates/ui2/src/components/multi_buffer.rs | 4 +-- crates/ui2/src/components/palette.rs | 6 ++--- crates/ui2/src/components/panel.rs | 4 +-- crates/ui2/src/components/panes.rs | 4 +-- crates/ui2/src/components/player_stack.rs | 2 +- crates/ui2/src/components/project_panel.rs | 4 +-- crates/ui2/src/components/recent_projects.rs | 4 +-- crates/ui2/src/components/status_bar.rs | 6 ++--- crates/ui2/src/components/tab.rs | 4 +-- crates/ui2/src/components/tab_bar.rs | 4 +-- crates/ui2/src/components/terminal.rs | 4 +-- crates/ui2/src/components/theme_selector.rs | 4 +-- crates/ui2/src/components/title_bar.rs | 4 +-- crates/ui2/src/components/toast.rs | 4 +-- crates/ui2/src/components/toolbar.rs | 4 +-- crates/ui2/src/components/traffic_lights.rs | 6 ++--- crates/ui2/src/components/workspace.rs | 4 +-- crates/ui2/src/element_ext.rs | 4 +-- crates/ui2/src/elements/avatar.rs | 4 +-- crates/ui2/src/elements/button.rs | 4 +-- crates/ui2/src/elements/details.rs | 4 +-- crates/ui2/src/elements/icon.rs | 4 +-- crates/ui2/src/elements/input.rs | 4 +-- crates/ui2/src/elements/label.rs | 4 +-- crates/ui2/src/elements/stack.rs | 6 ++--- crates/ui2/src/elements/tool_divider.rs | 2 +- crates/ui2/src/story.rs | 6 ++--- 44 files changed, 112 insertions(+), 107 deletions(-) diff --git a/crates/gpui3_macros/src/derive_element.rs b/crates/gpui3_macros/src/derive_element.rs index 08f50a92ba174e113645b8f791b8d10f22f638c9..6c57f6c966de844ac75857898c20505260324c4a 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 325e84847f5f8645bcf15c32e3cba74877ee4a7e..91e34d3c690c1aa2ddd39fe74774204c428c50f8 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 17506484f170277c43d5a40fe810838cc34e9398..89a146b4ece86023bb47c5f33fab9d6bf3863e4f 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 c7c81e97263b499b2202bc983fd39c4dc9b2a83f..e9a55d1cc04a9bbdb336ad1527bb5536b179cbb9 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 def22af18bb17db96462ab2a30237ce1d3848962..00562519597f382796571ac61e838759a2e67ac2 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 8572859c31777e082f354204cc10ad160c7b3c11..207142cd35c2d674182cc8b9ba39c5692bdf80a3 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 89ecad19dbf6e5ca6dda5f9d09a1f0542f7b332d..aadacd950bc4b21081cc435acf2abf6bf7ddaa82 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 ab4f5853cef680be627b7c575038d2188b0f9cb8..c603576c787a94d49b5b6843e96d274df8628390 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 1900b7e2ac2075b89e1972d26d39071ef38d2f32..22a41af12f5ddf29d9619c2805333779c7f829d3 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 6c29a787f55def2a3ee1f1eb859fe5bbf6f154a7..2d96d35df2eddacd0bc2b5b184ee40513f3920f7 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 f3ef79e920e24c142e5313ed01cc29ea297bb954..895ea71ea35c4023b14f402b6733c7b1de1e05dc 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 4460a6f7cde2ee9f58819123c7b6e6e758ac4750..bb9c5c262357e6bc9002241dcfd871bdc299a049 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 3a0aa055c2fb0d642b7741219282bc02830751e4..77fc95bc1499616fdcd059c882e7a8e489d0d9e5 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 c7a6329ff300f67b2a599acc4b01fbddf2227f66..91bb920811e34c6ce06f4562d4b1d53889b1f324 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 3830d1a3e5fbe6fb0cfcf88d4b2d1be3f0e81bac..67124a94143b32120e9f3896f7cece654ffb22c2 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 41e33596b86e005b9c69e78224473373357170b9..6b6d16f4af822c7afe715248ee0dafa8e3e22140 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 3897394a789f11036c304b729b1a049bfeb75569..a9cc070272b5d18bdef4b719e32c602ad0556276 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 d5a3d8f53979f23ae6ac8b0d21334749b12284a1..8ab399732c8decf8e3b0f19e52e7e72650864379 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 0ee359db6a37f36958afe116020c262320211115..d498fb53aa6e92cf66c028716abe9ad6e7ff425b 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 f82dbad3e4b7508fd9341900199333432a17b58f..7c796aac4f31c446fd4cdf2b82a2ff9f4748c662 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 4c1ec66099c91bed38ef98505052861b654001f6..ddad72348b9a17170729bf7f944f8642828f1fbf 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 e88470da385b716fe729ca017447a18dec6d4f8e..37c0db5fec243f9aca1110c3ae3f5370ea78db4b 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 fb24dcd37e55ed6790593aa714d98ce7c63f2747..07e8f120586c1bcf3deb80e0478acd484e77cd51 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 44f5bcbaf10f273601bd176ccf95d46fb9ce863d..4e28cbd80d2e9c007e85960837d88e0059535fc9 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 06e55bd9a6e44274af83cd7feedce67598b169a7..43cfed88d9d9a0a1299bcdd5dfa73a91a68a952a 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 8ed34580c9ab2d9a75a78ca0c023dbe41af8e938..4757b243018ce6fe741b7fafb837e3c14350d113 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 451dd858a0f26cbb68f56d75e01b6c5a6333cf42..da958b5f403a565bb8a46e218352c847ef959947 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 18fdc40f457b9c5c91b5fdffb5fbd8ec9d06149a..d7cd12a00a54885ac83458f83d34bd2ecaecef75 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 7bb49601dff0939dd1bcb78c00ee57f16cdce75c..d25f1ac8d258fec9a8db131c9cc041cdf1f79bd2 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 1ab9efdd61ea55d479cae5cfcbcb77b916b205c5..0b9f57d37850a6dcca13fdfddfdc2ec823d4d58c 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 be165b4646ceb6994fc466490402ba4784b95f91..ea7f9a1f1086096104b82452b3f7823ef4af1603 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 0c1d998d2869bf722f328afc0080e4ca01902826..6ab85ae8156059e673941fa07599ff1965f73a00 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 fd7f67b904a6f5cd86eee7d645908a4555b33290..0e6bca2bd13df5392287ed103442b4af2cc87f45 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 24417ae7ff3ef6140fd510db348a970374d75456..49045e3725517b30cec774622214e13755992608 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 41c91c0450b34f1e618605992d5b1dbc45a31df5..82bad3496a9d06389aea051cb6ec0e2fee434db0 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 bb43d37e183d63455fa780a1d9aef35a70d2090f..3f6031ece11419f57b302a303279a3a12b13ec7b 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 67b7770d0697439274f4fa33ca9cd5370228fda6..9708aec23ee31317630c1d1b1c1259a5edf312cd 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 50b361ea8b14cb5e1696e8a0b20deef1c9decccc..22fa45319843fcfb3c3d8f1d917ab80915c60186 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 b63eca561a58825457be66e0a86661f75abc8f7e..4ea9b8c57b437f48e549ea8fa7193684a4e4faf3 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 d63f116ca3873919c2245984e90f44d64142718a..9040f4847c0c67edb7aade9a2a2d95bfa51a48f9 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 a937468a357a5ec8625976e04a9fa2f6db5af60c..e63cef7d21a423126958b1679fe7b9c6e0aeb05e 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 e8e547e006d5065d3b9441c120800b71b76e0bdb..17d693dd48aad6b06a3a24cceef4e86637f551bb 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 96c730c2f61307ebf3a1fe7f51310908f404f91d..215a5676095b93c30cdc2ce7094679d66adf0883 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 f1a3b1ab70438a6354f4d7c4f0fc1877d93d6b26..a6fac40425843afd025cb92c52cfc706f02f2223 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()