From 7c324004312d98c355234b6201a6b9930dd98090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Valenzuela=20Dur=C3=A1n?= Date: Sat, 5 Mar 2022 01:28:03 +0100 Subject: Base+LibGUI+LibGfx: Improve disabled text readability Currently, disabled text colors are hardcoded. They look good in Default and light themes, but no so good in dark ones. This PR adds new variables for all themes to correctly display disabled text. --- Base/res/themes/Basalt.ini | 2 ++ Base/res/themes/Coffee.ini | 2 ++ Base/res/themes/Cupertino.ini | 2 ++ Base/res/themes/Dark.ini | 2 ++ Base/res/themes/Default.ini | 2 ++ Base/res/themes/Desert.ini | 2 ++ Base/res/themes/Faux Pas.ini | 2 ++ Base/res/themes/Gruvbox Dark.ini | 2 ++ Base/res/themes/Light.ini | 2 ++ Base/res/themes/Nord.ini | 2 ++ Base/res/themes/Olive.ini | 2 ++ Base/res/themes/Plum.ini | 2 ++ Base/res/themes/Pumpkin.ini | 2 ++ Base/res/themes/Redmond 2000.ini | 2 ++ Base/res/themes/Redmond.ini | 2 ++ Base/res/themes/Scarlett.ini | 2 ++ Base/res/themes/Silver.ini | 2 ++ Base/res/themes/Sunshine.ini | 2 ++ Userland/Libraries/LibGUI/AbstractButton.cpp | 4 ++-- Userland/Libraries/LibGUI/Label.cpp | 4 ++-- Userland/Libraries/LibGfx/Palette.h | 2 ++ Userland/Libraries/LibGfx/SystemTheme.h | 2 ++ 22 files changed, 44 insertions(+), 4 deletions(-) diff --git a/Base/res/themes/Basalt.ini b/Base/res/themes/Basalt.ini index 2f21743ba0..af951f8eac 100644 --- a/Base/res/themes/Basalt.ini +++ b/Base/res/themes/Basalt.ini @@ -34,6 +34,8 @@ Button=#1f1f1f ButtonText=white Base=#1f1f1f BaseText=white +DisabledTextFront=#4f4f4f +DisabledTextBack=#000000 ThreedHighlight=#2f2f2f ThreedShadow1=#171717 ThreedShadow2=#0f0f0f diff --git a/Base/res/themes/Coffee.ini b/Base/res/themes/Coffee.ini index 5bad31b49f..d2025bb47e 100644 --- a/Base/res/themes/Coffee.ini +++ b/Base/res/themes/Coffee.ini @@ -30,6 +30,8 @@ Button=#e6e6e6 ButtonText=black Base=white BaseText=black +DisabledTextFront=#808080 +DisabledTextBack=white ThreedHighlight=white ThreedShadow1=#9397a5 ThreedShadow2=#5d6069 diff --git a/Base/res/themes/Cupertino.ini b/Base/res/themes/Cupertino.ini index bb6dc1c7d4..6f0aadf84c 100644 --- a/Base/res/themes/Cupertino.ini +++ b/Base/res/themes/Cupertino.ini @@ -31,6 +31,8 @@ Button=#212121 ButtonText=#fcfcfc Base=#292929 BaseText=#fcfcfc +DisabledTextFront=#606060 +DisabledTextBack=#000000 ThreedHighlight=#363636 ThreedShadow1=#363636 ThreedShadow2=#363636 diff --git a/Base/res/themes/Dark.ini b/Base/res/themes/Dark.ini index c936a1fbac..66373eeba7 100644 --- a/Base/res/themes/Dark.ini +++ b/Base/res/themes/Dark.ini @@ -26,6 +26,8 @@ Button=#555555 ButtonText=white Base=#424242 BaseText=white +DisabledTextFront=#a0a0a0 +DisabledTextBack=#14141a ThreedHighlight=#6f6f6f ThreedShadow1=#3d3e40 ThreedShadow2=#2e2f30 diff --git a/Base/res/themes/Default.ini b/Base/res/themes/Default.ini index 6a637a73ef..39e137e046 100644 --- a/Base/res/themes/Default.ini +++ b/Base/res/themes/Default.ini @@ -34,6 +34,8 @@ Button=#d4d0c8 ButtonText=black Base=white BaseText=black +DisabledTextFront=#808080 +DisabledTextBack=white ThreedHighlight=white ThreedShadow1=#808080 ThreedShadow2=#404040 diff --git a/Base/res/themes/Desert.ini b/Base/res/themes/Desert.ini index e91fcfb03f..2169bd60c2 100644 --- a/Base/res/themes/Desert.ini +++ b/Base/res/themes/Desert.ini @@ -34,6 +34,8 @@ Button=#d5ccbb ButtonText=black Base=white BaseText=black +DisabledTextFront=#808080 +DisabledTextBack=#e1e8e0 ThreedHighlight=#eae6dd ThreedShadow1=#a28d68 ThreedShadow2=#000000 diff --git a/Base/res/themes/Faux Pas.ini b/Base/res/themes/Faux Pas.ini index ae210e0a60..1700ca4e7e 100644 --- a/Base/res/themes/Faux Pas.ini +++ b/Base/res/themes/Faux Pas.ini @@ -26,6 +26,8 @@ Button=#a0a0a0 ButtonText=black Base=#a0a0a0 BaseText=black +DisabledTextFront=#707070 +DisabledTextBack=white ThreedHighlight=white ThreedShadow1=#282828 ThreedShadow2=#282828 diff --git a/Base/res/themes/Gruvbox Dark.ini b/Base/res/themes/Gruvbox Dark.ini index a78e17ab48..6054974c72 100644 --- a/Base/res/themes/Gruvbox Dark.ini +++ b/Base/res/themes/Gruvbox Dark.ini @@ -26,6 +26,8 @@ Button=#32302f ButtonText=#ebdbb2 Base=#3c3836 BaseText=#ebdbb2 +DisabledTextFront=#665c54 +DisabledTextBack=#1d2021 ThreedHighlight=#504945 ThreedShadow1=#282828 ThreedShadow2=#1d2021 diff --git a/Base/res/themes/Light.ini b/Base/res/themes/Light.ini index cfd9ec4a55..e2e39d4bd8 100644 --- a/Base/res/themes/Light.ini +++ b/Base/res/themes/Light.ini @@ -34,6 +34,8 @@ Button=#e3e3e3 ButtonText=#4b4b4b Base=white BaseText=#4b4b4b +DisabledTextFront=#ababab +DisabledTextBack=white ThreedHighlight=#e3e3e3 ThreedShadow1=#ababab ThreedShadow2=#6b6b6b diff --git a/Base/res/themes/Nord.ini b/Base/res/themes/Nord.ini index 9279f421af..7271c58a82 100644 --- a/Base/res/themes/Nord.ini +++ b/Base/res/themes/Nord.ini @@ -26,6 +26,8 @@ Button=#434c5e ButtonText=white Base=#4c566a BaseText=white +DisabledTextFront=#95adc5 +DisabledTextBack=#2e3440 ThreedHighlight=#4c566a ThreedShadow1=#3b4252 ThreedShadow2=#2e3440 diff --git a/Base/res/themes/Olive.ini b/Base/res/themes/Olive.ini index 3c4ee8353f..c8edc6ed10 100644 --- a/Base/res/themes/Olive.ini +++ b/Base/res/themes/Olive.ini @@ -36,6 +36,8 @@ Button=#c1cbb5ff MenuSelectionText=#000000ff SelectionText=#ffffffff BaseText=#000000ff +DisabledTextFront=#747d74ff +DisabledTextBack=#e3ffb9ff SyntaxPreprocessorStatement=#00a0a0ff Accent=#619910ff Base=#ffffffff diff --git a/Base/res/themes/Plum.ini b/Base/res/themes/Plum.ini index 3a67f69228..b29a5afe00 100644 --- a/Base/res/themes/Plum.ini +++ b/Base/res/themes/Plum.ini @@ -34,6 +34,8 @@ Button=#a89890 ButtonText=black Base=#d8d0c8 BaseText=black +DisabledTextFront=#808080 +DisabledTextBack=#d8d0c8 ThreedHighlight=#d8d0c8 ThreedShadow1=#786058 ThreedShadow2=#201a18 diff --git a/Base/res/themes/Pumpkin.ini b/Base/res/themes/Pumpkin.ini index 4a10a54ded..f608972707 100644 --- a/Base/res/themes/Pumpkin.ini +++ b/Base/res/themes/Pumpkin.ini @@ -36,6 +36,8 @@ Button=#c7c2b0ff MenuSelectionText=#f3f3f3ff SelectionText=#ffffffff BaseText=#000000ff +DisabledTextFront=#808080 +DisabledTextBack=#e4d6beff SyntaxPreprocessorStatement=#00a0a0ff Accent=#6f517bff Base=#ffffffff diff --git a/Base/res/themes/Redmond 2000.ini b/Base/res/themes/Redmond 2000.ini index 1cc8f12a6b..02b5cc31da 100644 --- a/Base/res/themes/Redmond 2000.ini +++ b/Base/res/themes/Redmond 2000.ini @@ -30,6 +30,8 @@ Button=#d4d0c8 ButtonText=black Base=white BaseText=black +DisabledTextFront=#808080 +DisabledTextBack=white ThreedHighlight=white ThreedShadow1=#808080 ThreedShadow2=#404040 diff --git a/Base/res/themes/Redmond.ini b/Base/res/themes/Redmond.ini index 22f6279da1..551b702e33 100644 --- a/Base/res/themes/Redmond.ini +++ b/Base/res/themes/Redmond.ini @@ -30,6 +30,8 @@ Button=#bfb8bf ButtonText=black Base=white BaseText=black +DisabledTextFront=#7f787f +DisabledTextBack=#fff8ff ThreedHighlight=#fff8ff ThreedShadow1=#7f787f ThreedShadow2=#000000 diff --git a/Base/res/themes/Scarlett.ini b/Base/res/themes/Scarlett.ini index 911f13a130..23bdba3f75 100644 --- a/Base/res/themes/Scarlett.ini +++ b/Base/res/themes/Scarlett.ini @@ -39,6 +39,8 @@ BaseText=#000000ff SyntaxPreprocessorStatement=#00a0a0ff Accent=#970e0eff Base=#ffffffff +DisabledTextFront=#808080ff +DisabledTextBack=#ffe1e1ff InactiveWindowTitle=#d5c7c7ff HighlightWindowTitle=#ffffffff MovingWindowTitleShadow=#601e07ff diff --git a/Base/res/themes/Silver.ini b/Base/res/themes/Silver.ini index 6a02a554b4..a61e4288a1 100644 --- a/Base/res/themes/Silver.ini +++ b/Base/res/themes/Silver.ini @@ -42,6 +42,8 @@ BaseText=#000000ff SyntaxPreprocessorStatement=#008080ff Accent=#63639cff Base=#f3f3f3ff +DisabledTextFront=#808080ff +DisabledTextBack=white InactiveWindowTitle=#696969ff HighlightWindowTitle=#000000ff MovingWindowTitleShadow=#000000ff diff --git a/Base/res/themes/Sunshine.ini b/Base/res/themes/Sunshine.ini index 60bec13595..180bc0fee5 100644 --- a/Base/res/themes/Sunshine.ini +++ b/Base/res/themes/Sunshine.ini @@ -30,6 +30,8 @@ Button=#aeb2c3 ButtonText=black Base=white BaseText=black +DisabledTextFront=#9397a5 +DisabledTextBack=white ThreedHighlight=white ThreedShadow1=#9397a5 ThreedShadow2=#5d6069 diff --git a/Userland/Libraries/LibGUI/AbstractButton.cpp b/Userland/Libraries/LibGUI/AbstractButton.cpp index 3e1c58e96f..2a682f30ab 100644 --- a/Userland/Libraries/LibGUI/AbstractButton.cpp +++ b/Userland/Libraries/LibGUI/AbstractButton.cpp @@ -226,8 +226,8 @@ void AbstractButton::paint_text(Painter& painter, const Gfx::IntRect& rect, cons auto clipped_rect = rect.intersected(this->rect()); if (!is_enabled()) { - painter.draw_text(clipped_rect.translated(1, 1), text(), font, text_alignment, Color::White, Gfx::TextElision::Right, text_wrapping); - painter.draw_text(clipped_rect, text(), font, text_alignment, Color::from_rgb(0x808080), Gfx::TextElision::Right, text_wrapping); + painter.draw_text(clipped_rect.translated(1, 1), text(), font, text_alignment, palette().disabled_text_back(), Gfx::TextElision::Right, text_wrapping); + painter.draw_text(clipped_rect, text(), font, text_alignment, palette().disabled_text_front(), Gfx::TextElision::Right, text_wrapping); return; } diff --git a/Userland/Libraries/LibGUI/Label.cpp b/Userland/Libraries/LibGUI/Label.cpp index 77e72f3dae..e7a0ee254d 100644 --- a/Userland/Libraries/LibGUI/Label.cpp +++ b/Userland/Libraries/LibGUI/Label.cpp @@ -104,8 +104,8 @@ void Label::paint_event(PaintEvent& event) if (is_enabled()) { painter.draw_text(text_rect, text(), text_alignment(), palette().color(foreground_role()), Gfx::TextElision::Right, text_wrapping()); } else { - painter.draw_text(text_rect.translated(1, 1), text(), font(), text_alignment(), Color::White, Gfx::TextElision::Right, text_wrapping()); - painter.draw_text(text_rect, text(), font(), text_alignment(), Color::from_rgb(0x808080), Gfx::TextElision::Right, text_wrapping()); + painter.draw_text(text_rect.translated(1, 1), text(), font(), text_alignment(), palette().disabled_text_back(), Gfx::TextElision::Right, text_wrapping()); + painter.draw_text(text_rect, text(), font(), text_alignment(), palette().disabled_text_front(), Gfx::TextElision::Right, text_wrapping()); } } diff --git a/Userland/Libraries/LibGfx/Palette.h b/Userland/Libraries/LibGfx/Palette.h index d6d5d9cef3..365e8cc2e0 100644 --- a/Userland/Libraries/LibGfx/Palette.h +++ b/Userland/Libraries/LibGfx/Palette.h @@ -99,6 +99,8 @@ public: Color menu_selection_text() const { return color(ColorRole::MenuSelectionText); } Color base() const { return color(ColorRole::Base); } Color base_text() const { return color(ColorRole::BaseText); } + Color disabled_text_front() const { return color(ColorRole::DisabledTextFront); } + Color disabled_text_back() const { return color(ColorRole::DisabledTextBack); } Color button() const { return color(ColorRole::Button); } Color button_text() const { return color(ColorRole::ButtonText); } Color threed_highlight() const { return color(ColorRole::ThreedHighlight); } diff --git a/Userland/Libraries/LibGfx/SystemTheme.h b/Userland/Libraries/LibGfx/SystemTheme.h index 30b15b4279..769760c6dd 100644 --- a/Userland/Libraries/LibGfx/SystemTheme.h +++ b/Userland/Libraries/LibGfx/SystemTheme.h @@ -30,6 +30,8 @@ namespace Gfx { C(BaseText) \ C(Button) \ C(ButtonText) \ + C(DisabledTextFront) \ + C(DisabledTextBack) \ C(DesktopBackground) \ C(FocusOutline) \ C(Gutter) \ -- cgit v1.2.3