Checkpoint

This commit is contained in:
Nathan Sobo
2023-09-08 16:25:10 -06:00
parent 362b1a44be
commit ebf8b32811
49 changed files with 491 additions and 627 deletions
+1 -2
View File
@@ -36,7 +36,6 @@ impl<V: 'static> gpui::Element<V> for AdapterElement<V> {
fn paint(
&mut self,
scene: &mut gpui::SceneBuilder,
bounds: RectF,
_visible_bounds: RectF,
layout_data: &mut Option<(LayoutEngine, LayoutId)>,
@@ -45,7 +44,7 @@ impl<V: 'static> gpui::Element<V> for AdapterElement<V> {
) -> Self::PaintState {
let (layout_engine, layout_id) = layout_data.take().unwrap();
legacy_cx.push_layout_engine(layout_engine);
let mut cx = PaintContext::new(legacy_cx, scene);
let mut cx = PaintContext::new(legacy_cx);
self.0.paint(view, bounds.origin(), &mut cx);
*layout_data = legacy_cx.pop_layout_engine().zip(Some(layout_id));
debug_assert!(layout_data.is_some());
+3 -3
View File
@@ -88,7 +88,7 @@ impl<V: 'static> Element<V> for Div<V> {
// TODO: Support only one dimension being hidden
let mut pop_layer = false;
if style.overflow.y != Overflow::Visible || style.overflow.x != Overflow::Visible {
cx.scene.push_layer(Some(bounds));
cx.scene().push_layer(Some(bounds));
pop_layer = true;
}
@@ -97,7 +97,7 @@ impl<V: 'static> Element<V> for Div<V> {
}
if pop_layer {
cx.scene.pop_layer();
cx.scene().pop_layer();
}
style.paint_foreground(bounds, cx);
@@ -221,7 +221,7 @@ impl<V: 'static> Div<V> {
let hovered = bounds.contains_point(cx.mouse_position());
if hovered {
let rem_size = cx.rem_size();
cx.scene.push_quad(scene::Quad {
cx.scene().push_quad(scene::Quad {
bounds,
background: Some(hsla(0., 0., 1., 0.05).into()),
border: gpui::Border {
+1 -1
View File
@@ -70,7 +70,7 @@ impl<V: 'static> Element<V> for Img {
.and_then(ResultExt::log_err)
{
let rem_size = cx.rem_size();
cx.scene.push_image(scene::Image {
cx.scene().push_image(scene::Image {
bounds,
border: gpui::Border {
color: style.border_color.unwrap_or_default().into(),
+1 -1
View File
@@ -63,7 +63,7 @@ impl<V: 'static> Element<V> for Svg {
color: Rgba::from(fill_color).into(),
};
cx.scene.push_icon(icon);
cx.scene().push_icon(icon);
}
}
}
+1 -7
View File
@@ -92,13 +92,7 @@ impl<V: 'static> Element<V> for Text {
// TODO: We haven't added visible bounds to the new element system yet, so this is a placeholder.
let visible_bounds = bounds;
line.paint(
cx.scene,
bounds.origin(),
visible_bounds,
line_height,
cx.legacy_cx,
);
line.paint(bounds.origin(), visible_bounds, line_height, cx.legacy_cx);
}
}
+3 -7
View File
@@ -11,15 +11,11 @@ pub struct PaintContext<'a, 'b, 'c, 'd, V> {
#[deref]
#[deref_mut]
pub(crate) legacy_cx: &'d mut LegacyPaintContext<'a, 'b, 'c, V>,
pub(crate) scene: &'d mut gpui::SceneBuilder,
}
impl<'a, 'b, 'c, 'd, V: 'static> PaintContext<'a, 'b, 'c, 'd, V> {
pub fn new(
legacy_cx: &'d mut LegacyPaintContext<'a, 'b, 'c, V>,
scene: &'d mut gpui::SceneBuilder,
) -> Self {
Self { legacy_cx, scene }
pub fn new(legacy_cx: &'d mut LegacyPaintContext<'a, 'b, 'c, V>) -> Self {
Self { legacy_cx }
}
pub fn on_event<E: 'static>(
@@ -29,7 +25,7 @@ impl<'a, 'b, 'c, 'd, V: 'static> PaintContext<'a, 'b, 'c, 'd, V> {
) {
let view = self.weak_handle();
self.scene.event_handlers.push(EventHandler {
self.scene().event_handlers.push(EventHandler {
order,
handler: Rc::new(move |event, window_cx| {
if let Some(view) = view.upgrade(window_cx) {
+2 -2
View File
@@ -167,7 +167,7 @@ impl Style {
pub fn paint_background<V: 'static>(&self, bounds: RectF, cx: &mut PaintContext<V>) {
let rem_size = cx.rem_size();
if let Some(color) = self.fill.as_ref().and_then(Fill::color) {
cx.scene.push_quad(gpui::Quad {
cx.scene().push_quad(gpui::Quad {
bounds,
background: Some(color.into()),
corner_radii: self.corner_radii.to_gpui(bounds.size(), rem_size),
@@ -183,7 +183,7 @@ impl Style {
if let Some(color) = self.border_color {
let border = self.border_widths.to_pixels(rem_size);
if !border.is_empty() {
cx.scene.push_quad(gpui::Quad {
cx.scene().push_quad(gpui::Quad {
bounds,
background: None,
corner_radii: self.corner_radii.to_gpui(bounds.size(), rem_size),