From d853dbb048e8d2b8593a35c9ddd9be02bc714168 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 31 Mar 2021 13:30:07 +0200 Subject: [PATCH] Render borders correctly when only a subset of the border is visible --- gpui/src/platform/mac/shaders/shaders.metal | 14 ++++++++++---- zed/src/workspace/pane.rs | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gpui/src/platform/mac/shaders/shaders.metal b/gpui/src/platform/mac/shaders/shaders.metal index e9f8239541..8d136b7621 100644 --- a/gpui/src/platform/mac/shaders/shaders.metal +++ b/gpui/src/platform/mac/shaders/shaders.metal @@ -81,11 +81,17 @@ fragment float4 quad_fragment( float2 rounded_edge_to_point = abs(center_to_point) - half_size + input.corner_radius; float distance = length(max(0., rounded_edge_to_point)) + min(0., max(rounded_edge_to_point.x, rounded_edge_to_point.y)) - input.corner_radius; - float border_width = 0.; - if (edge_to_point.x > edge_to_point.y) { - border_width = center_to_point.x <= 0. ? input.border_left : input.border_right; + float vertical_border = center_to_point.x <= 0. ? input.border_left : input.border_right; + float horizontal_border = center_to_point.y <= 0. ? input.border_top : input.border_bottom; + float2 inset_size = half_size - input.corner_radius - float2(vertical_border, horizontal_border); + float2 point_to_inset_corner = abs(center_to_point) - inset_size; + float border_width; + if (point_to_inset_corner.x < 0. && point_to_inset_corner.y < 0.) { + border_width = 0.; + } else if (point_to_inset_corner.y > point_to_inset_corner.x) { + border_width = horizontal_border; } else { - border_width = center_to_point.y <= 0. ? input.border_top : input.border_bottom; + border_width = vertical_border; } float4 color; diff --git a/zed/src/workspace/pane.rs b/zed/src/workspace/pane.rs index 22a11be34d..2b248e4505 100644 --- a/zed/src/workspace/pane.rs +++ b/zed/src/workspace/pane.rs @@ -173,7 +173,7 @@ impl Pane { ctx.emit(Event::Split(direction)); } - fn render_tabs<'a>(&self, app: &AppContext) -> ElementBox { + fn render_tabs(&self, app: &AppContext) -> ElementBox { let settings = smol::block_on(self.settings.read()); let border_color = ColorU::from_u32(0xdbdbdcff);