graphview: draw the background grid via CSS instead of manually with cairo

This makes gtk draw the background grid for us via CSS, instead of manually drawing each line via cairo.

This improves performance, as the grid may now be drawn via GPU, and gets rid of the custom drawing code we had.
This commit is contained in:
Tom A. Wagner
2022-05-03 14:04:54 +02:00
parent 52e48cc0a7
commit df72a68815
2 changed files with 5 additions and 24 deletions

View File

@@ -115,29 +115,6 @@ mod imp {
Try to use relative units (em) and colours from the theme as much as possible. */
let alloc = widget.allocation();
let widget_bounds =
graphene::Rect::new(0.0, 0.0, alloc.width() as f32, alloc.height() as f32);
let background_cr = snapshot.append_cairo(&widget_bounds);
// Draw a nice grid on the background.
background_cr.set_source_rgb(0.18, 0.18, 0.18);
background_cr.set_line_width(0.2); // TODO: Set to 1px
let mut y = 0.0;
while y < alloc.height().into() {
background_cr.move_to(0.0, y);
background_cr.line_to(alloc.width().into(), y);
y += 20.0; // TODO: Change to em;
}
let mut x = 0.0;
while x < alloc.width().into() {
background_cr.move_to(x, 0.0);
background_cr.line_to(x, alloc.height().into());
x += 20.0; // TODO: Change to em;
}
if let Err(e) = background_cr.stroke() {
warn!("Failed to draw graphview grid: {}", e);
};
// Draw all children
self.nodes