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

@ -11,8 +11,8 @@ use gpui::{
serde_json::json,
text_layout::{Line, RunStyle},
AnyElement, Element, EventContext, FontCache, LayoutContext, ModelContext, MouseRegion,
PaintContext, Quad, SceneBuilder, SizeConstraint, TextLayoutCache, ViewContext,
WeakModelHandle,
PaintContext, Quad, SizeConstraint, TextLayoutCache, ViewContext, WeakModelHandle,
WindowContext,
};
use itertools::Itertools;
use language::CursorShape;
@ -86,12 +86,11 @@ impl LayoutCell {
fn paint(
&self,
scene: &mut SceneBuilder,
origin: Vector2F,
layout: &LayoutState,
visible_bounds: RectF,
_view: &mut TerminalView,
cx: &mut ViewContext<TerminalView>,
cx: &mut WindowContext,
) {
let pos = {
let point = self.point;
@ -102,7 +101,7 @@ impl LayoutCell {
};
self.text
.paint(scene, pos, visible_bounds, layout.size.line_height, cx);
.paint(pos, visible_bounds, layout.size.line_height, cx);
}
}
@ -132,11 +131,10 @@ impl LayoutRect {
fn paint(
&self,
scene: &mut SceneBuilder,
origin: Vector2F,
layout: &LayoutState,
_view: &mut TerminalView,
_cx: &mut ViewContext<TerminalView>,
cx: &mut ViewContext<TerminalView>,
) {
let position = {
let point = self.point;
@ -150,7 +148,7 @@ impl LayoutRect {
layout.size.line_height,
);
scene.push_quad(Quad {
cx.scene().push_quad(Quad {
bounds: RectF::new(position, size),
background: Some(self.color),
border: Default::default(),
@ -387,7 +385,6 @@ impl TerminalElement {
fn attach_mouse_handlers(
&self,
scene: &mut SceneBuilder,
origin: Vector2F,
visible_bounds: RectF,
mode: TermMode,
@ -518,7 +515,7 @@ impl TerminalElement {
)
}
scene.push_mouse_region(region);
cx.scene().push_mouse_region(region);
}
}
@ -733,7 +730,6 @@ impl Element<TerminalView> for TerminalElement {
fn paint(
&mut self,
scene: &mut SceneBuilder,
bounds: RectF,
visible_bounds: RectF,
layout: &mut Self::LayoutState,
@ -745,13 +741,13 @@ impl Element<TerminalView> for TerminalElement {
//Setup element stuff
let clip_bounds = Some(visible_bounds);
scene.paint_layer(clip_bounds, |scene| {
cx.paint_layer(clip_bounds, |cx| {
let origin = bounds.origin() + vec2f(layout.gutter, 0.);
// Elements are ephemeral, only at paint time do we know what could be clicked by a mouse
self.attach_mouse_handlers(scene, origin, visible_bounds, layout.mode, cx);
self.attach_mouse_handlers(origin, visible_bounds, layout.mode, cx);
scene.push_cursor_region(gpui::CursorRegion {
cx.scene().push_cursor_region(gpui::CursorRegion {
bounds,
style: if layout.hyperlink_tooltip.is_some() {
CursorStyle::PointingHand
@ -760,9 +756,9 @@ impl Element<TerminalView> for TerminalElement {
},
});
scene.paint_layer(clip_bounds, |scene| {
cx.paint_layer(clip_bounds, |cx| {
//Start with a background color
scene.push_quad(Quad {
cx.scene().push_quad(Quad {
bounds: RectF::new(bounds.origin(), bounds.size()),
background: Some(layout.background_color),
border: Default::default(),
@ -770,12 +766,12 @@ impl Element<TerminalView> for TerminalElement {
});
for rect in &layout.rects {
rect.paint(scene, origin, layout, view, cx)
rect.paint(origin, layout, view, cx);
}
});
//Draw Highlighted Backgrounds
scene.paint_layer(clip_bounds, |scene| {
cx.paint_layer(clip_bounds, |cx| {
for (relative_highlighted_range, color) in layout.relative_highlighted_ranges.iter()
{
if let Some((start_y, highlighted_range_lines)) =
@ -789,29 +785,29 @@ impl Element<TerminalView> for TerminalElement {
//Copied from editor. TODO: move to theme or something
corner_radius: 0.15 * layout.size.line_height,
};
hr.paint(bounds, scene);
hr.paint(bounds, cx);
}
}
});
//Draw the text cells
scene.paint_layer(clip_bounds, |scene| {
cx.paint_layer(clip_bounds, |cx| {
for cell in &layout.cells {
cell.paint(scene, origin, layout, visible_bounds, view, cx);
cell.paint(origin, layout, visible_bounds, view, cx);
}
});
//Draw cursor
if self.cursor_visible {
if let Some(cursor) = &layout.cursor {
scene.paint_layer(clip_bounds, |scene| {
cursor.paint(scene, origin, cx);
cx.paint_layer(clip_bounds, |cx| {
cursor.paint(origin, cx);
})
}
}
if let Some(element) = &mut layout.hyperlink_tooltip {
element.paint(scene, origin, visible_bounds, view, cx)
element.paint(origin, visible_bounds, view, cx)
}
});
}