Uncomment git gutter painting
This commit is contained in:
parent
1abc876c15
commit
f0bc4a04bd
2 changed files with 81 additions and 68 deletions
|
@ -19,6 +19,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use collections::{BTreeMap, HashMap};
|
use collections::{BTreeMap, HashMap};
|
||||||
|
use git::diff::DiffHunkStatus;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, point, px, relative, size, transparent_black, Action, AnyElement, AsyncWindowContext,
|
div, point, px, relative, size, transparent_black, Action, AnyElement, AsyncWindowContext,
|
||||||
AvailableSpace, BorrowWindow, Bounds, ContentMask, Corners, DispatchPhase, Edges, Element,
|
AvailableSpace, BorrowWindow, Bounds, ContentMask, Corners, DispatchPhase, Edges, Element,
|
||||||
|
@ -723,87 +724,85 @@ impl EditorElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint_diff_hunks(bounds: Bounds<Pixels>, layout: &LayoutState, cx: &mut WindowContext) {
|
fn paint_diff_hunks(bounds: Bounds<Pixels>, layout: &LayoutState, cx: &mut WindowContext) {
|
||||||
// todo!()
|
let line_height = layout.position_map.line_height;
|
||||||
// let diff_style = &theme::current(cx).editor.diff.clone();
|
|
||||||
// let line_height = layout.position_map.line_height;
|
|
||||||
|
|
||||||
// let scroll_position = layout.position_map.snapshot.scroll_position();
|
let scroll_position = layout.position_map.snapshot.scroll_position();
|
||||||
// let scroll_top = scroll_position.y * line_height;
|
let scroll_top = scroll_position.y * line_height;
|
||||||
|
|
||||||
// for hunk in &layout.display_hunks {
|
for hunk in &layout.display_hunks {
|
||||||
// let (display_row_range, status) = match hunk {
|
let (display_row_range, status) = match hunk {
|
||||||
// //TODO: This rendering is entirely a horrible hack
|
//TODO: This rendering is entirely a horrible hack
|
||||||
// &DisplayDiffHunk::Folded { display_row: row } => {
|
&DisplayDiffHunk::Folded { display_row: row } => {
|
||||||
// let start_y = row as f32 * line_height - scroll_top;
|
let start_y = row as f32 * line_height - scroll_top;
|
||||||
// let end_y = start_y + line_height;
|
let end_y = start_y + line_height;
|
||||||
|
|
||||||
// let width = diff_style.removed_width_em * line_height;
|
let width = 0.275 * line_height;
|
||||||
// let highlight_origin = bounds.origin + point(-width, start_y);
|
let highlight_origin = bounds.origin + point(-width, start_y);
|
||||||
// let highlight_size = point(width * 2., end_y - start_y);
|
let highlight_size = size(width * 2., end_y - start_y);
|
||||||
// let highlight_bounds = Bounds::<Pixels>::new(highlight_origin, highlight_size);
|
let highlight_bounds = Bounds::new(highlight_origin, highlight_size);
|
||||||
|
cx.paint_quad(
|
||||||
|
highlight_bounds,
|
||||||
|
Corners::all(1. * line_height),
|
||||||
|
gpui::yellow(), // todo!("use the right color")
|
||||||
|
Edges::default(),
|
||||||
|
transparent_black(),
|
||||||
|
);
|
||||||
|
|
||||||
// cx.paint_quad(Quad {
|
continue;
|
||||||
// bounds: highlight_bounds,
|
}
|
||||||
// background: Some(diff_style.modified),
|
|
||||||
// border: Border::new(0., Color::transparent_black()).into(),
|
|
||||||
// corner_radii: (1. * line_height).into(),
|
|
||||||
// });
|
|
||||||
|
|
||||||
// continue;
|
DisplayDiffHunk::Unfolded {
|
||||||
// }
|
display_row_range,
|
||||||
|
status,
|
||||||
|
} => (display_row_range, status),
|
||||||
|
};
|
||||||
|
|
||||||
// DisplayDiffHunk::Unfolded {
|
let color = match status {
|
||||||
// display_row_range,
|
DiffHunkStatus::Added => gpui::green(), // todo!("use the appropriate color")
|
||||||
// status,
|
DiffHunkStatus::Modified => gpui::yellow(), // todo!("use the appropriate color")
|
||||||
// } => (display_row_range, status),
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let color = match status {
|
//TODO: This rendering is entirely a horrible hack
|
||||||
// DiffHunkStatus::Added => diff_style.inserted,
|
DiffHunkStatus::Removed => {
|
||||||
// DiffHunkStatus::Modified => diff_style.modified,
|
let row = display_row_range.start;
|
||||||
|
|
||||||
// //TODO: This rendering is entirely a horrible hack
|
let offset = line_height / 2.;
|
||||||
// DiffHunkStatus::Removed => {
|
let start_y = row as f32 * line_height - offset - scroll_top;
|
||||||
// let row = display_row_range.start;
|
let end_y = start_y + line_height;
|
||||||
|
|
||||||
// let offset = line_height / 2.;
|
let width = 0.275 * line_height;
|
||||||
// let start_y = row as f32 * line_height - offset - scroll_top;
|
let highlight_origin = bounds.origin + point(-width, start_y);
|
||||||
// let end_y = start_y + line_height;
|
let highlight_size = size(width * 2., end_y - start_y);
|
||||||
|
let highlight_bounds = Bounds::new(highlight_origin, highlight_size);
|
||||||
|
cx.paint_quad(
|
||||||
|
highlight_bounds,
|
||||||
|
Corners::all(1. * line_height),
|
||||||
|
gpui::red(), // todo!("use the right color")
|
||||||
|
Edges::default(),
|
||||||
|
transparent_black(),
|
||||||
|
);
|
||||||
|
|
||||||
// let width = diff_style.removed_width_em * line_height;
|
continue;
|
||||||
// let highlight_origin = bounds.origin + point(-width, start_y);
|
}
|
||||||
// let highlight_size = point(width * 2., end_y - start_y);
|
};
|
||||||
// let highlight_bounds = Bounds::<Pixels>::new(highlight_origin, highlight_size);
|
|
||||||
|
|
||||||
// cx.paint_quad(Quad {
|
let start_row = display_row_range.start;
|
||||||
// bounds: highlight_bounds,
|
let end_row = display_row_range.end;
|
||||||
// background: Some(diff_style.deleted),
|
|
||||||
// border: Border::new(0., Color::transparent_black()).into(),
|
|
||||||
// corner_radii: (1. * line_height).into(),
|
|
||||||
// });
|
|
||||||
|
|
||||||
// continue;
|
let start_y = start_row as f32 * line_height - scroll_top;
|
||||||
// }
|
let end_y = end_row as f32 * line_height - scroll_top;
|
||||||
// };
|
|
||||||
|
|
||||||
// let start_row = display_row_range.start;
|
let width = 0.275 * line_height;
|
||||||
// let end_row = display_row_range.end;
|
let highlight_origin = bounds.origin + point(-width, start_y);
|
||||||
|
let highlight_size = size(width * 2., end_y - start_y);
|
||||||
// let start_y = start_row as f32 * line_height - scroll_top;
|
let highlight_bounds = Bounds::new(highlight_origin, highlight_size);
|
||||||
// let end_y = end_row as f32 * line_height - scroll_top;
|
cx.paint_quad(
|
||||||
|
highlight_bounds,
|
||||||
// let width = diff_style.width_em * line_height;
|
Corners::all(0.05 * line_height),
|
||||||
// let highlight_origin = bounds.origin + point(-width, start_y);
|
color, // todo!("use the right color")
|
||||||
// let highlight_size = point(width * 2., end_y - start_y);
|
Edges::default(),
|
||||||
// let highlight_bounds = Bounds::<Pixels>::new(highlight_origin, highlight_size);
|
transparent_black(),
|
||||||
|
);
|
||||||
// cx.paint_quad(Quad {
|
}
|
||||||
// bounds: highlight_bounds,
|
|
||||||
// background: Some(color),
|
|
||||||
// border: Border::new(0., Color::transparent_black()).into(),
|
|
||||||
// corner_radii: (diff_style.corner_radius * line_height).into(),
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint_text(
|
fn paint_text(
|
||||||
|
|
|
@ -655,6 +655,20 @@ pub struct Corners<T: Clone + Default + Debug> {
|
||||||
pub bottom_left: T,
|
pub bottom_left: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Corners<T>
|
||||||
|
where
|
||||||
|
T: Clone + Default + Debug,
|
||||||
|
{
|
||||||
|
pub fn all(value: T) -> Self {
|
||||||
|
Self {
|
||||||
|
top_left: value.clone(),
|
||||||
|
top_right: value.clone(),
|
||||||
|
bottom_right: value.clone(),
|
||||||
|
bottom_left: value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Corners<AbsoluteLength> {
|
impl Corners<AbsoluteLength> {
|
||||||
pub fn to_pixels(&self, size: Size<Pixels>, rem_size: Pixels) -> Corners<Pixels> {
|
pub fn to_pixels(&self, size: Size<Pixels>, rem_size: Pixels) -> Corners<Pixels> {
|
||||||
let max = size.width.max(size.height) / 2.;
|
let max = size.width.max(size.height) / 2.;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue