Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic dimming functionality #2751

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
don't dim behind child content
  • Loading branch information
farwyler committed Jul 2, 2022
commit 273e60944b1370d469d90a585613c5725e2a4636
22 changes: 19 additions & 3 deletions helix-term/src/ui/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,27 @@ fn clip_rect_relative(rect: Rect, percent_horizontal: u8, percent_vertical: u8)

impl<T: Component + 'static> Component for Overlay<T> {
fn render(&mut self, area: Rect, frame: &mut Buffer, ctx: &mut Context) {
let dimensions = (self.calc_child_size)(area);
if let Some(shade) = ctx.editor.config().dim.overlay_backdrops {
// TODO: optimise. we don't need to dim behind the child content
frame.dim(area, shade);
frame.dim(area.clip_left(dimensions.right()), shade);
frame.dim(area.with_width(dimensions.left()), shade);
frame.dim(
Rect {
y: 0,
height: dimensions.y,
..dimensions
},
shade,
);
frame.dim(
Rect {
y: dimensions.bottom(),
height: area.height - dimensions.bottom(),
..dimensions
},
shade,
);
}
let dimensions = (self.calc_child_size)(area);
self.content.render(dimensions, frame, ctx)
}

Expand Down