diff --git a/crates/gpui/src/platform/mac/renderer.rs b/crates/gpui/src/platform/mac/renderer.rs index 55ec3e9e9a..ef0757ea3e 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.rs index 11590f967c..b128ea691c 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 for Hsla { fn from(color: Rgba) -> Self { let r = color.r; diff --git a/crates/gpui3/src/geometry.rs b/crates/gpui3/src/geometry.rs index 5814730763..ca8e2e5761 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 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.rs index 605f1390bf..d6a7e23604 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_atlas diff --git a/crates/storybook/src/workspace.rs b/crates/storybook/src/workspace.rs index d9f9c22fcb..0ec7b1881d 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(&mut self, _: &mut V, cx: &mut ViewContext) -> impl IntoElement { 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.rs index 1ffb536713..f66f4832e8 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) -> impl Element { let theme = rose_pine_dawn(); div() - .font("Helvetica") - .text_color(white()) - .text_base() .size_full() - .fill(theme.middle.base.default.background) - .child("Hello world") + .font("Helvetica") + .text_base() + .fill(white()) + .text_color(black()) + .child("Hey") // TODO: Implement style. //.size_full().fill(gpui3::hsla(0.83, 1., 0.5, 1.))