From fd1633ac4b0973fd3e3aace7866414aeee6e9521 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 28 Aug 2023 14:24:27 -0600 Subject: [PATCH] Render a titlebar you can barely see Co-Authored-By: Mikayla Maki --- crates/gpui/playground/src/playground.rs | 14 ++++++++++++-- crates/gpui/playground/src/style.rs | 21 +++++++++++++++++++-- crates/gpui/src/app/window.rs | 4 ++++ crates/gpui/src/geometry.rs | 6 ++++++ 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/crates/gpui/playground/src/playground.rs b/crates/gpui/playground/src/playground.rs index 88e953b8bc..58b9f9438f 100644 --- a/crates/gpui/playground/src/playground.rs +++ b/crates/gpui/playground/src/playground.rs @@ -4,8 +4,9 @@ use crate::{ }; use element::Element; use gpui::{ - geometry::{rect::RectF, vector::vec2f}, + geometry::{pixels, rect::RectF, vector::vec2f}, platform::WindowOptions, + ViewContext, }; use log::LevelFilter; use simplelog::SimpleLogger; @@ -40,7 +41,7 @@ fn main() { center: true, ..Default::default() }, - |_| view(|_| playground(&rose_pine::moon())), + |_| view(|cx| workspace(&rose_pine::moon(), cx)), ); cx.platform().activate(true); }); @@ -58,3 +59,12 @@ fn playground(theme: &ThemeColors) -> impl Element { .child(div().fill(p.pine).child(div().fill(p.love).w_6().h_3())) .child(div().fill(p.gold).child(div().fill(p.iris).w_3().h_3())) } + +fn workspace(theme: &ThemeColors, cx: &mut ViewContext) -> impl Element { + use div::div; + // one line change1! + div() + .full() + .fill(theme.base(0.5)) + .child(div().h(pixels(cx.titlebar_height())).fill(theme.base(0.))) +} diff --git a/crates/gpui/playground/src/style.rs b/crates/gpui/playground/src/style.rs index 0d6a53e296..f01f269aa6 100644 --- a/crates/gpui/playground/src/style.rs +++ b/crates/gpui/playground/src/style.rs @@ -11,8 +11,8 @@ pub use gpui::taffy::style::{ use gpui::{ fonts::TextStyleRefinement, geometry::{ - rect::RectF, AbsoluteLength, DefiniteLength, Edges, EdgesRefinement, Length, Point, - PointRefinement, Size, SizeRefinement, + rect::RectF, relative, AbsoluteLength, DefiniteLength, Edges, EdgesRefinement, Length, + Point, PointRefinement, Size, SizeRefinement, }, taffy, }; @@ -286,6 +286,23 @@ pub trait Styleable { pub trait StyleHelpers: Styleable