mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-27 16:57:08 +00:00
Checkpoint
This commit is contained in:
parent
f3560caf93
commit
657a25178d
2 changed files with 78 additions and 10 deletions
|
@ -5,6 +5,7 @@ use crate::{
|
|||
SharedString, Size, SizeRefinement, ViewContext, WindowContext,
|
||||
};
|
||||
use refineable::Refineable;
|
||||
use smallvec::SmallVec;
|
||||
pub use taffy::style::{
|
||||
AlignContent, AlignItems, AlignSelf, Display, FlexDirection, FlexWrap, JustifyContent,
|
||||
Overflow, Position,
|
||||
|
@ -90,7 +91,7 @@ pub struct Style {
|
|||
pub corner_radii: Corners<AbsoluteLength>,
|
||||
|
||||
/// Box Shadow of the element
|
||||
pub box_shadow: Option<BoxShadow>,
|
||||
pub box_shadow: SmallVec<[BoxShadow; 2]>,
|
||||
|
||||
/// TEXT
|
||||
pub text: TextStyleRefinement,
|
||||
|
@ -244,7 +245,7 @@ impl Style {
|
|||
let rem_size = cx.rem_size();
|
||||
let scale = cx.scale_factor();
|
||||
|
||||
if let Some(shadow) = self.box_shadow.as_ref() {
|
||||
for shadow in &self.box_shadow {
|
||||
let layer_id = cx.current_layer_id();
|
||||
let content_mask = cx.content_mask();
|
||||
let mut shadow_bounds = bounds;
|
||||
|
@ -328,7 +329,7 @@ impl Default for Style {
|
|||
fill: None,
|
||||
border_color: None,
|
||||
corner_radii: Corners::default(),
|
||||
box_shadow: None,
|
||||
box_shadow: Default::default(),
|
||||
text: TextStyleRefinement::default(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::{
|
|||
FlexDirection, Hsla, JustifyContent, Length, Position, SharedString, Style, StyleRefinement,
|
||||
Styled, TextStyleRefinement,
|
||||
};
|
||||
use smallvec::smallvec;
|
||||
|
||||
pub trait StyleHelpers: Styled<Style = Style> {
|
||||
gpui3_macros::style_helpers!();
|
||||
|
@ -218,6 +219,28 @@ pub trait StyleHelpers: Styled<Style = Style> {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
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,
|
||||
{
|
||||
self.declared_style().box_shadow = Some(Default::default());
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -225,12 +248,12 @@ pub trait StyleHelpers: Styled<Style = Style> {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.declared_style().box_shadow = Some(BoxShadow {
|
||||
color: hsla(0., 0., 0., 1.),
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -238,7 +261,20 @@ pub trait StyleHelpers: Styled<Style = Style> {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
todo!();
|
||||
self.declared_style().box_shadow = Some(smallvec![
|
||||
BoxShadow {
|
||||
color: hsla(0., 0., 0., 0.1),
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -246,7 +282,20 @@ pub trait StyleHelpers: Styled<Style = Style> {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
todo!();
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -254,7 +303,20 @@ pub trait StyleHelpers: Styled<Style = Style> {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
todo!();
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -262,7 +324,12 @@ pub trait StyleHelpers: Styled<Style = Style> {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
todo!();
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue