mirror of
https://gitlab.freedesktop.org/pipewire/helvum
synced 2026-03-15 03:26:10 +08:00
graphview: draw background automatically
This removes the manual painting of the background via cairo and adds the correct color to CSS instead, which should hopefully improve performance as we do less cpu painting like this.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
@define-color video rgb(200,200,0);
|
||||
@define-color midi rgb(200,0,50);
|
||||
@define-color graphview-link #808080;
|
||||
@define-color graphview-grid @text_view_bg;
|
||||
|
||||
.audio {
|
||||
background: @audio;
|
||||
@@ -18,3 +17,7 @@
|
||||
background: @midi;
|
||||
color: black;
|
||||
}
|
||||
|
||||
graphview {
|
||||
background: @text_view_bg;
|
||||
}
|
||||
@@ -54,6 +54,7 @@ mod imp {
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
// The layout manager determines how child widgets are laid out.
|
||||
klass.set_layout_manager_type::<gtk::FixedLayout>();
|
||||
klass.set_css_name("graphview");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,24 +124,13 @@ 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(&graphene::Rect::new(
|
||||
0.0,
|
||||
0.0,
|
||||
alloc.width as f32,
|
||||
alloc.height as f32,
|
||||
))
|
||||
.append_cairo(&widget_bounds)
|
||||
.expect("Failed to get cairo context");
|
||||
|
||||
// Try to replace the background color with a darker one from the theme.
|
||||
if let Some(rgba) = widget.style_context().lookup_color("graphview-grid") {
|
||||
background_cr.set_source_rgb(rgba.red.into(), rgba.green.into(), rgba.blue.into());
|
||||
if let Err(e) = background_cr.paint() {
|
||||
warn!("Failed to paint graphview background: {}", e);
|
||||
};
|
||||
} // TODO: else log colour not found
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user