Merge branch 'main' into marshall/gpui2-playground

This commit is contained in:
Marshall Bowers
2023-10-06 13:33:04 -04:00
107 changed files with 6777 additions and 2442 deletions
+6 -10
View File
@@ -5,7 +5,7 @@ use crate::{
use anyhow::Result;
use gpui::{
geometry::{vector::Vector2F, Size},
text_layout::LineLayout,
text_layout::Line,
LayoutId,
};
use parking_lot::Mutex;
@@ -42,7 +42,7 @@ impl<V: 'static> Element<V> for Text {
_view: &mut V,
cx: &mut ViewContext<V>,
) -> Result<(LayoutId, Self::PaintState)> {
let fonts = cx.platform().fonts();
let layout_cache = cx.text_layout_cache().clone();
let text_style = cx.text_style();
let line_height = cx.font_cache().line_height(text_style.font_size);
let text = self.text.clone();
@@ -51,14 +51,14 @@ impl<V: 'static> Element<V> for Text {
let layout_id = cx.add_measured_layout_node(Default::default(), {
let paint_state = paint_state.clone();
move |_params| {
let line_layout = fonts.layout_line(
let line_layout = layout_cache.layout_str(
text.as_ref(),
text_style.font_size,
&[(text.len(), text_style.to_run())],
);
let size = Size {
width: line_layout.width,
width: line_layout.width(),
height: line_height,
};
@@ -95,13 +95,9 @@ impl<V: 'static> Element<V> for Text {
line_height = paint_state.line_height;
}
let text_style = cx.text_style();
let line =
gpui::text_layout::Line::new(line_layout, &[(self.text.len(), text_style.to_run())]);
// TODO: We haven't added visible bounds to the new element system yet, so this is a placeholder.
let visible_bounds = bounds;
line.paint(bounds.origin(), visible_bounds, line_height, cx.legacy_cx);
line_layout.paint(bounds.origin(), visible_bounds, line_height, cx.legacy_cx);
}
}
@@ -114,6 +110,6 @@ impl<V: 'static> IntoElement<V> for Text {
}
pub struct TextLayout {
line_layout: Arc<LineLayout>,
line_layout: Arc<Line>,
line_height: f32,
}