From dd6425e898d83e71cf65990b1e3a7d5cf3d3b29d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 10 Aug 2023 09:24:16 -0600 Subject: [PATCH] WIP --- crates/gpui/playground/src/playground.rs | 16 ++++++- crates/gpui/playground/ui/src/frame.rs | 9 ++++ .../gpui/playground/ui/src/playground_ui.rs | 6 ++- crates/gpui/playground/ui/src/themes.rs | 42 ++++++++++++------- crates/gpui/src/platform.rs | 2 +- 5 files changed, 56 insertions(+), 19 deletions(-) diff --git a/crates/gpui/playground/src/playground.rs b/crates/gpui/playground/src/playground.rs index 9a2f30c444..699ec7eaeb 100644 --- a/crates/gpui/playground/src/playground.rs +++ b/crates/gpui/playground/src/playground.rs @@ -1,6 +1,9 @@ use std::ops::{Deref, DerefMut}; -use gpui::{AnyElement, Element, Entity, View}; +use gpui::{ + platform::{TitlebarOptions, WindowOptions}, + AnyElement, Element, Entity, View, +}; use log::LevelFilter; use simplelog::SimpleLogger; @@ -9,7 +12,16 @@ fn main() { gpui::App::new(()).unwrap().run(|cx| { cx.platform().activate(true); - cx.add_window(Default::default(), |_| Playground::default()); + cx.add_window( + WindowOptions { + titlebar: Some(TitlebarOptions { + appears_transparent: true, + ..Default::default() + }), + ..Default::default() + }, + |_| Playground::default(), + ); }); } diff --git a/crates/gpui/playground/ui/src/frame.rs b/crates/gpui/playground/ui/src/frame.rs index 780b8cc5f8..e6481fd861 100644 --- a/crates/gpui/playground/ui/src/frame.rs +++ b/crates/gpui/playground/ui/src/frame.rs @@ -657,6 +657,15 @@ impl Size { } } +impl From for Size { + fn from(value: Length) -> Self { + Self { + width: value, + height: value, + } + } +} + #[derive(Clone, Default, Debug)] pub struct Edges { top: T, diff --git a/crates/gpui/playground/ui/src/playground_ui.rs b/crates/gpui/playground/ui/src/playground_ui.rs index 0c1fc46d51..2976d59cd7 100644 --- a/crates/gpui/playground/ui/src/playground_ui.rs +++ b/crates/gpui/playground/ui/src/playground_ui.rs @@ -3,7 +3,7 @@ use frame::{length::auto, *}; use gpui::{AnyElement, Element, LayoutContext, View, ViewContext}; use std::{borrow::Cow, cell::RefCell, marker::PhantomData, rc::Rc}; -use themes::ThemeColors; +use themes::{rose_pine, ThemeColors}; use tokens::{margin::m4, text::lg}; mod color; @@ -18,12 +18,14 @@ impl Frame {} impl Playground { pub fn render(&mut self, _: &mut V, _: &mut gpui::ViewContext) -> impl Element { - column() + workspace(&rose_pine::dawn()) } } fn workspace(theme: &ThemeColors) -> impl Element { column() + .size(auto()) + .fill(theme.base(0.1)) .child(title_bar(theme)) .child(stage(theme)) .child(status_bar(theme)) diff --git a/crates/gpui/playground/ui/src/themes.rs b/crates/gpui/playground/ui/src/themes.rs index b823c45c8b..f82954d94e 100644 --- a/crates/gpui/playground/ui/src/themes.rs +++ b/crates/gpui/playground/ui/src/themes.rs @@ -24,49 +24,63 @@ pub struct ThemeColors { impl ThemeColors { pub fn base(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.base.lerp(level) } + pub fn surface(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.surface.lerp(level) } + pub fn overlay(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.overlay.lerp(level) } + pub fn muted(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.muted.lerp(level) } + pub fn subtle(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.subtle.lerp(level) } + pub fn text(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.text.lerp(level) } + pub fn highlight_low(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.highlight_low.lerp(level) } + pub fn highlight_med(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.highlight_med.lerp(level) } + pub fn highlight_high(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.highlight_high.lerp(level) } + pub fn success(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.success.lerp(level) } + pub fn warning(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.warning.lerp(level) } + pub fn error(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.error.lerp(level) } + pub fn inserted(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.inserted.lerp(level) } + pub fn deleted(&self, level: f32) -> Hsla { self.deleted.lerp(level) } + pub fn modified(&self, level: f32) -> Hsla { - self.deleted.lerp(level) + self.modified.lerp(level) } } diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs index 1d93a45fc7..4dda941fd5 100644 --- a/crates/gpui/src/platform.rs +++ b/crates/gpui/src/platform.rs @@ -180,7 +180,7 @@ pub struct WindowOptions<'a> { pub screen: Option>, } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct TitlebarOptions<'a> { pub title: Option<&'a str>, pub appears_transparent: bool,