From 0db8f681ba026fee28543b46fdb351a3856bae3d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 14 Jul 2023 11:58:43 -0600 Subject: [PATCH 001/612] WIP --- crates/gpui/src/elements.rs | 1 + crates/gpui/src/elements/cell.rs | 154 +++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 crates/gpui/src/elements/cell.rs diff --git a/crates/gpui/src/elements.rs b/crates/gpui/src/elements.rs index 78403444ff..b28ce1f5bf 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.rs new file mode 100644 index 0000000000..43fb3a8e7f --- /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) -> Self {} +} + +impl CellStyle { + fn interactive(self) -> Interactive { + Interactive { + default: self.clone(), + hovered: self.clone(), + active: self.clone(), + disabled: self, + } + } + + fn hover(self, f: impl FnOnce(&mut CellStyle)) -> Interactive { + let mut style = self.interactive(); + f(&mut style.hovered); + style + } +} + +fn foo() { + + struct WidgetStyle { + foo: CellStyle, + bar: CellStyle, + button: Interactive, + } + + 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