diff --git a/crates/story/examples/tiles.rs b/crates/story/examples/tiles.rs index d4c257ba..2326ee7e 100644 --- a/crates/story/examples/tiles.rs +++ b/crates/story/examples/tiles.rs @@ -94,11 +94,11 @@ impl Panel for ContainerPanel { "ContainerPanel" } - fn title(&mut self, window: &mut Window, cx: &mut Context) -> AnyElement { + fn title(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { self.panel.title(window, cx) } - fn title_suffix(&mut self, _: &mut Window, cx: &mut Context) -> Option { + fn title_suffix(&mut self, _: &mut Window, cx: &mut Context) -> Option { Some( div() .w_24() diff --git a/crates/story/src/lib.rs b/crates/story/src/lib.rs index 5cfcf982..3c9cdfd3 100644 --- a/crates/story/src/lib.rs +++ b/crates/story/src/lib.rs @@ -692,7 +692,7 @@ impl Panel for StoryContainer { "StoryContainer" } - fn title(&mut self, _window: &mut Window, _cx: &mut Context) -> AnyElement { + fn title(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { self.name.clone().into_any_element() } diff --git a/crates/ui/src/dock/panel.rs b/crates/ui/src/dock/panel.rs index 019c2f70..ea65c590 100644 --- a/crates/ui/src/dock/panel.rs +++ b/crates/ui/src/dock/panel.rs @@ -66,8 +66,8 @@ pub trait Panel: EventEmitter + Render + Focusable { } /// The title of the panel - fn title(&mut self, window: &mut Window, cx: &mut Context) -> AnyElement { - SharedString::from(t!("Dock.Unnamed")).into_any_element() + fn title(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + SharedString::from(t!("Dock.Unnamed")) } /// The theme of the panel title, default is `None`. @@ -78,8 +78,12 @@ pub trait Panel: EventEmitter + Render + Focusable { /// The suffix of the panel title, default is `None`. /// /// This is used to add a suffix element to the panel title. - fn title_suffix(&mut self, window: &mut Window, cx: &mut Context) -> Option { - None + fn title_suffix( + &mut self, + window: &mut Window, + cx: &mut Context, + ) -> Option { + None:: } /// Whether the panel can be closed, default is `true`. @@ -197,11 +201,14 @@ impl PanelView for Entity { } fn title(&self, window: &mut Window, cx: &mut App) -> AnyElement { - self.update(cx, |this, cx| this.title(window, cx)) + self.update(cx, |this, cx| this.title(window, cx).into_any_element()) } fn title_suffix(&self, window: &mut Window, cx: &mut App) -> Option { - self.update(cx, |this, cx| this.title_suffix(window, cx)) + self.update(cx, |this, cx| { + this.title_suffix(window, cx) + .map(|el| el.into_any_element()) + }) } fn title_style(&self, cx: &App) -> Option { diff --git a/crates/ui/src/dock/stack_panel.rs b/crates/ui/src/dock/stack_panel.rs index a9ecb5f3..1dd91081 100644 --- a/crates/ui/src/dock/stack_panel.rs +++ b/crates/ui/src/dock/stack_panel.rs @@ -32,9 +32,10 @@ impl Panel for StackPanel { "StackPanel" } - fn title(&mut self, _window: &mut Window, _cx: &mut Context) -> gpui::AnyElement { - "StackPanel".into_any_element() + fn title(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { + "StackPanel" } + fn set_active(&mut self, active: bool, window: &mut Window, cx: &mut Context) { for panel in &self.panels { panel.set_active(active, window, cx); diff --git a/crates/ui/src/dock/tab_panel.rs b/crates/ui/src/dock/tab_panel.rs index e4576f43..9f597028 100644 --- a/crates/ui/src/dock/tab_panel.rs +++ b/crates/ui/src/dock/tab_panel.rs @@ -91,7 +91,7 @@ impl Panel for TabPanel { "TabPanel" } - fn title(&mut self, window: &mut Window, cx: &mut Context) -> gpui::AnyElement { + fn title(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { self.active_panel(cx) .map(|panel| panel.title(window, cx)) .unwrap_or("Empty Tab".into_any_element()) diff --git a/crates/ui/src/dock/tiles.rs b/crates/ui/src/dock/tiles.rs index 6e11606e..4e8a4426 100644 --- a/crates/ui/src/dock/tiles.rs +++ b/crates/ui/src/dock/tiles.rs @@ -148,7 +148,7 @@ impl Panel for Tiles { "Tiles" } - fn title(&mut self, _window: &mut Window, _cx: &mut Context) -> AnyElement { + fn title(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { "Tiles".into_any_element() }