Skip to content

Commit f70f863

Browse files
committed
Use appropriate colors instead of CSS filter.
1 parent 679bb17 commit f70f863

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

data/resources/ui/style.css

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
}
1010

1111
.vumeter {
12-
border: 1px solid black;
12+
border: 1px solid var(--border-color);
1313
border-radius: 5px;
14-
filter: saturate(.65) brightness(.95);
15-
background-color: #585858;
14+
background-color: var(--card-bg-color);
1615
}

src/macros.rs

+9
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,12 @@ macro_rules! pwvucontrol_critical {
2929
};
3030
}
3131
pub use pwvucontrol_critical;
32+
33+
34+
#[macro_export]
35+
macro_rules! pwvucontrol_hex_to_rgba {
36+
($r:literal $g:literal $b:literal) => {
37+
gtk::gdk::RGBA::new($r as f32 / 255.0, $g as f32 / 255.0, $b as f32 / 255.0, 1.0 )
38+
};
39+
}
40+
pub use pwvucontrol_hex_to_rgba;

src/ui/peakmeter.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use gtk::{self, prelude::*, subclass::prelude::*};
44
use std::cell::Cell;
55

66
mod imp {
7-
use gtk::{gdk::RGBA, graphene, gsk};
7+
use gtk::{graphene, gsk};
8+
9+
use crate::macros::*;
810

911
use super::*;
1012

@@ -46,6 +48,10 @@ mod imp {
4648
const GREEN_LIMIT: u32 = (0.6 * NUM_BLOCKS as f32) as u32;
4749
const YELLOW_LIMIT: u32 = (0.9 * NUM_BLOCKS as f32) as u32;
4850

51+
let color_green = pwvucontrol_hex_to_rgba!(0x33 0xd1 0x7a);
52+
let color_yellow = pwvucontrol_hex_to_rgba!(0xf6 0xd3 0x2d);
53+
let color_red = pwvucontrol_hex_to_rgba!(0xe0 0x1b 0x24);
54+
4955
let width = self.obj().width() as u32;
5056
let w = self.obj().width() as f32;
5157
let h = self.obj().height() as f32;
@@ -58,7 +64,7 @@ mod imp {
5864
snapshot.push_rounded_clip(&rounded_rect);
5965

6066
if !self.use_led.get() {
61-
snapshot.append_color(&RGBA::GREEN, &graphene::Rect::new(0.0, 0.0, level * w, h));
67+
snapshot.append_color(&color_green, &graphene::Rect::new(0.0, 0.0, level * w, h));
6268
} else {
6369
let discrete_level = (level * NUM_BLOCKS as f32).floor() as u32;
6470
let mut block_width = width / NUM_BLOCKS;
@@ -73,11 +79,11 @@ mod imp {
7379
if extra_space > 0 && i == extra_space {
7480
block_area_width -= 1;
7581
}
76-
82+
7783
let color = match i {
78-
0..GREEN_LIMIT => RGBA::GREEN,
79-
GREEN_LIMIT..YELLOW_LIMIT => RGBA::new(1.0, 1.0, 0.0, 1.0),
80-
_ => RGBA::RED,
84+
0..GREEN_LIMIT => color_green,
85+
GREEN_LIMIT..YELLOW_LIMIT => color_yellow,
86+
_ => color_red,
8187
};
8288
snapshot.append_color(&color, &graphene::Rect::new(block_area_x as f32, 0.0, block_area_width as f32 - 1.0, h));
8389
block_area_x += block_area_width;

0 commit comments

Comments
 (0)