mirror of
https://gitlab.freedesktop.org/pipewire/helvum
synced 2026-03-15 03:26:10 +08:00
graphview: Define link and grid colors in style.css
Previously, these were defined directly in the code, but defining them in the css helps seperating theming and behaviour and makes the colors easier to tweak.
This commit is contained in:
@@ -3,6 +3,7 @@ rust_sources = files(
|
||||
'main.rs',
|
||||
'pipewire_connection.rs',
|
||||
'pipewire_connection/state.rs',
|
||||
'style.css',
|
||||
'view/graph_view.rs',
|
||||
'view/mod.rs',
|
||||
'view/node.rs',
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
@define-color audio rgb(50,100,240);
|
||||
@define-color video rgb(200,200,0);
|
||||
@define-color midi rgb(200,0,50);
|
||||
@define-color graphview-link black;
|
||||
@define-color graphview-grid @text_view_bg;
|
||||
|
||||
.audio {
|
||||
background: rgb(50,100,240);
|
||||
background: @audio;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.video {
|
||||
background: rgb(200,200,0);
|
||||
background: @video;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.midi {
|
||||
background: rgb(200,0,50);
|
||||
background: @midi;
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ mod imp {
|
||||
.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("text_view_bg") {
|
||||
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);
|
||||
@@ -175,8 +175,25 @@ mod imp {
|
||||
alloc.height as f32,
|
||||
))
|
||||
.expect("Failed to get cairo context");
|
||||
|
||||
link_cr.set_line_width(2.0);
|
||||
link_cr.set_source_rgb(0.0, 0.0, 0.0);
|
||||
|
||||
let gtk::gdk::RGBA {
|
||||
red,
|
||||
green,
|
||||
blue,
|
||||
alpha,
|
||||
} = widget
|
||||
.style_context()
|
||||
.lookup_color("graphview-link")
|
||||
.unwrap_or(gtk::gdk::RGBA {
|
||||
red: 0.0,
|
||||
green: 0.0,
|
||||
blue: 0.0,
|
||||
alpha: 0.0,
|
||||
});
|
||||
link_cr.set_source_rgba(red.into(), green.into(), blue.into(), alpha.into());
|
||||
|
||||
for (link, active) in self.links.borrow().values() {
|
||||
if let Some((from_x, from_y, to_x, to_y)) = self.get_link_coordinates(link) {
|
||||
link_cr.move_to(from_x, from_y);
|
||||
|
||||
Reference in New Issue
Block a user