mirror of
https://gitlab.freedesktop.org/pipewire/helvum.git
synced 2025-12-28 21:00:06 +01: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:
parent
2cfc8e2e6f
commit
82a3e4f900
2 changed files with 8 additions and 15 deletions
|
|
@ -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;
|
||||
|
|
@ -17,4 +16,8 @@
|
|||
.midi {
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue