diff --git a/crates/gpui3/src/elements.rs b/crates/gpui3/src/elements.rs index 1609512919..83c27b8a3b 100644 --- a/crates/gpui3/src/elements.rs +++ b/crates/gpui3/src/elements.rs @@ -4,3 +4,6 @@ mod svg; mod text; pub use div::*; +pub use img::*; +pub use svg::*; +pub use text::*; diff --git a/crates/gpui3/src/platform/mac/platform.rs b/crates/gpui3/src/platform/mac/platform.rs index 25a9e03583..eaa66461c2 100644 --- a/crates/gpui3/src/platform/mac/platform.rs +++ b/crates/gpui3/src/platform/mac/platform.rs @@ -1123,7 +1123,7 @@ mod tests { } fn build_platform() -> MacPlatform { - let mut platform = MacPlatform::new(); + let platform = MacPlatform::new(); platform.0.borrow_mut().pasteboard = unsafe { NSPasteboard::pasteboardWithUniqueName(nil) }; platform } diff --git a/crates/storybook2/src/collab_panel.rs b/crates/storybook2/src/collab_panel.rs index 26e7f77871..5931a8a9b0 100644 --- a/crates/storybook2/src/collab_panel.rs +++ b/crates/storybook2/src/collab_panel.rs @@ -1,12 +1,9 @@ use crate::theme::{theme, Theme}; -use gpui2::{ - elements::{div, div::ScrollState, img, svg}, - style::{StyleHelpers, Styleable}, - ArcCow, Element, IntoElement, ParentElement, ViewContext, +use gpui3::{ + div, img, svg, ArcCow, Element, IntoAnyElement, ParentElement, ScrollState, Styled, ViewContext, }; use std::marker::PhantomData; -#[derive(Element)] pub struct CollabPanelElement { view_type: PhantomData, scroll_state: ScrollState, @@ -22,7 +19,7 @@ pub fn collab_panel(scroll_state: ScrollState) -> CollabPanelElement } impl CollabPanelElement { - fn render(&mut self, _: &mut V, cx: &mut ViewContext) -> impl IntoElement { + fn render(&mut self, _: &mut V, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); // Panel @@ -117,10 +114,10 @@ impl CollabPanelElement { fn list_section_header( &self, - label: impl IntoElement, + label: impl IntoAnyElement, expanded: bool, theme: &Theme, - ) -> impl Element { + ) -> impl Element { div() .h_7() .px_2() @@ -146,9 +143,9 @@ impl CollabPanelElement { fn list_item( &self, avatar_uri: impl Into>, - label: impl IntoElement, + label: impl IntoAnyElement, theme: &Theme, - ) -> impl Element { + ) -> impl Element { div() .h_7() .px_2() diff --git a/crates/storybook2/src/element_ext.rs b/crates/storybook2/src/element_ext.rs index 42334d27b6..d7c5e3d1af 100644 --- a/crates/storybook2/src/element_ext.rs +++ b/crates/storybook2/src/element_ext.rs @@ -1,22 +1,17 @@ use crate::theme::{Theme, Themed}; use gpui3::Element; -use std::marker::PhantomData; pub trait ElementExt: Element { - fn themed(self, theme: Theme) -> Themed + fn themed(self, theme: Theme) -> Themed where Self: Sized; } -impl ElementExt for E { - fn themed(self, theme: Theme) -> Themed +impl ElementExt for E { + fn themed(self, theme: Theme) -> Themed where Self: Sized, { - Themed { - child: self, - theme, - view_type: PhantomData, - } + Themed { child: self, theme } } } diff --git a/crates/storybook2/src/theme.rs b/crates/storybook2/src/theme.rs index e6627bcc6c..30ce39d485 100644 --- a/crates/storybook2/src/theme.rs +++ b/crates/storybook2/src/theme.rs @@ -1,5 +1,5 @@ use gpui3::{ - serde_json, AppContext, Element, Hsla, IntoAnyElement, Layout, Vector2F, ViewContext, + serde_json, AppContext, Element, Hsla, IntoAnyElement, Layout, LayoutId, Vector2F, ViewContext, WindowContext, }; use serde::{de::Visitor, Deserialize, Deserializer}; @@ -131,25 +131,24 @@ where deserializer.deserialize_map(SyntaxVisitor) } -pub struct Themed> { +pub struct Themed { pub(crate) theme: Theme, pub(crate) child: E, - pub(crate) view_type: PhantomData, } -impl> Element for Themed { +impl Element for Themed { type FrameState = E::FrameState; fn layout( &mut self, - view: &mut V, - cx: &mut ViewContext, - ) -> anyhow::Result<(gpui2::LayoutId, Self::FrameState)> + state: &mut E::State, + cx: &mut ViewContext, + ) -> anyhow::Result<(LayoutId, Self::FrameState)> where Self: Sized, { cx.push_theme(self.theme.clone()); - let result = self.child.layout(view, cx); + let result = self.child.layout(state, cx); cx.pop_theme(); result } diff --git a/crates/storybook2/src/workspace.rs b/crates/storybook2/src/workspace.rs index efc75088ab..d44160449e 100644 --- a/crates/storybook2/src/workspace.rs +++ b/crates/storybook2/src/workspace.rs @@ -1,18 +1,18 @@ use crate::{collab_panel::collab_panel, theme::theme}; -use gpui3::{div, Element, IntoAnyElement, ParentElement, ScrollState, Styled, ViewContext}; +use gpui3::{div, img, svg, Element, ParentElement, ScrollState, Styled, ViewContext}; -#[derive(Element, Default)] +#[derive(Default)] struct WorkspaceElement { left_scroll_state: ScrollState, right_scroll_state: ScrollState, } -pub fn workspace() -> impl Element { +pub fn workspace() -> impl Element { WorkspaceElement::default() } impl WorkspaceElement { - fn render(&mut self, _: &mut V, cx: &mut ViewContext) -> impl IntoElement { + fn render(&mut self, _: &mut V, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() @@ -41,15 +41,14 @@ impl WorkspaceElement { } } -#[derive(Element)] struct TitleBar; -pub fn titlebar() -> impl Element { +pub fn titlebar() -> impl Element { TitleBar } impl TitleBar { - fn render(&mut self, _: &mut V, cx: &mut ViewContext) -> impl IntoElement { + fn render(&mut self, _: &mut V, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() .flex() @@ -62,7 +61,7 @@ impl TitleBar { .child(self.right_group(cx)) } - fn left_group(&mut self, cx: &mut ViewContext) -> impl IntoElement { + fn left_group(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() .flex() @@ -136,7 +135,7 @@ impl TitleBar { ) } - fn right_group(&mut self, cx: &mut ViewContext) -> impl IntoElement { + fn right_group(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() .flex() @@ -264,15 +263,14 @@ impl TitleBar { // ================================================================================ // -#[derive(Element)] struct StatusBar; -pub fn statusbar() -> impl Element { +pub fn statusbar() -> impl Element { StatusBar } impl StatusBar { - fn render(&mut self, _: &mut V, cx: &mut ViewContext) -> impl IntoElement { + fn render(&mut self, _: &mut V, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() .flex() @@ -285,7 +283,7 @@ impl StatusBar { .child(self.right_group(cx)) } - fn left_group(&mut self, cx: &mut ViewContext) -> impl IntoElement { + fn left_group(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() .flex() @@ -382,7 +380,7 @@ impl StatusBar { ) } - fn right_group(&mut self, cx: &mut ViewContext) -> impl IntoElement { + fn right_group(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); div() .flex()