diff --git a/crates/gpui/src/gpui.rs b/crates/gpui/src/gpui.rs index a0e7804a14..74a50e9e64 100644 --- a/crates/gpui/src/gpui.rs +++ b/crates/gpui/src/gpui.rs @@ -28,6 +28,7 @@ pub mod json; pub mod keymap_matcher; pub mod platform; pub use gpui_macros::{test, Element}; +pub use usvg; pub use window::{ Axis, Layout, LayoutEngine, LayoutId, RectFExt, SizeConstraint, Vector2FExt, WindowContext, }; diff --git a/crates/gpui2/src/arc_cow.rs b/crates/gpui2/src/arc_cow.rs new file mode 100644 index 0000000000..26c9870ee0 --- /dev/null +++ b/crates/gpui2/src/arc_cow.rs @@ -0,0 +1,53 @@ +use std::sync::Arc; + +pub enum ArcCow<'a, T: ?Sized> { + Borrowed(&'a T), + Owned(Arc), +} + +impl<'a, T: ?Sized> Clone for ArcCow<'a, T> { + fn clone(&self) -> Self { + match self { + Self::Borrowed(borrowed) => Self::Borrowed(borrowed), + Self::Owned(owned) => Self::Owned(owned.clone()), + } + } +} + +impl<'a, T: ?Sized> From<&'a T> for ArcCow<'a, T> { + fn from(s: &'a T) -> Self { + Self::Borrowed(s) + } +} + +impl From> for ArcCow<'_, T> { + fn from(s: Arc) -> Self { + Self::Owned(s) + } +} + +impl From for ArcCow<'_, str> { + fn from(value: String) -> Self { + Self::Owned(value.into()) + } +} + +impl std::ops::Deref for ArcCow<'_, T> { + type Target = T; + + fn deref(&self) -> &Self::Target { + match self { + ArcCow::Borrowed(s) => s, + ArcCow::Owned(s) => s.as_ref(), + } + } +} + +impl AsRef for ArcCow<'_, T> { + fn as_ref(&self) -> &T { + match self { + ArcCow::Borrowed(borrowed) => borrowed, + ArcCow::Owned(owned) => owned.as_ref(), + } + } +} diff --git a/crates/gpui2/src/elements/text.rs b/crates/gpui2/src/elements/text.rs index 8bbec8e645..82527d8dc0 100644 --- a/crates/gpui2/src/elements/text.rs +++ b/crates/gpui2/src/elements/text.rs @@ -2,6 +2,7 @@ use crate::{ element::{Element, IntoElement, Layout}, layout_context::LayoutContext, paint_context::PaintContext, + ArcCow, }; use anyhow::Result; use gpui::{geometry::Size, text_layout::LineLayout, LayoutId}; @@ -93,55 +94,3 @@ pub struct TextLayout { line_layout: Arc, line_height: f32, } - -pub enum ArcCow<'a, T: ?Sized> { - Borrowed(&'a T), - Owned(Arc), -} - -impl<'a, T: ?Sized> Clone for ArcCow<'a, T> { - fn clone(&self) -> Self { - match self { - Self::Borrowed(borrowed) => Self::Borrowed(borrowed), - Self::Owned(owned) => Self::Owned(owned.clone()), - } - } -} - -impl<'a, T: ?Sized> From<&'a T> for ArcCow<'a, T> { - fn from(s: &'a T) -> Self { - Self::Borrowed(s) - } -} - -impl From> for ArcCow<'_, T> { - fn from(s: Arc) -> Self { - Self::Owned(s) - } -} - -impl From for ArcCow<'_, str> { - fn from(value: String) -> Self { - Self::Owned(value.into()) - } -} - -impl std::ops::Deref for ArcCow<'_, T> { - type Target = T; - - fn deref(&self) -> &Self::Target { - match self { - ArcCow::Borrowed(s) => s, - ArcCow::Owned(s) => s.as_ref(), - } - } -} - -impl AsRef for ArcCow<'_, T> { - fn as_ref(&self) -> &T { - match self { - ArcCow::Borrowed(borrowed) => borrowed, - ArcCow::Owned(owned) => owned.as_ref(), - } - } -} diff --git a/crates/gpui2/src/gpui2.rs b/crates/gpui2/src/gpui2.rs index a37f8cc50f..e9cddb65c8 100644 --- a/crates/gpui2/src/gpui2.rs +++ b/crates/gpui2/src/gpui2.rs @@ -1,4 +1,5 @@ pub mod adapter; +mod arc_cow; pub mod color; pub mod element; pub mod elements; @@ -8,6 +9,7 @@ pub mod paint_context; pub mod style; pub mod view; +pub use arc_cow::ArcCow; pub use color::*; pub use element::{AnyElement, Element, IntoElement, Layout, ParentElement}; pub use geometry::{ diff --git a/crates/storybook/src/collab_panel.rs b/crates/storybook/src/collab_panel.rs index 7e8b6fe397..a3b12af81c 100644 --- a/crates/storybook/src/collab_panel.rs +++ b/crates/storybook/src/collab_panel.rs @@ -19,7 +19,7 @@ impl CollabPanelElement { div() .full() - .font("Zed Mono") + .font("Zed Sans") .text_color(theme.middle.variant.default.foreground) .fill(theme.middle.base.default.background) .py_2() diff --git a/crates/storybook/src/components.rs b/crates/storybook/src/components.rs index 142bc36312..c24f9d672b 100644 --- a/crates/storybook/src/components.rs +++ b/crates/storybook/src/components.rs @@ -1,6 +1,6 @@ use gpui2::{ - elements::div, elements::text::ArcCow, interactive::Interactive, platform::MouseButton, - style::StyleHelpers, Element, IntoElement, ParentElement, ViewContext, + elements::div, interactive::Interactive, platform::MouseButton, style::StyleHelpers, ArcCow, + Element, IntoElement, ParentElement, ViewContext, }; use std::{marker::PhantomData, rc::Rc}; diff --git a/crates/storybook/src/storybook.rs b/crates/storybook/src/storybook.rs index 669da5da2d..5fe45af3b9 100644 --- a/crates/storybook/src/storybook.rs +++ b/crates/storybook/src/storybook.rs @@ -44,7 +44,7 @@ fn storybook(cx: &mut ViewContext) -> impl Element { collab_panel().themed(current_theme(cx)) } -// Nathan: During the transition, we will include the base theme on the legacy Theme struct. +// Nathan: During the transition to gpui2, we will include the base theme on the legacy Theme struct. fn current_theme(cx: &mut ViewContext) -> Theme { settings::get::(cx) .theme