Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Nathan Sobo45429b5400e9
diff --git a/crates/gpui/src/platform/mac/renderer.rs b/crates/gpui/src/platform/mac/renderer.rsindex 55ec3e9e9a2..ef0757ea3e7 100644--- a/crates/gpui/src/platform/mac/renderer.rs+++ b/crates/gpui/src/platform/mac/renderer.rs@@ -631,7 +631,9 @@ impl Renderer {glyph.origin,) {// Snap sprite to pixel grid.- let origin = (glyph.origin * scale_factor).floor() + sprite.offset.to_f32();+ let origin = dbg!(+ dbg!((glyph.origin * scale_factor).floor()) + dbg!(sprite.offset.to_f32())+ );sprites_by_atlas.entry(sprite.atlas_id).or_insert_with(Vec::new)diff --git a/crates/gpui2/src/color.rs b/crates/gpui2/src/color.rsindex 11590f967cd..b128ea691c1 100644--- a/crates/gpui2/src/color.rs+++ b/crates/gpui2/src/color.rs@@ -160,6 +160,15 @@ pub fn black() -> Hsla {}}+pub fn white() -> Hsla {+ Hsla {+ h: 0.,+ s: 0.,+ l: 1.,+ a: 1.,+ }+}+impl From<Rgba> for Hsla {fn from(color: Rgba) -> Self {let r = color.r;diff --git a/crates/gpui3/src/geometry.rs b/crates/gpui3/src/geometry.rsindex 58147307632..ca8e2e5761d 100644--- a/crates/gpui3/src/geometry.rs+++ b/crates/gpui3/src/geometry.rs@@ -484,10 +484,6 @@ impl Pixels {Self(self.0.round())}- pub fn floor(&self) -> Self {- Self(self.0.floor())- }-pub fn scale(&self, factor: f32) -> ScaledPixels {ScaledPixels(self.0 * factor)}@@ -604,6 +600,12 @@ impl From<u64> for DevicePixels {#[repr(transparent)]pub struct ScaledPixels(pub(crate) f32);+impl ScaledPixels {+ pub fn floor(&self) -> Self {+ Self(self.0.floor())+ }+}+impl Eq for ScaledPixels {}impl Debug for ScaledPixels {diff --git a/crates/gpui3/src/window.rs b/crates/gpui3/src/window.rsindex 605f1390bfb..d6a7e23604e 100644--- a/crates/gpui3/src/window.rs+++ b/crates/gpui3/src/window.rs@@ -176,10 +176,10 @@ impl<'a, 'w> WindowContext<'a, 'w> {color: Hsla,) -> Result<()> {let scale_factor = self.scale_factor();- let origin = origin.scale(scale_factor);+ let glyph_origin = origin.scale(scale_factor);let subpixel_variant = Point {- x: (origin.x.0.fract() * SUBPIXEL_VARIANTS as f32).floor() as u8,- y: (origin.y.0.fract() * SUBPIXEL_VARIANTS as f32).floor() as u8,+ x: (glyph_origin.x.0.fract() * SUBPIXEL_VARIANTS as f32).floor() as u8,+ y: (glyph_origin.y.0.fract() * SUBPIXEL_VARIANTS as f32).floor() as u8,};let params = GlyphRasterizationParams {font_id,@@ -193,10 +193,12 @@ impl<'a, 'w> WindowContext<'a, 'w> {if !raster_bounds.is_zero() {let layer_id = self.current_layer_id();+ let offset = raster_bounds.origin.map(Into::into);let bounds = Bounds {- origin: origin + raster_bounds.origin.map(Into::into),+ origin: dbg!(dbg!(glyph_origin.map(|px| px.floor())) + dbg!(offset)),size: raster_bounds.size.map(Into::into),};+let tile = self.window.glyph_atlasdiff --git a/crates/storybook/src/workspace.rs b/crates/storybook/src/workspace.rsindex d9f9c22fcb4..0ec7b1881d6 100644--- a/crates/storybook/src/workspace.rs+++ b/crates/storybook/src/workspace.rs@@ -1,8 +1,9 @@use crate::{collab_panel::collab_panel, theme::theme};use gpui2::{+ black,elements::{div, div::ScrollState, img, svg},style::{StyleHelpers, Styleable},- Element, IntoElement, ParentElement, ViewContext,+ white, Element, IntoElement, ParentElement, ViewContext,};#[derive(Element, Default)]@@ -19,29 +20,37 @@ impl WorkspaceElement {fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {let theme = theme(cx);- div()+ return div().size_full()- .flex()- .flex_col()- .font("Zed Sans Extended")- .gap_0()- .justify_start()- .items_start()- .text_color(theme.lowest.base.default.foreground)- .fill(theme.middle.base.default.background)- .child(titlebar())- .child(- div()- .flex_1()- .w_full()- .flex()- .flex_row()- .overflow_hidden()- .child(collab_panel(self.left_scroll_state.clone()))- .child(div().h_full().flex_1())- .child(collab_panel(self.right_scroll_state.clone())),- )- .child(statusbar())+ .fill(white())+ .font("Helvetica")+ .text_base()+ .text_color(black())+ .child("Hey");++ // div()+ // .size_full()+ // .flex()+ // .flex_col()+ // .font("Zed Sans Extended")+ // .gap_0()+ // .justify_start()+ // .items_start()+ // .text_color(theme.lowest.base.default.foreground)+ // .fill(theme.middle.base.default.background)+ // .child(titlebar())+ // .child(+ // div()+ // .flex_1()+ // .w_full()+ // .flex()+ // .flex_row()+ // .overflow_hidden()+ // .child(collab_panel(self.left_scroll_state.clone()))+ // .child(div().h_full().flex_1())+ // .child(collab_panel(self.right_scroll_state.clone())),+ // )+ // .child(statusbar())}}diff --git a/crates/storybook2/src/workspace.rs b/crates/storybook2/src/workspace.rsindex 1ffb536713e..f66f4832e8e 100644--- a/crates/storybook2/src/workspace.rs+++ b/crates/storybook2/src/workspace.rs@@ -4,8 +4,8 @@ use crate::{themes::rose_pine_dawn,};use gpui3::{- div, img, svg, view, white, Context, Element, ParentElement, RootView, StyleHelpers, View,- ViewContext, WindowContext,+ black, div, img, svg, view, white, Context, Element, ParentElement, RootView, StyleHelpers,+ View, ViewContext, WindowContext,};pub struct Workspace {@@ -28,12 +28,12 @@ impl Workspace {fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<State = Self> {let theme = rose_pine_dawn();div()+ .size_full().font("Helvetica")- .text_color(white()).text_base()- .size_full()- .fill(theme.middle.base.default.background)- .child("Hello world")+ .fill(white())+ .text_color(black())+ .child("Hey")// TODO: Implement style.//.size_full().fill(gpui3::hsla(0.83, 1., 0.5, 1.))