This commit is contained in:
Antonio Scandurra 2022-09-08 19:07:11 +02:00
parent c03300df29
commit 2b9fe0a2e6
8 changed files with 89 additions and 51 deletions

View file

@ -116,15 +116,25 @@ impl gpui::View for ScreenCaptureView {
fn render(&mut self, _: &mut gpui::RenderContext<Self>) -> gpui::ElementBox {
let image_buffer = self.image_buffer.clone();
Canvas::new(move |bounds, _, cx| {
let canvas = Canvas::new(move |bounds, _, cx| {
if let Some(image_buffer) = image_buffer.clone() {
cx.scene.push_surface(Surface {
bounds,
image_buffer,
});
}
})
.boxed()
});
if let Some(image_buffer) = self.image_buffer.as_ref() {
canvas
.constrained()
.with_width(image_buffer.width() as f32)
.with_height(image_buffer.height() as f32)
.aligned()
.boxed()
} else {
canvas.boxed()
}
}
}