Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Merge branch 'gpui2' into marshall/gpui2-playground
Marshall Bowers7fd35d68bbff
diff --cc crates/gpui3/src/style_helpers.rsindex 0557c81ef45,a0cdbffd91d..b58da2fbfc7--- a/crates/gpui3/src/style_helpers.rs+++ b/crates/gpui3/src/style_helpers.rs@@@ -1,12 -1,17 +1,14 @@@use crate::{- self as gpui3, relative, rems, AlignItems, Display, Fill, FlexDirection, Hsla, JustifyContent,- Length, Position, SharedString, Style, StyleRefinement, Styled, TextStyleRefinement,+ self as gpui3, hsla, point, px, relative, rems, AlignItems, BoxShadow, Display, Fill,+ FlexDirection, Hsla, JustifyContent, Length, Position, SharedString, Style, StyleRefinement,+ Styled, TextStyleRefinement,};+ use smallvec::smallvec;- pub trait StyleHelpers: Sized + Styled<Style = Style> {+ pub trait StyleHelpers: Styled<Style = Style> {gpui3_macros::style_helpers!();- fn h(mut self, height: Length) -> Self- where- Self: Sized,- {+ fn h(mut self, height: Length) -> Self {self.declared_style().size.height = Some(height);self}@@@ -147,6 -215,124 +149,103 @@@self}- fn shadow(mut self) -> Self- where- Self: Sized,- {++ fn shadow(mut self) -> Self {+ self.declared_style().box_shadow = Some(smallvec![+ BoxShadow {+ color: hsla(0., 0., 0., 0.1),+ offset: point(px(0.), px(1.)),+ blur_radius: px(3.),+ spread_radius: px(0.),+ },+ BoxShadow {+ color: hsla(0., 0., 0., 0.1),+ offset: point(px(0.), px(1.)),+ blur_radius: px(2.),+ spread_radius: px(-1.),+ }+ ]);+ self+ }+- fn shadow_none(mut self) -> Self- where- Self: Sized,- {++ fn shadow_none(mut self) -> Self {+ self.declared_style().box_shadow = Some(Default::default());+ self+ }+- fn shadow_sm(mut self) -> Self- where- Self: Sized,- {++ fn shadow_sm(mut self) -> Self {+ self.declared_style().box_shadow = Some(smallvec![BoxShadow {+ color: hsla(0., 0., 0., 0.05),+ offset: point(px(0.), px(1.)),+ blur_radius: px(2.),+ spread_radius: px(0.),+ }]);+ self+ }+- fn shadow_md(mut self) -> Self- where- Self: Sized,- {++ fn shadow_md(mut self) -> Self {+ self.declared_style().box_shadow = Some(smallvec![+ BoxShadow {+ color: hsla(0.5, 0., 0., 1.0),+ offset: point(px(0.), px(4.)),+ blur_radius: px(6.),+ spread_radius: px(-1.),+ },+ BoxShadow {+ color: hsla(0., 0., 0., 0.1),+ offset: point(px(0.), px(2.)),+ blur_radius: px(4.),+ spread_radius: px(-2.),+ }+ ]);+ self+ }+- fn shadow_lg(mut self) -> Self- where- Self: Sized,- {++ fn shadow_lg(mut self) -> Self {+ self.declared_style().box_shadow = Some(smallvec![+ BoxShadow {+ color: hsla(0., 0., 0., 0.1),+ offset: point(px(0.), px(10.)),+ blur_radius: px(15.),+ spread_radius: px(-3.),+ },+ BoxShadow {+ color: hsla(0., 0., 0., 0.1),+ offset: point(px(0.), px(4.)),+ blur_radius: px(6.),+ spread_radius: px(-4.),+ }+ ]);+ self+ }+- fn shadow_xl(mut self) -> Self- where- Self: Sized,- {++ fn shadow_xl(mut self) -> Self {+ self.declared_style().box_shadow = Some(smallvec![+ BoxShadow {+ color: hsla(0., 0., 0., 0.1),+ offset: point(px(0.), px(20.)),+ blur_radius: px(25.),+ spread_radius: px(-5.),+ },+ BoxShadow {+ color: hsla(0., 0., 0., 0.1),+ offset: point(px(0.), px(8.)),+ blur_radius: px(10.),+ spread_radius: px(-6.),+ }+ ]);+ self+ }+- fn shadow_2xl(mut self) -> Self- where- Self: Sized,- {++ fn shadow_2xl(mut self) -> Self {+ self.declared_style().box_shadow = Some(smallvec![BoxShadow {+ color: hsla(0., 0., 0., 0.25),+ offset: point(px(0.), px(25.)),+ blur_radius: px(50.),+ spread_radius: px(-12.),+ }]);+ self+ }+fn text_style(&mut self) -> &mut Option<TextStyleRefinement> {let style: &mut StyleRefinement = self.declared_style();&mut style.text@@@ -206,7 -416,100 +305,70 @@@self}- fn text_decoration_none(mut self) -> Self- where- Self: Sized,- {++ fn text_decoration_none(mut self) -> Self {+ self.text_style()+ .get_or_insert_with(Default::default)+ .underline = None;+ self+ }+- fn text_decoration_color(mut self, color: impl Into<Hsla>) -> Self- where- Self: Sized,- {++ fn text_decoration_color(mut self, color: impl Into<Hsla>) -> Self {+ let style = self.text_style().get_or_insert_with(Default::default);+ let underline = style.underline.get_or_insert_with(Default::default);+ underline.color = Some(color.into());+ self+ }+- fn text_decoration_solid(mut self) -> Self- where- Self: Sized,- {++ fn text_decoration_solid(mut self) -> Self {+ let style = self.text_style().get_or_insert_with(Default::default);+ let underline = style.underline.get_or_insert_with(Default::default);+ underline.wavy = false;+ self+ }+- fn text_decoration_wavy(mut self) -> Self- where- Self: Sized,- {++ fn text_decoration_wavy(mut self) -> Self {+ let style = self.text_style().get_or_insert_with(Default::default);+ let underline = style.underline.get_or_insert_with(Default::default);+ underline.wavy = true;+ self+ }+- fn text_decoration_0(mut self) -> Self- where- Self: Sized,- {++ fn text_decoration_0(mut self) -> Self {+ let style = self.text_style().get_or_insert_with(Default::default);+ let underline = style.underline.get_or_insert_with(Default::default);+ underline.thickness = px(0.);+ self+ }+- fn text_decoration_1(mut self) -> Self- where- Self: Sized,- {++ fn text_decoration_1(mut self) -> Self {+ let style = self.text_style().get_or_insert_with(Default::default);+ let underline = style.underline.get_or_insert_with(Default::default);+ underline.thickness = px(1.);+ self+ }+- fn text_decoration_2(mut self) -> Self- where- Self: Sized,- {++ fn text_decoration_2(mut self) -> Self {+ let style = self.text_style().get_or_insert_with(Default::default);+ let underline = style.underline.get_or_insert_with(Default::default);+ underline.thickness = px(2.);+ self+ }+- fn text_decoration_4(mut self) -> Self- where- Self: Sized,- {++ fn text_decoration_4(mut self) -> Self {+ let style = self.text_style().get_or_insert_with(Default::default);+ let underline = style.underline.get_or_insert_with(Default::default);+ underline.thickness = px(4.);+ self+ }+- fn text_decoration_8(mut self) -> Self- where- Self: Sized,- {++ fn text_decoration_8(mut self) -> Self {+ let style = self.text_style().get_or_insert_with(Default::default);+ let underline = style.underline.get_or_insert_with(Default::default);+ underline.thickness = px(8.);+ self+ }+- fn font(mut self, family_name: impl Into<SharedString>) -> Self- where- Self: Sized,- {+ fn font(mut self, family_name: impl Into<SharedString>) -> Self {self.text_style().get_or_insert_with(Default::default).font_family = Some(family_name.into());diff --cc crates/storybook2/src/theme.rsindex 7a32786adfe,498d626d765..785cf05c3b4--- a/crates/storybook2/src/theme.rs+++ b/crates/storybook2/src/theme.rs@@@ -1,10 -1,8 +1,10 @@@+use std::sync::Arc;+use std::{collections::HashMap, fmt};+use gpui3::{- BorrowAppContext, Element, Hsla, Layout, LayoutId, Result, ViewContext, WindowContext,+ BorrowAppContext, Bounds, Element, Hsla, LayoutId, Pixels, Result, ViewContext, WindowContext,};use serde::{de::Visitor, Deserialize, Deserializer};-use std::{collections::HashMap, fmt};#[derive(Deserialize, Clone, Default, Debug)]pub struct Theme {diff --cc crates/storybook2/src/workspace.rsindex a12f31b40b8,99841322914..65e9d82c1a7--- a/crates/storybook2/src/workspace.rs+++ b/crates/storybook2/src/workspace.rs@@@ -28,71 -26,32 +28,70 @@@ impl Workspace}fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<State = Self> {- let theme = rose_pine_dawn();-themed(rose_pine_dawn(), cx, |cx| {+ let theme = theme(cx);div().size_full()- .flex()- .flex_col()- .font("Courier")- .gap_0()- .justify_start()- .items_start()- .text_color(theme.lowest.base.default.foreground)- .fill(theme.middle.base.default.background)- .child(titlebar(cx))+ .v_stack()+ .fill(theme.lowest.base.default.background)+ .child(Panel::new(+ ScrollState::default(),+ |_, _| {+ vec![div()+ .font("Courier")+ .text_color(gpui3::hsla(1., 1., 1., 1.))+ .child("Hello world")+ .into_any()]+ },+ Box::new(()),+ )).child(div()- .flex_1()- .w_full()+ .size_full()+ .h_stack()+ .gap_3()+ .children((0..4).map(|i| {+ div().size_full().flex().fill(gpui3::hsla(+ 0. + (i as f32 / 7.),+ 0. + (i as f32 / 5.),+ 0.5,+ 1.,+ ))+ })),+ )+ .child(+ div()+ .size_full().flex()- .flex_row()- .overflow_hidden()- .child(self.left_panel.clone())- .child(div().h_full().flex_1())- .child(self.right_panel.clone()),+ .fill(theme.middle.negative.default.background),)- .child(statusbar::statusbar(cx))})++ // themed(rose_pine_dawn(), cx, |cx| {+ // div()+ // .size_full()+ // .flex()+ // .flex_col()+ // .font("Courier")+ // .gap_0()+ // .justify_start()+ // .items_start()+ // .text_color(theme.lowest.base.default.foreground)+ // .fill(theme.middle.base.default.background)+ // .child(titlebar(cx))+ // .child(+ // div()+ // .flex_1()+ // .w_full()+ // .flex()+ // .flex_row()+ // .overflow_hidden()+ // .child(self.left_panel.clone())+ // .child(div().h_full().flex_1())+ // .child(self.right_panel.clone()),+ // )+ // .child(statusbar::statusbar(cx))+ // })}}