Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Render a titlebar you can barely see
Nathan Sobofd1633ac4b09
diff --git a/crates/gpui/playground/src/playground.rs b/crates/gpui/playground/src/playground.rsindex 88e953b8bc9..58b9f9438f5 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<V: 'static>(theme: &ThemeColors) -> impl Element<V> {.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<V: 'static>(theme: &ThemeColors, cx: &mut ViewContext<V>) -> impl Element<V> {+ 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.rsindex 0d6a53e2960..f01f269aa62 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<Style = Style> {styleable_helpers!();+ fn h(mut self, height: Length) -> Self+ where+ Self: Sized,+ {+ self.declared_style().size.height = Some(height);+ self+ }++ fn full(mut self) -> Self+ where+ Self: Sized,+ {+ self.declared_style().size.width = Some(relative(1.));+ self.declared_style().size.height = Some(relative(1.));+ self+ }+fn relative(mut self) -> SelfwhereSelf: Sized,diff --git a/crates/gpui/src/app/window.rs b/crates/gpui/src/app/window.rsindex c243b4591a3..e1492eda997 100644--- a/crates/gpui/src/app/window.rs+++ b/crates/gpui/src/app/window.rs@@ -1190,6 +1190,10 @@ impl<'a> WindowContext<'a> {self.window.platform_window.bounds()}+ pub fn titlebar_height(&self) -> f32 {+ self.window.titlebar_height+ }+pub fn window_appearance(&self) -> Appearance {self.window.appearance}diff --git a/crates/gpui/src/geometry.rs b/crates/gpui/src/geometry.rsindex db9af34516f..c6312b18c44 100644--- a/crates/gpui/src/geometry.rs+++ b/crates/gpui/src/geometry.rs@@ -387,3 +387,9 @@ impl Default for Length {Self::Definite(DefiniteLength::default())}}++impl From<()> for Length {+ fn from(_: ()) -> Self {+ Self::Definite(DefiniteLength::default())+ }+}