Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Nathan Sobo0db8f681ba02
diff --git a/crates/gpui/src/elements.rs b/crates/gpui/src/elements.rsindex 78403444fff..b28ce1f5bfa 100644--- a/crates/gpui/src/elements.rs+++ b/crates/gpui/src/elements.rs@@ -1,5 +1,6 @@mod align;mod canvas;+mod cell;mod clipped;mod constrained_box;mod container;diff --git a/crates/gpui/src/elements/cell.rs b/crates/gpui/src/elements/cell.rsnew file mode 100644index 00000000000..43fb3a8e7fe--- /dev/null+++ b/crates/gpui/src/elements/cell.rs@@ -0,0 +1,154 @@+use crate::{color::Color, geometry::vector::Vector2F};++struct Cell {}++impl Cell {+ fn new(style: CellStyle) -> Self {+ Self { style }+ }++ fn interactive(style: Interactive<CellStyle>) -> Self {}+}++impl CellStyle {+ fn interactive(self) -> Interactive<CellStyle> {+ Interactive {+ default: self.clone(),+ hovered: self.clone(),+ active: self.clone(),+ disabled: self,+ }+ }++ fn hover(self, f: impl FnOnce(&mut CellStyle)) -> Interactive<CellStyle> {+ let mut style = self.interactive();+ f(&mut style.hovered);+ style+ }+}++fn foo() {++ struct WidgetStyle {+ foo: CellStyle,+ bar: CellStyle,+ button: Interactive<CellStyle>,+ }++ let mut header_style = CellStyle::default();+ header_style.fill = Fill::Color(Color::red());++ let style = CellStyle::default().hover(|style| {++ })++ let interactive = style.hover(|style| {+ style.fill = Fill::Color(Color::red());+ });+++ style.hover(|style| {+ style+ .fill(Color(red))+ .text_color(Color(red));+ })+}+struct Interactive<Style> {+ default: Style,+ hovered: Style,+ active: Style,+ disabled: Style,+}++#[derive(Clone, Default)]+struct CellStyle {+ axis: Axis,+ wrap: bool,+ align: Vector2F,+ overflow_x: Overflow,+ overflow_y: Overflow,+ gap_x: Gap,+ gap_y: Gap,++ width: Length,+ height: Length,++ text_color: Option<Color>,+ font_size: Option<f32>,+ font_style: Option<FontStyle>,+ font_weight: Option<FontWeight>,++ opacity: f32,+ fill: Fill,+ border: Border,+ corner_radii: CornerRadii,+ shadows: Vec<Shadow>,+}++struct CornerRadii {+ top_left: f32,+ top_right: f32,+ bottom_right: f32,+ bottom_left: f32,+}++enum Fill {+ Color(Color),+ Svg(String),+}++struct Border {+ color: Color,+ width: f32,+ top: bool,+ bottom: bool,+ left: bool,+ right: bool,+}++enum Length {+ Fixed(f32),+ Auto(f32),+}++enum Axis {+ X,+ Y,+ Z,+}++enum Overflow {+ Hidden,+ Auto,+}++enum Gap {+ Fixed(f32),+ Around,+ Between,+ Even,+}++struct Shadow {+ offset: Vector2F,+ blur: f32,+ color: Color,+}++enum FontStyle {+ Normal,+ Italic,+ Oblique,+}++enum FontWeight {+ Thin,+ ExtraLight,+ Light,+ Normal,+ Medium,+ Semibold,+ Bold,+ ExtraBold,+ Black,+}