Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Checkpoint: Compiling

Marshall Bowers9fb988593109
diff --git a/crates/gpui2_macros/src/derive_element.rs b/crates/gpui2_macros/src/derive_element.rs
index 3f6b053aa06..a63be0f5da0 100644
--- a/crates/gpui2_macros/src/derive_element.rs
+++ b/crates/gpui2_macros/src/derive_element.rs
@@ -47,10 +47,9 @@ pub fn derive_element(input: TokenStream) -> TokenStream {
}
}
- impl #impl_generics gpui2::Element for #type_name #ty_generics
+ impl #impl_generics gpui2::Element<#state_type> for #type_name #ty_generics
#where_clause
{
- type ViewState = #state_type;
type ElementState = gpui2::AnyElement<#state_type>;
fn id(&self) -> Option<gpui2::ElementId> {
@@ -59,9 +58,9 @@ pub fn derive_element(input: TokenStream) -> TokenStream {
fn initialize(
&mut self,
- view_state: &mut Self::ViewState,
+ view_state: &mut #state_type,
_: Option<Self::ElementState>,
- cx: &mut gpui2::ViewContext<Self::ViewState>
+ cx: &mut gpui2::ViewContext<#state_type>
) -> Self::ElementState {
use gpui2::IntoAnyElement;
@@ -72,9 +71,9 @@ pub fn derive_element(input: TokenStream) -> TokenStream {
fn layout(
&mut self,
- view_state: &mut Self::ViewState,
+ view_state: &mut #state_type,
rendered_element: &mut Self::ElementState,
- cx: &mut gpui2::ViewContext<Self::ViewState>,
+ cx: &mut gpui2::ViewContext<#state_type>,
) -> gpui2::LayoutId {
rendered_element.layout(view_state, cx)
}
@@ -82,9 +81,9 @@ pub fn derive_element(input: TokenStream) -> TokenStream {
fn paint(
&mut self,
bounds: gpui2::Bounds<gpui2::Pixels>,
- view_state: &mut Self::ViewState,
+ view_state: &mut #state_type,
rendered_element: &mut Self::ElementState,
- cx: &mut gpui2::ViewContext<Self::ViewState>,
+ cx: &mut gpui2::ViewContext<#state_type>,
) {
rendered_element.paint(view_state, cx)
}
diff --git a/crates/storybook2/src/stories/kitchen_sink.rs b/crates/storybook2/src/stories/kitchen_sink.rs
index e7c4e752f6f..63cb1d0f517 100644
--- a/crates/storybook2/src/stories/kitchen_sink.rs
+++ b/crates/storybook2/src/stories/kitchen_sink.rs
@@ -16,7 +16,7 @@ impl KitchenSinkStory {
view(cx.entity(|cx| Self::new()), Self::render)
}
- fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
+ fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<Self> {
let element_stories = ElementStory::iter()
.map(|selector| selector.story(cx))
.collect::<Vec<_>>();
diff --git a/crates/storybook2/src/stories/scroll.rs b/crates/storybook2/src/stories/scroll.rs
index c5df3bd3d31..67200b52bcc 100644
--- a/crates/storybook2/src/stories/scroll.rs
+++ b/crates/storybook2/src/stories/scroll.rs
@@ -16,7 +16,7 @@ impl ScrollStory {
}
}
-fn checkerboard<S>(depth: usize) -> impl Element<ViewState = S>
+fn checkerboard<S>(depth: usize) -> impl Element<S>
where
S: 'static + Send + Sync,
{
diff --git a/crates/storybook2/src/stories/z_index.rs b/crates/storybook2/src/stories/z_index.rs
index 9dd74b6884d..39ac6fd6e41 100644
--- a/crates/storybook2/src/stories/z_index.rs
+++ b/crates/storybook2/src/stories/z_index.rs
@@ -19,7 +19,7 @@ impl<S: 'static + Send + Sync> ZIndexStory<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
Story::container(cx)
.child(Story::title(cx, "z-index"))
.child(
@@ -86,23 +86,23 @@ trait Styles: Styled + Sized {
}
}
-impl<S: 'static + Send + Sync> Styles for Div<S> {}
+impl<V: 'static + Send + Sync> Styles for Div<V> {}
#[derive(Element)]
-struct ZIndexExample<S: 'static + Send + Sync> {
- state_type: PhantomData<S>,
+struct ZIndexExample<V: 'static + Send + Sync> {
+ view_type: PhantomData<V>,
z_index: u32,
}
-impl<S: 'static + Send + Sync> ZIndexExample<S> {
+impl<V: 'static + Send + Sync> ZIndexExample<V> {
pub fn new(z_index: u32) -> Self {
Self {
- state_type: PhantomData,
+ view_type: PhantomData,
z_index,
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Element<V> {
div()
.relative()
.size_full()
diff --git a/crates/storybook2/src/storybook2.rs b/crates/storybook2/src/storybook2.rs
index c6d71f079da..107d737ef92 100644
--- a/crates/storybook2/src/storybook2.rs
+++ b/crates/storybook2/src/storybook2.rs
@@ -107,7 +107,7 @@ impl StoryWrapper {
Self { story, theme }
}
- fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
+ fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<Self> {
themed(self.theme.clone(), cx, |cx| {
div()
.flex()
diff --git a/crates/ui2/src/components/assistant_panel.rs b/crates/ui2/src/components/assistant_panel.rs
index 31f299de910..77d29f44f78 100644
--- a/crates/ui2/src/components/assistant_panel.rs
+++ b/crates/ui2/src/components/assistant_panel.rs
@@ -26,7 +26,7 @@ impl<S: 'static + Send + Sync> AssistantPanel<S> {
self
}
- fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
Panel::new(self.id.clone(), cx)
.children(vec![div()
.flex()
@@ -100,7 +100,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, AssistantPanel<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/components/breadcrumb.rs b/crates/ui2/src/components/breadcrumb.rs
index e67ceb1751c..4bd5283db3c 100644
--- a/crates/ui2/src/components/breadcrumb.rs
+++ b/crates/ui2/src/components/breadcrumb.rs
@@ -35,7 +35,7 @@ impl<S: 'static + Send + Sync> Breadcrumb<S> {
&mut self,
view_state: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
let theme = theme(cx);
let symbols_len = self.symbols.len();
@@ -106,7 +106,7 @@ mod stories {
&mut self,
view_state: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
let theme = theme(cx);
Story::container(cx)
diff --git a/crates/ui2/src/components/buffer.rs b/crates/ui2/src/components/buffer.rs
index 2e0e07e16c8..51f5ea91965 100644
--- a/crates/ui2/src/components/buffer.rs
+++ b/crates/ui2/src/components/buffer.rs
@@ -158,7 +158,7 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
self
}
- fn render_row(row: BufferRow, cx: &WindowContext) -> impl Element<ViewState = S> {
+ fn render_row(row: BufferRow, cx: &WindowContext) -> impl Element<S> {
let theme = theme(cx);
let line_background = if row.current {
@@ -208,7 +208,7 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
}))
}
- fn render_rows(&self, cx: &WindowContext) -> Vec<impl Element<ViewState = S>> {
+ fn render_rows(&self, cx: &WindowContext) -> Vec<impl Element<S>> {
match &self.rows {
Some(rows) => rows
.rows
@@ -219,7 +219,7 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let rows = self.render_rows(cx);
@@ -262,7 +262,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
let theme = theme(cx);
Story::container(cx)
diff --git a/crates/ui2/src/components/buffer_search.rs b/crates/ui2/src/components/buffer_search.rs
index 1edbd58c877..3294aec7806 100644
--- a/crates/ui2/src/components/buffer_search.rs
+++ b/crates/ui2/src/components/buffer_search.rs
@@ -25,7 +25,7 @@ impl BufferSearch {
view(cx.entity(|cx| Self::new()), Self::render)
}
- fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
+ fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<Self> {
let theme = theme(cx);
h_stack().bg(theme.toolbar).p_2().child(
diff --git a/crates/ui2/src/components/chat_panel.rs b/crates/ui2/src/components/chat_panel.rs
index 7afccd6d9d5..b66868138f8 100644
--- a/crates/ui2/src/components/chat_panel.rs
+++ b/crates/ui2/src/components/chat_panel.rs
@@ -24,7 +24,7 @@ impl<S: 'static + Send + Sync> ChatPanel<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div()
.id(self.element_id.clone())
.flex()
@@ -88,7 +88,7 @@ impl<S: 'static + Send + Sync> ChatMessage<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div()
.flex()
.flex_col()
@@ -133,7 +133,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, ChatPanel<S>>(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 6414e0e5ffb..40276f20b35 100644
--- a/crates/ui2/src/components/collab_panel.rs
+++ b/crates/ui2/src/components/collab_panel.rs
@@ -19,7 +19,7 @@ impl<S: 'static + Send + Sync> CollabPanel<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
v_stack()
@@ -114,7 +114,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, CollabPanel<S>>(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 45194e843c7..036a41e0b90 100644
--- a/crates/ui2/src/components/command_palette.rs
+++ b/crates/ui2/src/components/command_palette.rs
@@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> CommandPalette<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div().id(self.id.clone()).child(
Palette::new("palette")
.items(example_editor_actions())
@@ -53,7 +53,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, CommandPalette<S>>(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 73813ed6135..fb076dc9fe4 100644
--- a/crates/ui2/src/components/context_menu.rs
+++ b/crates/ui2/src/components/context_menu.rs
@@ -42,7 +42,7 @@ impl<S: 'static + Send + Sync> ContextMenu<S> {
items: items.into_iter().collect(),
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
v_stack()
@@ -89,7 +89,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, ContextMenu<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/components/copilot.rs b/crates/ui2/src/components/copilot.rs
index b0f20cfa0d8..8c51b1f4ebd 100644
--- a/crates/ui2/src/components/copilot.rs
+++ b/crates/ui2/src/components/copilot.rs
@@ -16,7 +16,7 @@ impl<S: 'static + Send + Sync + Clone> CopilotModal<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div().id(self.id.clone()).child(
Modal::new("some-id")
.title("Connect Copilot to Zed")
@@ -51,7 +51,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, CopilotModal<S>>(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 7489b3e47d8..b641c86f7e2 100644
--- a/crates/ui2/src/components/editor_pane.rs
+++ b/crates/ui2/src/components/editor_pane.rs
@@ -49,7 +49,7 @@ impl EditorPane {
)
}
- fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
+ fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<Self> {
v_stack()
.w_full()
.h_full()
diff --git a/crates/ui2/src/components/facepile.rs b/crates/ui2/src/components/facepile.rs
index 9a96d800105..b75ef328f33 100644
--- a/crates/ui2/src/components/facepile.rs
+++ b/crates/ui2/src/components/facepile.rs
@@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> Facepile<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let player_count = self.players.len();
let player_list = self.players.iter().enumerate().map(|(ix, player)| {
let isnt_last = ix < player_count - 1;
@@ -55,7 +55,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
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 b74165720d1..77d248e9ee1 100644
--- a/crates/ui2/src/components/icon_button.rs
+++ b/crates/ui2/src/components/icon_button.rs
@@ -68,7 +68,7 @@ impl<S: 'static + Send + Sync> IconButton<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
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 2fb40adac64..25de760cabe 100644
--- a/crates/ui2/src/components/keybinding.rs
+++ b/crates/ui2/src/components/keybinding.rs
@@ -34,7 +34,7 @@ impl<S: 'static + Send + Sync> Keybinding<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div()
.flex()
.gap_2()
@@ -68,7 +68,7 @@ impl<S: 'static + Send + Sync> Key<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
div()
@@ -189,7 +189,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
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 224db697544..dbead8467e0 100644
--- a/crates/ui2/src/components/language_selector.rs
+++ b/crates/ui2/src/components/language_selector.rs
@@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> LanguageSelector<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div().id(self.id.clone()).child(
Palette::new("palette")
.items(vec![
@@ -64,7 +64,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, LanguageSelector<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rs
index 99282fa06dd..0c41671247c 100644
--- a/crates/ui2/src/components/list.rs
+++ b/crates/ui2/src/components/list.rs
@@ -92,7 +92,7 @@ impl<S: 'static + Send + Sync> ListHeader<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
@@ -157,7 +157,7 @@ impl<S: 'static + Send + Sync> ListSubHeader<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
h_stack().flex_1().w_full().relative().py_1().child(
div()
.h_6()
@@ -230,7 +230,7 @@ impl<S: 'static + Send + Sync> From<ListSubHeader<S>> for ListItem<S> {
}
impl<S: 'static + Send + Sync> ListItem<S> {
- fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
match self {
ListItem::Entry(entry) => div().child(entry.render(view, cx)),
ListItem::Separator(separator) => div().child(separator.render(view, cx)),
@@ -347,7 +347,7 @@ impl<S: 'static + Send + Sync> ListEntry<S> {
fn disclosure_control(
&mut self,
cx: &mut ViewContext<S>,
- ) -> Option<impl Element<ViewState = S>> {
+ ) -> Option<impl Element<S>> {
let disclosure_control_icon = if let Some(ToggleState::Toggled) = self.toggle {
IconElement::new(Icon::ChevronDown)
} else {
@@ -367,7 +367,7 @@ impl<S: 'static + Send + Sync> ListEntry<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let settings = user_settings(cx);
let theme = theme(cx);
@@ -477,7 +477,7 @@ impl<S: 'static + Send + Sync> ListDetailsEntry<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let settings = user_settings(cx);
@@ -534,7 +534,7 @@ impl<S: 'static + Send + Sync> ListSeparator<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
div().h_px().w_full().bg(theme.border)
@@ -574,7 +574,7 @@ impl<S: 'static + Send + Sync> List<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
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 792f8e12682..154df4e862e 100644
--- a/crates/ui2/src/components/modal.rs
+++ b/crates/ui2/src/components/modal.rs
@@ -42,7 +42,7 @@ impl<S: 'static + Send + Sync> Modal<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
v_stack()
@@ -80,8 +80,8 @@ impl<S: 'static + Send + Sync> Modal<S> {
}
}
-impl<S: 'static + Send + Sync> ParentElement for Modal<S> {
- fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<Self::ViewState>; 2]> {
+impl<S: 'static + Send + Sync> ParentElement<S> for Modal<S> {
+ fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
&mut self.children
}
}
diff --git a/crates/ui2/src/components/multi_buffer.rs b/crates/ui2/src/components/multi_buffer.rs
index b53ea13ef23..568302b5595 100644
--- a/crates/ui2/src/components/multi_buffer.rs
+++ b/crates/ui2/src/components/multi_buffer.rs
@@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> MultiBuffer<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
v_stack()
@@ -66,7 +66,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
let theme = theme(cx);
Story::container(cx)
diff --git a/crates/ui2/src/components/notification_toast.rs b/crates/ui2/src/components/notification_toast.rs
index b7709e1a58e..afcef8fb203 100644
--- a/crates/ui2/src/components/notification_toast.rs
+++ b/crates/ui2/src/components/notification_toast.rs
@@ -28,7 +28,7 @@ impl<S: 'static + Send + Sync + Clone> NotificationToast<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
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 eaf64eb4848..fd0445d0070 100644
--- a/crates/ui2/src/components/notifications_panel.rs
+++ b/crates/ui2/src/components/notifications_panel.rs
@@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> NotificationsPanel<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
div()
@@ -74,7 +74,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, NotificationsPanel<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/components/palette.rs b/crates/ui2/src/components/palette.rs
index 87eb88c7648..9787086cd6d 100644
--- a/crates/ui2/src/components/palette.rs
+++ b/crates/ui2/src/components/palette.rs
@@ -46,7 +46,7 @@ impl<S: 'static + Send + Sync> Palette<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
v_stack()
@@ -135,7 +135,7 @@ impl<S: 'static + Send + Sync> PaletteItem<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div()
.flex()
.flex_row()
@@ -176,7 +176,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, Palette<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/components/panel.rs b/crates/ui2/src/components/panel.rs
index 90dbcf39599..0c52a7a12ad 100644
--- a/crates/ui2/src/components/panel.rs
+++ b/crates/ui2/src/components/panel.rs
@@ -96,7 +96,7 @@ impl<S: 'static + Send + Sync> Panel<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let current_size = self.width.unwrap_or(self.initial_width);
@@ -121,8 +121,8 @@ impl<S: 'static + Send + Sync> Panel<S> {
}
}
-impl<S: 'static + Send + Sync> ParentElement for Panel<S> {
- fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<Self::ViewState>; 2]> {
+impl<S: 'static + Send + Sync> ParentElement<S> for Panel<S> {
+ fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
&mut self.children
}
}
@@ -152,7 +152,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, Panel<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/components/panes.rs b/crates/ui2/src/components/panes.rs
index 77b6817d89f..fd958532013 100644
--- a/crates/ui2/src/components/panes.rs
+++ b/crates/ui2/src/components/panes.rs
@@ -40,7 +40,7 @@ impl<S: 'static + Send + Sync> Pane<S> {
self
}
- fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div()
.id(self.id.clone())
.flex()
@@ -70,8 +70,8 @@ impl<S: 'static + Send + Sync> Pane<S> {
}
}
-impl<S: 'static + Send + Sync> ParentElement for Pane<S> {
- fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<Self::ViewState>; 2]> {
+impl<S: 'static + Send + Sync> ParentElement<S> for Pane<S> {
+ fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
&mut self.children
}
}
@@ -103,7 +103,7 @@ impl<S: 'static + Send + Sync> PaneGroup<S> {
}
}
- fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
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 0240af8f47c..0ada98aa3f5 100644
--- a/crates/ui2/src/components/player_stack.rs
+++ b/crates/ui2/src/components/player_stack.rs
@@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> PlayerStack<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
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 9328b21d435..8b52a1b89aa 100644
--- a/crates/ui2/src/components/project_panel.rs
+++ b/crates/ui2/src/components/project_panel.rs
@@ -19,7 +19,7 @@ impl<S: 'static + Send + Sync> ProjectPanel<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
div()
@@ -83,7 +83,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, ProjectPanel<S>>(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 6a5f570562f..16c019be533 100644
--- a/crates/ui2/src/components/recent_projects.rs
+++ b/crates/ui2/src/components/recent_projects.rs
@@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> RecentProjects<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div().id(self.id.clone()).child(
Palette::new("palette")
.items(vec![
@@ -60,7 +60,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, RecentProjects<S>>(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 db28ac50703..5eeeb841ef6 100644
--- a/crates/ui2/src/components/status_bar.rs
+++ b/crates/ui2/src/components/status_bar.rs
@@ -86,7 +86,7 @@ impl StatusBar {
&mut self,
view: &mut Workspace,
cx: &mut ViewContext<Workspace>,
- ) -> impl Element<ViewState = Workspace> {
+ ) -> impl Element<Workspace> {
let theme = theme(cx);
div()
@@ -101,11 +101,7 @@ impl StatusBar {
.child(self.right_tools(view, cx))
}
- fn left_tools(
- &self,
- workspace: &mut Workspace,
- cx: &WindowContext,
- ) -> impl Element<ViewState = Workspace> {
+ fn left_tools(&self, workspace: &mut Workspace, cx: &WindowContext) -> impl Element<Workspace> {
div()
.flex()
.items_center()
@@ -136,7 +132,7 @@ impl StatusBar {
&self,
workspace: &mut Workspace,
cx: &WindowContext,
- ) -> impl Element<ViewState = Workspace> {
+ ) -> impl Element<Workspace> {
div()
.flex()
.items_center()
diff --git a/crates/ui2/src/components/tab.rs b/crates/ui2/src/components/tab.rs
index 451dba9aa47..4bfd21248fc 100644
--- a/crates/ui2/src/components/tab.rs
+++ b/crates/ui2/src/components/tab.rs
@@ -81,7 +81,7 @@ impl<S: 'static + Send + Sync + Clone> Tab<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let has_fs_conflict = self.fs_status == FileSystemStatus::Conflict;
let is_deleted = self.fs_status == FileSystemStatus::Deleted;
@@ -192,7 +192,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
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 ef67088287d..0cc9409c048 100644
--- a/crates/ui2/src/components/tab_bar.rs
+++ b/crates/ui2/src/components/tab_bar.rs
@@ -27,7 +27,7 @@ impl<S: 'static + Send + Sync + Clone> TabBar<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
@@ -116,7 +116,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, TabBar<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/components/terminal.rs b/crates/ui2/src/components/terminal.rs
index 236a8961bba..480c1a5da6a 100644
--- a/crates/ui2/src/components/terminal.rs
+++ b/crates/ui2/src/components/terminal.rs
@@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> Terminal<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let can_navigate_back = true;
@@ -109,7 +109,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, Terminal<S>>(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 3186e814bdc..cb1b491d87e 100644
--- a/crates/ui2/src/components/theme_selector.rs
+++ b/crates/ui2/src/components/theme_selector.rs
@@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> ThemeSelector<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div().child(
Palette::new(self.id.clone())
.items(vec![
@@ -65,7 +65,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, ThemeSelector<S>>(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 4cfb0921691..68661d0ea20 100644
--- a/crates/ui2/src/components/title_bar.rs
+++ b/crates/ui2/src/components/title_bar.rs
@@ -87,7 +87,7 @@ impl TitleBar {
)
}
- fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
+ fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<Self> {
let theme = theme(cx);
let settings = user_settings(cx);
@@ -204,7 +204,7 @@ mod stories {
)
}
- fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
+ fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<Self> {
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 f75f9218417..9318b12eec2 100644
--- a/crates/ui2/src/components/toast.rs
+++ b/crates/ui2/src/components/toast.rs
@@ -36,7 +36,7 @@ impl<S: 'static + Send + Sync> Toast<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let mut div = div();
@@ -61,8 +61,8 @@ impl<S: 'static + Send + Sync> Toast<S> {
}
}
-impl<S: 'static + Send + Sync> ParentElement for Toast<S> {
- fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<Self::ViewState>; 2]> {
+impl<S: 'static + Send + Sync> ParentElement<S> for Toast<S> {
+ fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
&mut self.children
}
}
@@ -90,11 +90,7 @@ mod stories {
}
}
- fn render(
- &mut self,
- _view: &mut S,
- cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, Toast<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/components/toolbar.rs b/crates/ui2/src/components/toolbar.rs
index 2dc5dbff2fb..51ec6ee4976 100644
--- a/crates/ui2/src/components/toolbar.rs
+++ b/crates/ui2/src/components/toolbar.rs
@@ -54,7 +54,7 @@ impl<S: 'static + Send + Sync> Toolbar<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
div()
@@ -96,7 +96,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
let theme = theme(cx);
Story::container(cx)
diff --git a/crates/ui2/src/components/traffic_lights.rs b/crates/ui2/src/components/traffic_lights.rs
index 254855bc3f7..e8750759428 100644
--- a/crates/ui2/src/components/traffic_lights.rs
+++ b/crates/ui2/src/components/traffic_lights.rs
@@ -25,7 +25,7 @@ impl<S: 'static + Send + Sync> TrafficLight<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let fill = match (self.window_has_focus, self.color) {
@@ -58,7 +58,7 @@ impl<S: 'static + Send + Sync> TrafficLights<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div()
.flex()
.items_center()
@@ -103,7 +103,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, TrafficLights<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/components/workspace.rs b/crates/ui2/src/components/workspace.rs
index ee913cb6931..92ea93ef026 100644
--- a/crates/ui2/src/components/workspace.rs
+++ b/crates/ui2/src/components/workspace.rs
@@ -3,13 +3,13 @@ use std::sync::Arc;
use chrono::DateTime;
use gpui2::{px, relative, rems, view, Context, Size, View};
-use crate::{prelude::*, NotificationsPanel};
use crate::{
- static_livestream, old_theme, user_settings_mut, v_stack, AssistantPanel, Button, ChatMessage,
+ old_theme, static_livestream, user_settings_mut, v_stack, AssistantPanel, Button, ChatMessage,
ChatPanel, CollabPanel, EditorPane, FakeSettings, Label, LanguageSelector, Pane, PaneGroup,
Panel, PanelAllowedSides, PanelSide, ProjectPanel, SettingValue, SplitDirection, StatusBar,
Terminal, TitleBar, Toast, ToastOrigin,
};
+use crate::{prelude::*, NotificationsPanel};
#[derive(Clone)]
pub struct Gpui2UiDebug {
@@ -174,7 +174,7 @@ impl Workspace {
view(cx.entity(|cx| Self::new(cx)), Self::render)
}
- pub fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
+ pub fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<Self> {
let theme = old_theme(cx).clone();
// HACK: This should happen inside of `debug_toggle_user_settings`, but
diff --git a/crates/ui2/src/element_ext.rs b/crates/ui2/src/element_ext.rs
index a6ad48e6296..813f01dd24c 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<S: 'static + Send + Sync>: Element<ViewState = S> {
+pub trait ElementExt<S: 'static + Send + Sync>: Element<S> {
/// 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.
@@ -25,4 +25,4 @@ pub trait ElementExt<S: 'static + Send + Sync>: Element<ViewState = S> {
// }
}
-impl<S: 'static + Send + Sync, E: Element<ViewState = S>> ElementExt<S> for E {}
+impl<S: 'static + Send + Sync, E: Element<S>> ElementExt<S> for E {}
diff --git a/crates/ui2/src/elements/avatar.rs b/crates/ui2/src/elements/avatar.rs
index 416a55a4f7a..0bc1ccad227 100644
--- a/crates/ui2/src/elements/avatar.rs
+++ b/crates/ui2/src/elements/avatar.rs
@@ -25,7 +25,7 @@ impl<S: 'static + Send + Sync> Avatar<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let mut img = img();
@@ -67,7 +67,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, Avatar<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/elements/button.rs b/crates/ui2/src/elements/button.rs
index 9948c91999a..363f70ddb42 100644
--- a/crates/ui2/src/elements/button.rs
+++ b/crates/ui2/src/elements/button.rs
@@ -154,7 +154,7 @@ impl<S: 'static + Send + Sync> Button<S> {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
let icon_color = self.icon_color();
let mut button = h_stack()
@@ -211,7 +211,7 @@ impl<S: 'static + Send + Sync> ButtonGroup<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let mut el = h_stack().text_size(ui_size(cx, 1.));
for button in &mut self.buttons {
@@ -250,7 +250,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
let states = InteractionState::iter();
Story::container(cx)
diff --git a/crates/ui2/src/elements/details.rs b/crates/ui2/src/elements/details.rs
index 9a37fb09358..e7df25f6a39 100644
--- a/crates/ui2/src/elements/details.rs
+++ b/crates/ui2/src/elements/details.rs
@@ -30,7 +30,7 @@ impl<S: 'static + Send + Sync> Details<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
v_stack()
@@ -70,7 +70,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, Details<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/elements/icon.rs b/crates/ui2/src/elements/icon.rs
index ebeed25ea83..d20f262fbcb 100644
--- a/crates/ui2/src/elements/icon.rs
+++ b/crates/ui2/src/elements/icon.rs
@@ -176,7 +176,7 @@ impl<S: 'static + Send + Sync> IconElement<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let fill = self.color.color(cx);
let svg_size = match self.size {
IconSize::Small => ui_size(cx, 12. / 14.),
@@ -218,7 +218,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
let icons = Icon::iter();
Story::container(cx)
diff --git a/crates/ui2/src/elements/input.rs b/crates/ui2/src/elements/input.rs
index af0e73c9eb4..56d81a0831f 100644
--- a/crates/ui2/src/elements/input.rs
+++ b/crates/ui2/src/elements/input.rs
@@ -60,7 +60,7 @@ impl<S: 'static + Send + Sync> Input<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let (input_bg, input_hover_bg, input_active_bg) = match self.variant {
@@ -136,7 +136,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, Input<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/elements/label.rs b/crates/ui2/src/elements/label.rs
index 81219206a99..d29ab8a5ee4 100644
--- a/crates/ui2/src/elements/label.rs
+++ b/crates/ui2/src/elements/label.rs
@@ -83,7 +83,7 @@ impl<S: 'static + Send + Sync> Label<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
div()
.when(self.strikethrough, |this| {
this.relative().child(
@@ -135,7 +135,7 @@ impl<S: 'static + Send + Sync> HighlightedLabel<S> {
self
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
let highlight_color = theme.text_accent;
@@ -227,7 +227,7 @@ mod stories {
&mut self,
_view: &mut S,
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Story::container(cx)
.child(Story::title_for::<_, Label<S>>(cx))
.child(Story::label(cx, "Default"))
diff --git a/crates/ui2/src/elements/tool_divider.rs b/crates/ui2/src/elements/tool_divider.rs
index 68b97ccb035..46b790e6bb1 100644
--- a/crates/ui2/src/elements/tool_divider.rs
+++ b/crates/ui2/src/elements/tool_divider.rs
@@ -14,7 +14,7 @@ impl<S: 'static + Send + Sync> ToolDivider<S> {
}
}
- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<S> {
let theme = theme(cx);
div().w_px().h_3().bg(theme.border)
diff --git a/crates/ui2/src/story.rs b/crates/ui2/src/story.rs
index 7a5358dfed1..9fc6a11f197 100644
--- a/crates/ui2/src/story.rs
+++ b/crates/ui2/src/story.rs
@@ -21,7 +21,7 @@ impl Story {
pub fn title<S: 'static + Send + Sync>(
cx: &mut ViewContext<S>,
title: &str,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
let theme = theme(cx);
div()
@@ -32,14 +32,14 @@ impl Story {
pub fn title_for<S: 'static + Send + Sync, T>(
cx: &mut ViewContext<S>,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
Self::title(cx, std::any::type_name::<T>())
}
pub fn label<S: 'static + Send + Sync>(
cx: &mut ViewContext<S>,
label: &str,
- ) -> impl Element<ViewState = S> {
+ ) -> impl Element<S> {
let theme = theme(cx);
div()
diff --git a/crates/ui2/src/theme.rs b/crates/ui2/src/theme.rs
index 00f20f59674..b585140cf73 100644
--- a/crates/ui2/src/theme.rs
+++ b/crates/ui2/src/theme.rs
@@ -132,10 +132,11 @@ where
deserializer.deserialize_map(SyntaxVisitor)
}
-pub fn themed<E, F>(theme: Theme, cx: &mut ViewContext<E::ViewState>, build_child: F) -> Themed<E>
+pub fn themed<V, E, F>(theme: Theme, cx: &mut ViewContext<V>, build_child: F) -> Themed<E>
where
- E: Element,
- F: FnOnce(&mut ViewContext<E::ViewState>) -> E,
+ V: 'static,
+ E: Element<V>,
+ F: FnOnce(&mut ViewContext<V>) -> E,
{
cx.default_global::<ThemeStack>().0.push(theme.clone());
let child = build_child(cx);
@@ -148,12 +149,13 @@ pub struct Themed<E> {
pub(crate) child: E,
}
-impl<E> IntoAnyElement<E::ViewState> for Themed<E>
+impl<V, E> IntoAnyElement<V> for Themed<E>
where
- E: 'static + Element + Send + Sync,
+ V: 'static,
+ E: 'static + Element<V> + Send + Sync,
E::ElementState: Send + Sync,
{
- fn into_any(self) -> AnyElement<E::ViewState> {
+ fn into_any(self) -> AnyElement<V> {
AnyElement::new(self)
}
}
@@ -161,11 +163,11 @@ where
#[derive(Default)]
struct ThemeStack(Vec<Theme>);
-impl<E: 'static + Element + Send + Sync> Element for Themed<E>
+impl<V, E: 'static + Element<V> + Send + Sync> Element<V> for Themed<E>
where
+ V: 'static,
E::ElementState: Send + Sync,
{
- type ViewState = E::ViewState;
type ElementState = E::ElementState;
fn id(&self) -> Option<gpui2::ElementId> {
@@ -174,9 +176,9 @@ where
fn initialize(
&mut self,
- view_state: &mut Self::ViewState,
+ view_state: &mut V,
element_state: Option<Self::ElementState>,
- cx: &mut ViewContext<Self::ViewState>,
+ cx: &mut ViewContext<V>,
) -> Self::ElementState {
cx.default_global::<ThemeStack>().0.push(self.theme.clone());
let element_state = self.child.initialize(view_state, element_state, cx);
@@ -186,9 +188,9 @@ where
fn layout(
&mut self,
- view_state: &mut E::ViewState,
+ view_state: &mut V,
element_state: &mut Self::ElementState,
- cx: &mut ViewContext<E::ViewState>,
+ cx: &mut ViewContext<V>,
) -> LayoutId
where
Self: Sized,
@@ -202,9 +204,9 @@ where
fn paint(
&mut self,
bounds: Bounds<Pixels>,
- view_state: &mut Self::ViewState,
+ view_state: &mut V,
frame_state: &mut Self::ElementState,
- cx: &mut ViewContext<Self::ViewState>,
+ cx: &mut ViewContext<V>,
) where
Self: Sized,
{