mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 10:40:54 +00:00
Render a titlebar you can barely see
Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
b5aedc144d
commit
fd1633ac4b
4 changed files with 41 additions and 4 deletions
|
@ -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.)))
|
||||
}
|
||||
|
|
|
@ -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) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -387,3 +387,9 @@ impl Default for Length {
|
|||
Self::Definite(DefiniteLength::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<()> for Length {
|
||||
fn from(_: ()) -> Self {
|
||||
Self::Definite(DefiniteLength::default())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue