Skip to content

Commit 620c1a7

Browse files
committed
refactor(stack): use const variables for overlay colors
1 parent b2acace commit 620c1a7

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

src/shell/element/stack/tab_text.rs

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,34 @@ use cosmic::{
1515

1616
use super::tab::Model;
1717

18+
const OVERLAY_DARK: Color = Color {
19+
a: 1.0,
20+
r: 0.149,
21+
g: 0.149,
22+
b: 0.149,
23+
};
24+
25+
const OVERLAY_DARK_SELECTED: Color = Color {
26+
a: 1.0,
27+
r: 0.196,
28+
g: 0.196,
29+
b: 0.196,
30+
};
31+
32+
const OVERLAY_LIGHT: Color = Color {
33+
a: 1.0,
34+
r: 0.894,
35+
g: 0.894,
36+
b: 0.894,
37+
};
38+
39+
const OVERLAY_LIGHT_SELECTED: Color = Color {
40+
a: 1.0,
41+
r: 0.831,
42+
g: 0.831,
43+
b: 0.831,
44+
};
45+
1846
/// Text in a stack tab with an overflow gradient.
1947
pub fn tab_text(model: &Model, selected: bool) -> TabText {
2048
TabText::new(model, selected)
@@ -152,30 +180,10 @@ impl<'a, Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabText<'
152180
renderer.with_layer(bounds, |renderer| {
153181
if state.overflowed {
154182
let overlay = match (theme.cosmic().is_dark, self.selected) {
155-
(true, false) => Color {
156-
a: 1.0,
157-
r: 0.149,
158-
g: 0.149,
159-
b: 0.149,
160-
},
161-
(true, true) => Color {
162-
a: 1.0,
163-
r: 0.196,
164-
g: 0.196,
165-
b: 0.196,
166-
},
167-
(false, false) => Color {
168-
a: 1.0,
169-
r: 0.894,
170-
g: 0.894,
171-
b: 0.894,
172-
},
173-
(false, true) => Color {
174-
a: 1.0,
175-
r: 0.831,
176-
g: 0.831,
177-
b: 0.831,
178-
},
183+
(true, false) => OVERLAY_DARK,
184+
(true, true) => OVERLAY_DARK_SELECTED,
185+
(false, false) => OVERLAY_LIGHT,
186+
(false, true) => OVERLAY_LIGHT_SELECTED,
179187
};
180188

181189
let transparent = Color { a: 0.0, ..overlay };

0 commit comments

Comments
 (0)