Skip to content

Commit 228eb4d

Browse files
committed
Only override icon button colors when it is disabled
1 parent 973018f commit 228eb4d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/theme/style/button.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub fn appearance(
4141
theme: &crate::Theme,
4242
focused: bool,
4343
selected: bool,
44+
disabled: bool,
4445
style: &Button,
4546
color: impl Fn(&Component) -> (Color, Option<Color>, Option<Color>),
4647
) -> Appearance {
@@ -83,8 +84,9 @@ pub fn appearance(
8384

8485
let (background, text, icon) = color(&cosmic.icon_button);
8586
appearance.background = Some(Background::Color(background));
86-
appearance.text_color = text;
87-
appearance.icon_color = icon;
87+
// Only override icon button colors when it is disabled
88+
appearance.icon_color = if disabled { icon } else { None };
89+
appearance.text_color = if disabled { text } else { None };
8890
}
8991

9092
Button::Image => {
@@ -169,7 +171,7 @@ impl StyleSheet for crate::Theme {
169171
return active(focused, self);
170172
}
171173

172-
appearance(self, focused, selected, style, move |component| {
174+
appearance(self, focused, selected, false, style, move |component| {
173175
let text_color = if matches!(
174176
style,
175177
Button::Icon | Button::IconVertical | Button::HeaderBar
@@ -189,7 +191,7 @@ impl StyleSheet for crate::Theme {
189191
return disabled(self);
190192
}
191193

192-
appearance(self, false, false, style, |component| {
194+
appearance(self, false, false, true, style, |component| {
193195
let mut background = Color::from(component.base);
194196
background.a *= 0.5;
195197
(
@@ -213,6 +215,7 @@ impl StyleSheet for crate::Theme {
213215
self,
214216
focused || matches!(style, Button::Image),
215217
selected,
218+
false,
216219
style,
217220
|component| {
218221
let text_color = if matches!(
@@ -235,7 +238,7 @@ impl StyleSheet for crate::Theme {
235238
return pressed(focused, self);
236239
}
237240

238-
appearance(self, focused, selected, style, |component| {
241+
appearance(self, focused, selected, false, style, |component| {
239242
let text_color = if matches!(
240243
style,
241244
Button::Icon | Button::IconVertical | Button::HeaderBar

0 commit comments

Comments
 (0)