@@ -4,7 +4,9 @@ use gtk::{self, prelude::*, subclass::prelude::*};
4
4
use std:: cell:: Cell ;
5
5
6
6
mod imp {
7
- use gtk:: { gdk:: RGBA , graphene, gsk} ;
7
+ use gtk:: { graphene, gsk} ;
8
+
9
+ use crate :: macros:: * ;
8
10
9
11
use super :: * ;
10
12
@@ -46,6 +48,10 @@ mod imp {
46
48
const GREEN_LIMIT : u32 = ( 0.6 * NUM_BLOCKS as f32 ) as u32 ;
47
49
const YELLOW_LIMIT : u32 = ( 0.9 * NUM_BLOCKS as f32 ) as u32 ;
48
50
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
+
49
55
let width = self . obj ( ) . width ( ) as u32 ;
50
56
let w = self . obj ( ) . width ( ) as f32 ;
51
57
let h = self . obj ( ) . height ( ) as f32 ;
@@ -58,7 +64,7 @@ mod imp {
58
64
snapshot. push_rounded_clip ( & rounded_rect) ;
59
65
60
66
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) ) ;
62
68
} else {
63
69
let discrete_level = ( level * NUM_BLOCKS as f32 ) . floor ( ) as u32 ;
64
70
let mut block_width = width / NUM_BLOCKS ;
@@ -73,11 +79,11 @@ mod imp {
73
79
if extra_space > 0 && i == extra_space {
74
80
block_area_width -= 1 ;
75
81
}
76
-
82
+
77
83
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 ,
81
87
} ;
82
88
snapshot. append_color ( & color, & graphene:: Rect :: new ( block_area_x as f32 , 0.0 , block_area_width as f32 - 1.0 , h) ) ;
83
89
block_area_x += block_area_width;
0 commit comments