Checkpoint

This commit is contained in:
Nathan Sobo 2023-09-08 16:08:31 -06:00
parent 362b1a44be
commit ebf8b32811
49 changed files with 491 additions and 627 deletions

View file

@ -1440,10 +1440,10 @@ impl Pane {
None
};
Canvas::new(move |scene, bounds, _, _, _| {
Canvas::new(move |bounds, _, _, cx| {
if let Some(color) = icon_color {
let square = RectF::new(bounds.origin(), vec2f(diameter, diameter));
scene.push_quad(Quad {
cx.scene().push_quad(Quad {
bounds: square,
background: Some(color),
border: Default::default(),
@ -2007,7 +2007,6 @@ impl<V: 'static> Element<V> for PaneBackdrop<V> {
fn paint(
&mut self,
scene: &mut gpui::SceneBuilder,
bounds: RectF,
visible_bounds: RectF,
_: &mut Self::LayoutState,
@ -2018,14 +2017,14 @@ impl<V: 'static> Element<V> for PaneBackdrop<V> {
let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default();
scene.push_quad(gpui::Quad {
cx.scene().push_quad(gpui::Quad {
bounds: RectF::new(bounds.origin(), bounds.size()),
background: Some(background),
..Default::default()
});
let child_view_id = self.child_view;
scene.push_mouse_region(
cx.scene().push_mouse_region(
MouseRegion::new::<Self>(child_view_id, 0, visible_bounds).on_down(
gpui::platform::MouseButton::Left,
move |_, _: &mut V, cx| {
@ -2035,10 +2034,9 @@ impl<V: 'static> Element<V> for PaneBackdrop<V> {
),
);
scene.paint_layer(Some(bounds), |scene| {
self.child
.paint(scene, bounds.origin(), visible_bounds, view, cx)
})
cx.scene().push_layer(Some(bounds));
self.child.paint(bounds.origin(), visible_bounds, view, cx);
cx.scene().pop_layer();
}
fn rect_for_text_range(

View file

@ -50,7 +50,7 @@ where
Stack::new()
.with_child(render_child(state, cx))
.with_children(drag_position.map(|drag_position| {
Canvas::new(move |scene, bounds, _, _, cx| {
Canvas::new(move |bounds, _, _, cx| {
if bounds.contains_point(drag_position) {
let overlay_region = split_margin
.and_then(|split_margin| {
@ -60,14 +60,15 @@ where
.map(|(dir, margin)| dir.along_edge(bounds, margin))
.unwrap_or(bounds);
scene.paint_stacking_context(None, None, |scene| {
scene.push_quad(Quad {
bounds: overlay_region,
background: Some(overlay_color(cx)),
border: Default::default(),
corner_radii: Default::default(),
});
cx.scene().push_stacking_context(None, None);
let background = overlay_color(cx);
cx.scene().push_quad(Quad {
bounds: overlay_region,
background: Some(background),
border: Default::default(),
corner_radii: Default::default(),
});
cx.scene().pop_stacking_context();
}
})
}))

View file

@ -595,7 +595,7 @@ mod element {
platform::{CursorStyle, MouseButton},
scene::MouseDrag,
AnyElement, Axis, CursorRegion, Element, EventContext, LayoutContext, MouseRegion,
PaintContext, RectFExt, SceneBuilder, SizeConstraint, Vector2FExt, ViewContext,
PaintContext, RectFExt, SizeConstraint, Vector2FExt, ViewContext,
};
use crate::{
@ -851,7 +851,6 @@ mod element {
fn paint(
&mut self,
scene: &mut SceneBuilder,
bounds: RectF,
visible_bounds: RectF,
remaining_space: &mut Self::LayoutState,
@ -863,7 +862,7 @@ mod element {
let overflowing = *remaining_space < 0.;
if overflowing {
scene.push_layer(Some(visible_bounds));
cx.scene().push_layer(Some(visible_bounds));
}
let mut child_origin = bounds.origin();
@ -874,7 +873,7 @@ mod element {
let mut children_iter = self.children.iter_mut().enumerate().peekable();
while let Some((ix, child)) = children_iter.next() {
let child_start = child_origin.clone();
child.paint(scene, child_origin, visible_bounds, view, cx);
child.paint(child_origin, visible_bounds, view, cx);
bounding_boxes.push(Some(RectF::new(child_origin, child.size())));
@ -884,7 +883,7 @@ mod element {
}
if can_resize && children_iter.peek().is_some() {
scene.push_stacking_context(None, None);
cx.scene().push_stacking_context(None, None);
let handle_origin = match self.axis {
Axis::Horizontal => child_origin - vec2f(HANDLE_HITBOX_SIZE / 2., 0.0),
@ -907,7 +906,7 @@ mod element {
Axis::Vertical => CursorStyle::ResizeUpDown,
};
scene.push_cursor_region(CursorRegion {
cx.scene().push_cursor_region(CursorRegion {
bounds: handle_bounds,
style,
});
@ -940,14 +939,14 @@ mod element {
}
}
});
scene.push_mouse_region(mouse_region);
cx.scene().push_mouse_region(mouse_region);
scene.pop_stacking_context();
cx.scene().pop_stacking_context();
}
}
if overflowing {
scene.pop_layer();
cx.scene().pop_layer();
}
}

View file

@ -73,14 +73,14 @@ impl View for SharedScreen {
let frame = self.frame.clone();
MouseEventHandler::new::<Focus, _>(0, cx, |_, cx| {
Canvas::new(move |scene, bounds, _, _, _| {
Canvas::new(move |bounds, _, _, cx| {
if let Some(frame) = frame.clone() {
let size = constrain_size_preserving_aspect_ratio(
bounds.size(),
vec2f(frame.width() as f32, frame.height() as f32),
);
let origin = bounds.origin() + (bounds.size() / 2.) - size / 2.;
scene.push_surface(gpui::platform::mac::Surface {
cx.scene().push_surface(gpui::platform::mac::Surface {
bounds: RectF::new(origin, size),
image_buffer: frame.image(),
});

View file

@ -8,8 +8,8 @@ use gpui::{
vector::{vec2f, Vector2F},
},
json::{json, ToJson},
AnyElement, AnyViewHandle, Entity, LayoutContext, PaintContext, SceneBuilder, SizeConstraint,
Subscription, View, ViewContext, ViewHandle, WindowContext,
AnyElement, AnyViewHandle, Entity, LayoutContext, PaintContext, SizeConstraint, Subscription,
View, ViewContext, ViewHandle, WindowContext,
};
pub trait StatusItemView: View {
@ -226,7 +226,6 @@ impl Element<StatusBar> for StatusBarElement {
fn paint(
&mut self,
scene: &mut SceneBuilder,
bounds: RectF,
visible_bounds: RectF,
_: &mut Self::LayoutState,
@ -237,12 +236,10 @@ impl Element<StatusBar> for StatusBarElement {
let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default();
let left_origin = vec2f(bounds.lower_left().x(), origin_y);
self.left
.paint(scene, left_origin, visible_bounds, view, cx);
self.left.paint(left_origin, visible_bounds, view, cx);
let right_origin = vec2f(bounds.upper_right().x() - self.right.size().x(), origin_y);
self.right
.paint(scene, right_origin, visible_bounds, view, cx);
self.right.paint(right_origin, visible_bounds, view, cx);
}
fn rect_for_text_range(

View file

@ -3626,13 +3626,13 @@ fn notify_of_new_dock(workspace: &WeakViewHandle<Workspace>, cx: &mut AsyncAppCo
"Looking for the dock? Try ctrl-`!\nshift-escape now zooms your pane.",
text,
)
.with_custom_runs(vec![26..32, 34..46], |_, bounds, scene, cx| {
.with_custom_runs(vec![26..32, 34..46], |_, bounds, cx| {
let code_span_background_color = settings::get::<ThemeSettings>(cx)
.theme
.editor
.document_highlight_read_background;
scene.push_quad(gpui::Quad {
cx.scene().push_quad(gpui::Quad {
bounds,
background: Some(code_span_background_color),
border: Default::default(),