diff --git a/Cargo.lock b/Cargo.lock index 090ab493bf923691d1d35fae93fe21128b0734bb..1c34050c7c064b55b08fe9276bc51d80e5d5326a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3363,6 +3363,7 @@ dependencies = [ "font-kit", "foreign-types 0.3.2", "futures 0.3.28", + "gpui2_macros", "gpui_macros", "image", "itertools", @@ -7696,6 +7697,21 @@ dependencies = [ "util", ] +[[package]] +name = "storybook2" +version = "0.1.0" +dependencies = [ + "anyhow", + "gpui3", + "log", + "rust-embed", + "serde", + "settings", + "simplelog", + "theme", + "util", +] + [[package]] name = "stringprep" version = "0.1.3" diff --git a/Cargo.toml b/Cargo.toml index 4c6d3a6fb9d742534e9b13dcef9e645db7761fa2..4a9606ffa10b6809314604418fb66990459a0890 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,7 @@ members = [ "crates/sqlez_macros", "crates/feature_flags", "crates/storybook", + "crates/storybook2", "crates/sum_tree", "crates/terminal", "crates/text", diff --git a/crates/gpui3/Cargo.toml b/crates/gpui3/Cargo.toml index 3a995aeb40adedaa254b77fe7e9be176c8bfb696..68a6ed081204f73299994fcefaeab1af9da2b7a3 100644 --- a/crates/gpui3/Cargo.toml +++ b/crates/gpui3/Cargo.toml @@ -16,6 +16,7 @@ doctest = false [dependencies] collections = { path = "../collections" } gpui_macros = { path = "../gpui_macros" } +gpui2_macros = { path = "../gpui2_macros" } util = { path = "../util" } sum_tree = { path = "../sum_tree" } sqlez = { path = "../sqlez" } diff --git a/crates/gpui3/src/elements.rs b/crates/gpui3/src/elements.rs index c2cecaf6c66a9c622b727708a79c82d9cc852496..f9d5a99101afe5e6d98ae181d0dbecb1132bbcae 100644 --- a/crates/gpui3/src/elements.rs +++ b/crates/gpui3/src/elements.rs @@ -1,7 +1,8 @@ -pub mod div; -pub mod editor; +mod div; +mod img; +mod svg; +mod text; use super::*; -pub use div::div; -pub use editor::field; +pub use div::*; diff --git a/crates/gpui3/src/elements/div.rs b/crates/gpui3/src/elements/div.rs index 4545bc83bd7e0e9716db3935e66126472a7a1961..9faad7a3e4ff65317cbf489907f2df9883f28eb0 100644 --- a/crates/gpui3/src/elements/div.rs +++ b/crates/gpui3/src/elements/div.rs @@ -77,7 +77,7 @@ impl Element for Div { // } for child in &mut self.children { - child.paint(scrolled_origin, state, cx); + child.paint(scrolled_origin, state, cx)?; } // if pop_layer { diff --git a/crates/gpui3/src/elements/editor.rs b/crates/gpui3/src/elements/editor.rs deleted file mode 100644 index 8b2cbc808b7bacbe9af56451cb98c1ce595c57b9..0000000000000000000000000000000000000000 --- a/crates/gpui3/src/elements/editor.rs +++ /dev/null @@ -1,61 +0,0 @@ -use super::{Element, Handle, Layout, LayoutId, Result, SharedString, ViewContext}; -use std::marker::PhantomData; - -pub fn field(editor: Handle) -> EditorElement { - EditorElement { - editor, - field: true, - placeholder_text: None, - parent_state: PhantomData, - } -} - -pub struct EditorElement { - editor: Handle, - field: bool, - placeholder_text: Option, - parent_state: PhantomData, -} - -impl EditorElement { - pub fn field(mut self) -> Self { - self.field = true; - self - } - - pub fn placeholder_text(mut self, text: impl Into) -> Self { - self.placeholder_text = Some(text.into()); - self - } -} - -impl Element for EditorElement { - type State = S; - type FrameState = (); - - fn layout( - &mut self, - _: &mut Self::State, - cx: &mut ViewContext, - ) -> Result<(LayoutId, Self::FrameState)> { - self.editor.update(cx, |_editor, _cx| todo!()) - } - - fn paint( - &mut self, - _layout: Layout, - _state: &mut Self::State, - _frame_state: &mut Self::FrameState, - cx: &mut ViewContext, - ) -> Result<()> { - self.editor.update(cx, |_editor, _cx| todo!()) - } -} - -pub struct Editor {} - -impl Editor { - pub fn new(_: &mut ViewContext) -> Self { - Editor {} - } -} diff --git a/crates/gpui3/src/elements/img.rs b/crates/gpui3/src/elements/img.rs index 866f2fa97169131ff32d64581ac7eccdc19db664..6ff9116c416a660dab0cf917c1f188754f29637e 100644 --- a/crates/gpui3/src/elements/img.rs +++ b/crates/gpui3/src/elements/img.rs @@ -1,101 +1,93 @@ -use crate as gpui2; -use crate::{ - style::{Style, StyleHelpers, Styleable}, - Element, -}; -use futures::FutureExt; -use gpui::geometry::vector::Vector2F; -use gpui::scene; -use gpui2_macros::IntoElement; +use crate::{Element, Layout, LayoutId, Result, Style, Styled}; use refineable::RefinementCascade; -use util::arc_cow::ArcCow; -use util::ResultExt; +use std::marker::PhantomData; +use util::{arc_cow::ArcCow, ResultExt}; -#[derive(IntoElement)] -pub struct Img { +pub struct Img { style: RefinementCascade