diff --git a/crates/storybook2/src/stories/z_index.rs b/crates/storybook2/src/stories/z_index.rs index 7fa078c4e3..15f66fc26a 100644 --- a/crates/storybook2/src/stories/z_index.rs +++ b/crates/storybook2/src/stories/z_index.rs @@ -14,7 +14,7 @@ impl ZIndexStory { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { Story::container(cx) .child(Story::title(cx, "z-index")) .child( diff --git a/crates/ui2/src/components/buffer.rs b/crates/ui2/src/components/buffer.rs index b4ccb89b5c..ee8271a94d 100644 --- a/crates/ui2/src/components/buffer.rs +++ b/crates/ui2/src/components/buffer.rs @@ -154,7 +154,7 @@ impl Buffer { self } - fn render_row(row: BufferRow, cx: &WindowContext) -> impl Component { + fn render_row(row: BufferRow, cx: &WindowContext) -> impl Component { let theme = theme(cx); let line_background = if row.current { @@ -204,7 +204,7 @@ impl Buffer { })) } - fn render_rows(&self, cx: &WindowContext) -> Vec> { + fn render_rows(&self, cx: &WindowContext) -> Vec> { match &self.rows { Some(rows) => rows .rows @@ -215,7 +215,7 @@ impl Buffer { } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); let rows = self.render_rows(cx); @@ -250,7 +250,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { 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 5155d70010..10e9e2a706 100644 --- a/crates/ui2/src/components/chat_panel.rs +++ b/crates/ui2/src/components/chat_panel.rs @@ -22,7 +22,7 @@ impl ChatPanel { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { div() .id(self.element_id.clone()) .flex() @@ -84,7 +84,7 @@ impl ChatMessage { } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { div() .flex() .flex_col() @@ -121,7 +121,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { 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 6d2cbd8e14..b8d0510f8f 100644 --- a/crates/ui2/src/components/collab_panel.rs +++ b/crates/ui2/src/components/collab_panel.rs @@ -14,7 +14,7 @@ impl CollabPanel { Self { id: id.into() } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); v_stack() @@ -101,7 +101,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { 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 065ee9a052..038dc7f460 100644 --- a/crates/ui2/src/components/command_palette.rs +++ b/crates/ui2/src/components/command_palette.rs @@ -11,7 +11,7 @@ impl CommandPalette { Self { id: id.into() } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { div().id(self.id.clone()).child( Palette::new("palette") .items(example_editor_actions()) @@ -39,7 +39,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { 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 206f5a2f31..f39df6879d 100644 --- a/crates/ui2/src/components/context_menu.rs +++ b/crates/ui2/src/components/context_menu.rs @@ -43,7 +43,7 @@ impl ContextMenu { } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); v_stack() @@ -80,7 +80,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { Story::container(cx) .child(Story::title_for::<_, ContextMenu>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/copilot.rs b/crates/ui2/src/components/copilot.rs index 3c48ef20d0..a33dc1a0b7 100644 --- a/crates/ui2/src/components/copilot.rs +++ b/crates/ui2/src/components/copilot.rs @@ -10,7 +10,7 @@ impl CopilotModal { Self { id: id.into() } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { div().id(self.id.clone()).child( Modal::new("some-id") .title("Connect Copilot to Zed") @@ -37,7 +37,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { Story::container(cx) .child(Story::title_for::<_, CopilotModal>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/facepile.rs b/crates/ui2/src/components/facepile.rs index 898489f1ed..1d0f435eac 100644 --- a/crates/ui2/src/components/facepile.rs +++ b/crates/ui2/src/components/facepile.rs @@ -13,7 +13,7 @@ impl Facepile { } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let player_count = self.players.len(); let player_list = self.players.iter().enumerate().map(|(ix, player)| { let isnt_last = ix < player_count - 1; @@ -43,7 +43,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { 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 2891ce6bd8..b591c937b0 100644 --- a/crates/ui2/src/components/icon_button.rs +++ b/crates/ui2/src/components/icon_button.rs @@ -5,27 +5,27 @@ use gpui2::MouseButton; use crate::{h_stack, prelude::*}; use crate::{ClickHandler, Icon, IconColor, IconElement}; -struct IconButtonHandlers { - click: Option>, +struct IconButtonHandlers { + click: Option>, } -impl Default for IconButtonHandlers { +impl Default for IconButtonHandlers { fn default() -> Self { Self { click: None } } } #[derive(Component)] -pub struct IconButton { +pub struct IconButton { id: ElementId, icon: Icon, color: IconColor, variant: ButtonVariant, state: InteractionState, - handlers: IconButtonHandlers, + handlers: IconButtonHandlers, } -impl IconButton { +impl IconButton { pub fn new(id: impl Into, icon: Icon) -> Self { Self { id: id.into(), @@ -57,12 +57,12 @@ impl IconButton { self } - pub fn on_click(mut self, handler: impl 'static + Fn(&mut S, &mut ViewContext) + Send + Sync) -> Self { + pub fn on_click(mut self, handler: impl 'static + Fn(&mut V, &mut ViewContext) + Send + Sync) -> Self { self.handlers.click = Some(Arc::new(handler)); self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { 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 2b0eefa4ea..822cdd1dcb 100644 --- a/crates/ui2/src/components/keybinding.rs +++ b/crates/ui2/src/components/keybinding.rs @@ -29,7 +29,7 @@ impl Keybinding { } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { div() .flex() .gap_2() @@ -59,7 +59,7 @@ impl Key { Self { key: key.into() } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); div() diff --git a/crates/ui2/src/components/language_selector.rs b/crates/ui2/src/components/language_selector.rs index db42b28281..92af80cd76 100644 --- a/crates/ui2/src/components/language_selector.rs +++ b/crates/ui2/src/components/language_selector.rs @@ -11,7 +11,7 @@ impl LanguageSelector { Self { id: id.into() } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { div().id(self.id.clone()).child( Palette::new("palette") .items(vec![ @@ -50,7 +50,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { 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 bfd650b390..9557e68d7f 100644 --- a/crates/ui2/src/components/list.rs +++ b/crates/ui2/src/components/list.rs @@ -55,7 +55,7 @@ impl ListHeader { self } - fn disclosure_control(&self) -> Div { + fn disclosure_control(&self) -> Div { let is_toggleable = self.toggleable != Toggleable::NotToggleable; let is_toggled = Toggleable::is_toggled(&self.toggleable); @@ -88,7 +88,7 @@ impl ListHeader { } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); let is_toggleable = self.toggleable != Toggleable::NotToggleable; @@ -151,7 +151,7 @@ impl ListSubHeader { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { h_stack().flex_1().w_full().relative().py_1().child( div() .h_6() @@ -192,39 +192,39 @@ pub enum ListEntrySize { } #[derive(Component)] -pub enum ListItem { +pub enum ListItem { Entry(ListEntry), - Details(ListDetailsEntry), + Details(ListDetailsEntry), Separator(ListSeparator), Header(ListSubHeader), } -impl From for ListItem { +impl From for ListItem { fn from(entry: ListEntry) -> Self { Self::Entry(entry) } } -impl From> for ListItem { - fn from(entry: ListDetailsEntry) -> Self { +impl From> for ListItem { + fn from(entry: ListDetailsEntry) -> Self { Self::Details(entry) } } -impl From for ListItem { +impl From for ListItem { fn from(entry: ListSeparator) -> Self { Self::Separator(entry) } } -impl From for ListItem { +impl From for ListItem { fn from(entry: ListSubHeader) -> Self { Self::Header(entry) } } -impl ListItem { - fn render(self, view: &mut S, cx: &mut ViewContext) -> impl Component { +impl ListItem { + fn render(self, view: &mut V, cx: &mut ViewContext) -> impl Component { match self { ListItem::Entry(entry) => div().child(entry.render(view, cx)), ListItem::Separator(separator) => div().child(separator.render(view, cx)), @@ -361,7 +361,7 @@ impl ListEntry { } } - fn render(mut self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(mut self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let settings = user_settings(cx); let theme = theme(cx); @@ -417,29 +417,29 @@ impl ListEntry { } } -struct ListDetailsEntryHandlers { - click: Option>, +struct ListDetailsEntryHandlers { + click: Option>, } -impl Default for ListDetailsEntryHandlers { +impl Default for ListDetailsEntryHandlers { fn default() -> Self { Self { click: None } } } #[derive(Component)] -pub struct ListDetailsEntry { +pub struct ListDetailsEntry { label: SharedString, meta: Option, left_content: Option, - handlers: ListDetailsEntryHandlers, - actions: Option>>, + handlers: ListDetailsEntryHandlers, + actions: Option>>, // TODO: make this more generic instead of // specifically for notifications seen: bool, } -impl ListDetailsEntry { +impl ListDetailsEntry { pub fn new(label: impl Into) -> Self { Self { label: label.into(), @@ -461,17 +461,17 @@ impl ListDetailsEntry { self } - pub fn on_click(mut self, handler: ClickHandler) -> Self { + pub fn on_click(mut self, handler: ClickHandler) -> Self { self.handlers.click = Some(handler); self } - pub fn actions(mut self, actions: Vec>) -> Self { + pub fn actions(mut self, actions: Vec>) -> Self { self.actions = Some(actions); self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); let settings = user_settings(cx); @@ -531,15 +531,15 @@ impl ListSeparator { } #[derive(Component)] -pub struct List { - items: Vec>, +pub struct List { + items: Vec>, empty_message: SharedString, header: Option, toggleable: Toggleable, } -impl List { - pub fn new(items: Vec>) -> Self { +impl List { + pub fn new(items: Vec>) -> Self { Self { items, empty_message: "No items".into(), @@ -563,7 +563,7 @@ impl List { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let is_toggleable = self.toggleable != Toggleable::NotToggleable; let is_toggled = Toggleable::is_toggled(&self.toggleable); diff --git a/crates/ui2/src/components/modal.rs b/crates/ui2/src/components/modal.rs index 0ed1b0c72f..7c3efe79ba 100644 --- a/crates/ui2/src/components/modal.rs +++ b/crates/ui2/src/components/modal.rs @@ -4,15 +4,15 @@ use smallvec::SmallVec; use crate::{h_stack, prelude::*, v_stack, Button, Icon, IconButton, Label}; #[derive(Component)] -pub struct Modal { +pub struct Modal { id: ElementId, title: Option, - primary_action: Option>, - secondary_action: Option>, - children: SmallVec<[AnyElement; 2]>, + primary_action: Option>, + secondary_action: Option>, + children: SmallVec<[AnyElement; 2]>, } -impl Modal { +impl Modal { pub fn new(id: impl Into) -> Self { Self { id: id.into(), @@ -28,17 +28,17 @@ impl Modal { self } - pub fn primary_action(mut self, action: Button) -> Self { + pub fn primary_action(mut self, action: Button) -> Self { self.primary_action = Some(action); self } - pub fn secondary_action(mut self, action: Button) -> Self { + pub fn secondary_action(mut self, action: Button) -> Self { self.secondary_action = Some(action); self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); v_stack() @@ -76,8 +76,8 @@ impl Modal { } } -impl ParentElement for Modal { - fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> { +impl ParentElement for Modal { + fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> { &mut self.children } } diff --git a/crates/ui2/src/components/notification_toast.rs b/crates/ui2/src/components/notification_toast.rs index 6be3e3b1b5..f7d280ed16 100644 --- a/crates/ui2/src/components/notification_toast.rs +++ b/crates/ui2/src/components/notification_toast.rs @@ -10,10 +10,7 @@ pub struct NotificationToast { impl NotificationToast { pub fn new(label: SharedString) -> Self { - Self { - label, - icon: None, - } + Self { label, icon: None } } pub fn icon(mut self, icon: I) -> Self @@ -24,7 +21,7 @@ impl NotificationToast { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); h_stack() diff --git a/crates/ui2/src/components/notifications_panel.rs b/crates/ui2/src/components/notifications_panel.rs index e154d717d4..3e0c3887c5 100644 --- a/crates/ui2/src/components/notifications_panel.rs +++ b/crates/ui2/src/components/notifications_panel.rs @@ -1,4 +1,3 @@ - use crate::{prelude::*, static_new_notification_items, static_read_notification_items}; use crate::{List, ListHeader}; @@ -9,12 +8,10 @@ pub struct NotificationsPanel { impl NotificationsPanel { pub fn new(id: impl Into) -> Self { - Self { - id: id.into(), - } + Self { id: id.into() } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); div() diff --git a/crates/ui2/src/components/palette.rs b/crates/ui2/src/components/palette.rs index c2b7ba7e6c..97f3df0b7c 100644 --- a/crates/ui2/src/components/palette.rs +++ b/crates/ui2/src/components/palette.rs @@ -42,7 +42,7 @@ impl Palette { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); v_stack() @@ -131,7 +131,7 @@ impl PaletteItem { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { div() .flex() .flex_row() diff --git a/crates/ui2/src/components/panel.rs b/crates/ui2/src/components/panel.rs index 861babf27c..7da2dab09a 100644 --- a/crates/ui2/src/components/panel.rs +++ b/crates/ui2/src/components/panel.rs @@ -39,17 +39,17 @@ pub enum PanelSide { use std::collections::HashSet; #[derive(Component)] -pub struct Panel { +pub struct Panel { id: ElementId, current_side: PanelSide, /// Defaults to PanelAllowedSides::LeftAndRight allowed_sides: PanelAllowedSides, initial_width: AbsoluteLength, width: Option, - children: SmallVec<[AnyElement; 2]>, + children: SmallVec<[AnyElement; 2]>, } -impl Panel { +impl Panel { pub fn new(id: impl Into, cx: &mut WindowContext) -> Self { let settings = user_settings(cx); @@ -92,7 +92,7 @@ impl Panel { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); let current_size = self.width.unwrap_or(self.initial_width); @@ -117,8 +117,8 @@ impl Panel { } } -impl ParentElement for Panel { - fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> { +impl ParentElement for Panel { + fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> { &mut self.children } } @@ -140,9 +140,9 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { Story::container(cx) - .child(Story::title_for::<_, Panel>(cx)) + .child(Story::title_for::<_, Panel>(cx)) .child(Story::label(cx, "Default")) .child( Panel::new("panel", cx).child( diff --git a/crates/ui2/src/components/player_stack.rs b/crates/ui2/src/components/player_stack.rs index 8c2d0bbf25..ced761a086 100644 --- a/crates/ui2/src/components/player_stack.rs +++ b/crates/ui2/src/components/player_stack.rs @@ -13,7 +13,7 @@ impl PlayerStack { } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); 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 0898b70c8e..61458ad4a0 100644 --- a/crates/ui2/src/components/project_panel.rs +++ b/crates/ui2/src/components/project_panel.rs @@ -13,7 +13,7 @@ impl ProjectPanel { Self { id: id.into() } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); div() @@ -69,7 +69,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { 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 67a32ad009..81da295c3a 100644 --- a/crates/ui2/src/components/recent_projects.rs +++ b/crates/ui2/src/components/recent_projects.rs @@ -11,7 +11,7 @@ impl RecentProjects { Self { id: id.into() } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { div().id(self.id.clone()).child( Palette::new("palette") .items(vec![ @@ -46,7 +46,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { Story::container(cx) .child(Story::title_for::<_, RecentProjects>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/tab_bar.rs b/crates/ui2/src/components/tab_bar.rs index 4ebf7c6376..4c27d85f03 100644 --- a/crates/ui2/src/components/tab_bar.rs +++ b/crates/ui2/src/components/tab_bar.rs @@ -23,7 +23,7 @@ impl TabBar { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); let (can_navigate_back, can_navigate_forward) = self.can_navigate; @@ -104,7 +104,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { 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 eb95458f0f..4a38d20523 100644 --- a/crates/ui2/src/components/terminal.rs +++ b/crates/ui2/src/components/terminal.rs @@ -11,7 +11,7 @@ impl Terminal { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); let can_navigate_back = true; @@ -95,7 +95,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { 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 18dbaac407..c1e1527d6c 100644 --- a/crates/ui2/src/components/theme_selector.rs +++ b/crates/ui2/src/components/theme_selector.rs @@ -11,7 +11,7 @@ impl ThemeSelector { Self { id: id.into() } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { div().child( Palette::new(self.id.clone()) .items(vec![ @@ -51,7 +51,7 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { Story::container(cx) .child(Story::title_for::<_, ThemeSelector>(cx)) .child(Story::label(cx, "Default")) diff --git a/crates/ui2/src/components/toast.rs b/crates/ui2/src/components/toast.rs index 40c1e3a6a4..626a79b367 100644 --- a/crates/ui2/src/components/toast.rs +++ b/crates/ui2/src/components/toast.rs @@ -23,12 +23,12 @@ pub enum ToastOrigin { /// /// Only one toast may be visible at a time. #[derive(Component)] -pub struct Toast { +pub struct Toast { origin: ToastOrigin, - children: SmallVec<[AnyElement; 2]>, + children: SmallVec<[AnyElement; 2]>, } -impl Toast { +impl Toast { pub fn new(origin: ToastOrigin) -> Self { Self { origin, @@ -36,7 +36,7 @@ impl Toast { } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); let mut div = div(); @@ -61,8 +61,8 @@ impl Toast { } } -impl ParentElement for Toast { - fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> { +impl ParentElement for Toast { + fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> { &mut self.children } } @@ -84,9 +84,9 @@ mod stories { Self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { Story::container(cx) - .child(Story::title_for::<_, Toast>(cx)) + .child(Story::title_for::<_, Toast>(cx)) .child(Story::label(cx, "Default")) .child(Toast::new(ToastOrigin::Bottom).child(Label::new("label"))) } diff --git a/crates/ui2/src/components/toolbar.rs b/crates/ui2/src/components/toolbar.rs index 83bcde255e..d3af4485e2 100644 --- a/crates/ui2/src/components/toolbar.rs +++ b/crates/ui2/src/components/toolbar.rs @@ -7,12 +7,12 @@ use crate::prelude::*; pub struct ToolbarItem {} #[derive(Component)] -pub struct Toolbar { - left_items: SmallVec<[AnyElement; 2]>, - right_items: SmallVec<[AnyElement; 2]>, +pub struct Toolbar { + left_items: SmallVec<[AnyElement; 2]>, + right_items: SmallVec<[AnyElement; 2]>, } -impl Toolbar { +impl Toolbar { pub fn new() -> Self { Self { left_items: SmallVec::new(), @@ -20,7 +20,7 @@ impl Toolbar { } } - pub fn left_item(mut self, child: impl Component) -> Self + pub fn left_item(mut self, child: impl Component) -> Self where Self: Sized, { @@ -28,7 +28,7 @@ impl Toolbar { self } - pub fn left_items(mut self, iter: impl IntoIterator>) -> Self + pub fn left_items(mut self, iter: impl IntoIterator>) -> Self where Self: Sized, { @@ -37,7 +37,7 @@ impl Toolbar { self } - pub fn right_item(mut self, child: impl Component) -> Self + pub fn right_item(mut self, child: impl Component) -> Self where Self: Sized, { @@ -45,7 +45,7 @@ impl Toolbar { self } - pub fn right_items(mut self, iter: impl IntoIterator>) -> Self + pub fn right_items(mut self, iter: impl IntoIterator>) -> Self where Self: Sized, { @@ -54,7 +54,7 @@ impl Toolbar { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); div() diff --git a/crates/ui2/src/components/traffic_lights.rs b/crates/ui2/src/components/traffic_lights.rs index e3698adbf9..f9bba2828a 100644 --- a/crates/ui2/src/components/traffic_lights.rs +++ b/crates/ui2/src/components/traffic_lights.rs @@ -21,7 +21,7 @@ impl TrafficLight { } } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); let fill = match (self.window_has_focus, self.color) { @@ -52,7 +52,7 @@ impl TrafficLights { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { div() .flex() .items_center() diff --git a/crates/ui2/src/element_ext.rs b/crates/ui2/src/element_ext.rs index 69603bbb59..bbdf6ded42 100644 --- a/crates/ui2/src/element_ext.rs +++ b/crates/ui2/src/element_ext.rs @@ -1,6 +1,6 @@ use gpui2::Element; -pub trait ElementExt: Element { +pub trait ElementExt: Element { // fn when(mut self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self // where // Self: Sized, diff --git a/crates/ui2/src/elements/button.rs b/crates/ui2/src/elements/button.rs index 24776c52c3..b54944b45b 100644 --- a/crates/ui2/src/elements/button.rs +++ b/crates/ui2/src/elements/button.rs @@ -50,23 +50,23 @@ impl ButtonVariant { pub type ClickHandler = Arc) + Send + Sync>; -struct ButtonHandlers { - click: Option>, +struct ButtonHandlers { + click: Option>, } unsafe impl Send for ButtonHandlers {} unsafe impl Sync for ButtonHandlers {} -impl Default for ButtonHandlers { +impl Default for ButtonHandlers { fn default() -> Self { Self { click: None } } } #[derive(Component)] -pub struct Button { +pub struct Button { disabled: bool, - handlers: ButtonHandlers, + handlers: ButtonHandlers, icon: Option, icon_position: Option, label: SharedString, @@ -74,7 +74,7 @@ pub struct Button { width: Option, } -impl Button { +impl Button { pub fn new(label: impl Into) -> Self { Self { disabled: false, @@ -114,7 +114,7 @@ impl Button { self } - pub fn on_click(mut self, handler: ClickHandler) -> Self { + pub fn on_click(mut self, handler: ClickHandler) -> Self { self.handlers.click = Some(handler); self } @@ -150,7 +150,7 @@ impl Button { self.icon.map(|i| IconElement::new(i).color(icon_color)) } - pub fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + pub fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let icon_color = self.icon_color(); let mut button = h_stack() diff --git a/crates/ui2/src/elements/details.rs b/crates/ui2/src/elements/details.rs index 2191829731..2ff8767066 100644 --- a/crates/ui2/src/elements/details.rs +++ b/crates/ui2/src/elements/details.rs @@ -7,7 +7,7 @@ pub struct Details { actions: Option>, } -impl Details { +impl Details { pub fn new(text: &'static str) -> Self { Self { text, @@ -21,12 +21,12 @@ impl Details { self } - pub fn actions(mut self, actions: ButtonGroup) -> Self { + pub fn actions(mut self, actions: ButtonGroup) -> Self { self.actions = Some(actions); self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); v_stack() diff --git a/crates/ui2/src/elements/input.rs b/crates/ui2/src/elements/input.rs index 30b930b315..557a8c5f83 100644 --- a/crates/ui2/src/elements/input.rs +++ b/crates/ui2/src/elements/input.rs @@ -56,7 +56,7 @@ impl Input { self } - fn render(self, _view: &mut S, cx: &mut ViewContext) -> impl Component { + fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); let (input_bg, input_hover_bg, input_active_bg) = match self.variant { diff --git a/crates/ui2/src/elements/player.rs b/crates/ui2/src/elements/player.rs index 12457e4f58..5bf890b8bb 100644 --- a/crates/ui2/src/elements/player.rs +++ b/crates/ui2/src/elements/player.rs @@ -138,12 +138,12 @@ impl Player { self } - pub fn cursor_color(&self, cx: &mut ViewContext) -> Hsla { + pub fn cursor_color(&self, cx: &mut ViewContext) -> Hsla { let theme = theme(cx); theme.players[self.index].cursor } - pub fn selection_color(&self, cx: &mut ViewContext) -> Hsla { + pub fn selection_color(&self, cx: &mut ViewContext) -> Hsla { let theme = theme(cx); theme.players[self.index].selection } diff --git a/crates/ui2/src/elements/stack.rs b/crates/ui2/src/elements/stack.rs index 35ba00cecd..1b019ad4d9 100644 --- a/crates/ui2/src/elements/stack.rs +++ b/crates/ui2/src/elements/stack.rs @@ -14,18 +14,18 @@ pub trait Stack: Styled + Sized { } } -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/static_data.rs b/crates/ui2/src/static_data.rs index f1b2405e72..5f6d29a081 100644 --- a/crates/ui2/src/static_data.rs +++ b/crates/ui2/src/static_data.rs @@ -325,7 +325,7 @@ pub fn static_players_with_call_status() -> Vec { ] } -pub fn static_new_notification_items() -> Vec> { +pub fn static_new_notification_items() -> Vec> { vec![ ListDetailsEntry::new("maxdeviant invited you to join a stream in #design.") .meta("4 people in stream."), @@ -336,7 +336,7 @@ pub fn static_new_notification_items() -> Vec> { .collect() } -pub fn static_read_notification_items() -> Vec> { +pub fn static_read_notification_items() -> Vec> { vec![ ListDetailsEntry::new("mikaylamaki added you as a contact.").actions(vec![ Button::new("Decline"), @@ -352,7 +352,7 @@ pub fn static_read_notification_items() -> Vec> { .collect() } -pub fn static_project_panel_project_items() -> Vec> { +pub fn static_project_panel_project_items() -> Vec> { vec![ ListEntry::new(Label::new("zed")) .left_icon(Icon::FolderOpen.into()) @@ -479,7 +479,7 @@ pub fn static_project_panel_project_items() -> Vec> { .collect() } -pub fn static_project_panel_single_items() -> Vec> { +pub fn static_project_panel_single_items() -> Vec> { vec![ ListEntry::new(Label::new("todo.md")) .left_icon(Icon::FileDoc.into()) @@ -496,7 +496,7 @@ pub fn static_project_panel_single_items() -> Vec> { .collect() } -pub fn static_collab_panel_current_call() -> Vec> { +pub fn static_collab_panel_current_call() -> Vec> { vec![ ListEntry::new(Label::new("as-cii")).left_avatar("http://github.com/as-cii.png?s=50"), ListEntry::new(Label::new("nathansobo")) @@ -509,7 +509,7 @@ pub fn static_collab_panel_current_call() -> Vec> { .collect() } -pub fn static_collab_panel_channels() -> Vec> { +pub fn static_collab_panel_channels() -> Vec> { vec![ ListEntry::new(Label::new("zed")) .left_icon(Icon::Hash.into()) diff --git a/crates/ui2/src/story.rs b/crates/ui2/src/story.rs index fae65a16b7..d2813bd174 100644 --- a/crates/ui2/src/story.rs +++ b/crates/ui2/src/story.rs @@ -5,7 +5,7 @@ use crate::prelude::*; pub struct Story {} impl Story { - pub fn container(cx: &mut ViewContext) -> Div { + pub fn container(cx: &mut ViewContext) -> Div { let theme = theme(cx); div() @@ -18,10 +18,7 @@ impl Story { .bg(theme.background) } - pub fn title( - cx: &mut ViewContext, - title: &str, - ) -> impl Component { + pub fn title(cx: &mut ViewContext, title: &str) -> impl Component { let theme = theme(cx); div() @@ -30,14 +27,11 @@ impl Story { .child(title.to_owned()) } - pub fn title_for(cx: &mut ViewContext) -> impl Component { + pub fn title_for(cx: &mut ViewContext) -> impl Component { Self::title(cx, std::any::type_name::()) } - pub fn label( - cx: &mut ViewContext, - label: &str, - ) -> impl Component { + pub fn label(cx: &mut ViewContext, label: &str) -> impl Component { let theme = theme(cx); div()