Просмотр исходного кода

LibDraw: Add MenuBaseText and MenuSelectionText color roles

This allows the very aesthetic "Hotdog Stand" theme to have quite
reasonable looking menus.
Andreas Kling 5 лет назад
Родитель
Сommit
5be6a43860

+ 2 - 9
Base/res/themes/Dark.ini

@@ -1,38 +1,31 @@
 [Colors]
 DesktopBackground=#202020
-
 ActiveWindowBorder1=#3d3d4f
 ActiveWindowBorder2=#b7b7da
 ActiveWindowTitle=white
-
 InactiveWindowBorder1=#606060
 InactiveWindowBorder2=#a0a0a0
 InactiveWindowTitle=#d5d0c7
-
 MovingWindowBorder1=#49496c
 MovingWindowBorder2=#9c9cd5
 MovingWindowTitle=white
-
 HighlightWindowBorder1=#a10d0d
 HighlightWindowBorder2=#fabbbb
 HighlightWindowTitle=white
-
 MenuBase=#444444
+MenuBaseText=white
 MenuStripe=#323232
 MenuSelection=#666666
-
+MenuSelectionText=white
 Window=#323232
 WindowText=white
 Button=#555555
 ButtonText=white
 Base=#424242
 BaseText=white
-
 ThreedHighlight=#6f6f6f
 ThreedShadow1=#3d3e40
 ThreedShadow2=#2e2f30
-
 HoverHighlight=#696969
-
 Selection=#14141a
 SelectionText=white

+ 2 - 10
Base/res/themes/Default.ini

@@ -1,39 +1,31 @@
 [Colors]
 DesktopBackground=#404040
-
 ActiveWindowBorder1=#6e2209
 ActiveWindowBorder2=#f4ca9e
 ActiveWindowTitle=white
-
 InactiveWindowBorder1=#808080
 InactiveWindowBorder2=#c0c0c0
 InactiveWindowTitle=#d5d0c7
-
 MovingWindowBorder1=#a1320d
 MovingWindowBorder2=#fadcbb
 MovingWindowTitle=white
-
 HighlightWindowBorder1=#a10d0d
 HighlightWindowBorder2=#fabbbb
 HighlightWindowTitle=white
-
 MenuBase=white
+MenuBaseText=black
 MenuStripe=#bbb7b0
 MenuSelection=#ad714f
-
+MenuSelectionText=white
 Window=#d4d0c8
 WindowText=black
 Button=#d4d0c8
 ButtonText=black
-
 Base=white
 BaseText=black
-
 ThreedHighlight=white
 ThreedShadow1=#808080
 ThreedShadow2=#404040
-
 HoverHighlight=#e3dfdb
-
 Selection=#84351a
 SelectionText=white

+ 2 - 10
Base/res/themes/Hotdog Stand.ini

@@ -1,39 +1,31 @@
 [Colors]
 DesktopBackground=yellow
-
 ActiveWindowBorder1=black
 ActiveWindowBorder2=black
 ActiveWindowTitle=white
-
 InactiveWindowBorder1=red
 InactiveWindowBorder2=red
 InactiveWindowTitle=white
-
 MovingWindowBorder1=black
 MovingWindowBorder2=black
 MovingWindowTitle=white
-
 HighlightWindowBorder1=black
 HighlightWindowBorder2=black
 HighlightWindowTitle=white
-
 MenuBase=white
+MenuBaseText=black
 MenuStripe=red
 MenuSelection=#550000
-
+MenuSelectionText=white
 Window=red
 WindowText=white
 Button=#c0c0c0
 ButtonText=black
-
 Base=red
 BaseText=white
-
 ThreedHighlight=#a0a0a0
 ThreedShadow1=#b0b0b0
 ThreedShadow2=#909090
-
 HoverHighlight=white
-
 Selection=black
 SelectionText=white

+ 2 - 10
Base/res/themes/Xmas.ini

@@ -1,39 +1,31 @@
 [Colors]
 DesktopBackground=#313819
-
 ActiveWindowBorder1=#731013
 ActiveWindowBorder2=#ee3532
 ActiveWindowTitle=white
-
 InactiveWindowBorder1=#734546
 InactiveWindowBorder2=#ee908f
 InactiveWindowTitle=white
-
 MovingWindowBorder1=#a76f24
 MovingWindowBorder2=#eec666
 MovingWindowTitle=white
-
 HighlightWindowBorder1=#a76f24
 HighlightWindowBorder2=#eec666
 HighlightWindowTitle=white
-
 MenuBase=#57691f
+MenuBaseText=white
 MenuStripe=#2b3018
 MenuSelection=#ff8742
-
+MenuSelectionText=black
 Window=#5a0103
 WindowText=white
 Button=#d46c64
 ButtonText=black
-
 Base=#d3d7c4
 BaseText=black
-
 ThreedHighlight=#e69e99
 ThreedShadow1=#a24841
 ThreedShadow2=#882d26
-
 HoverHighlight=#e6e5e2
-
 Selection=#84351a
 SelectionText=white

+ 2 - 0
Libraries/LibDraw/Palette.h

@@ -29,7 +29,9 @@ public:
     Color highlight_window_title() const { return color(ColorRole::HighlightWindowTitle); }
     Color menu_stripe() const { return color(ColorRole::MenuStripe); }
     Color menu_base() const { return color(ColorRole::MenuBase); }
+    Color menu_base_text() const { return color(ColorRole::MenuBaseText); }
     Color menu_selection() const { return color(ColorRole::MenuSelection); }
+    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 button() const { return color(ColorRole::Button); }

+ 2 - 0
Libraries/LibDraw/SystemTheme.cpp

@@ -72,7 +72,9 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
     DO_COLOR(HighlightWindowTitle);
     DO_COLOR(MenuStripe);
     DO_COLOR(MenuBase);
+    DO_COLOR(MenuBaseText);
     DO_COLOR(MenuSelection);
+    DO_COLOR(MenuSelectionText);
 
     buffer->seal();
     buffer->share_globally();

+ 2 - 0
Libraries/LibDraw/SystemTheme.h

@@ -21,7 +21,9 @@ enum class ColorRole {
     HighlightWindowTitle,
     MenuStripe,
     MenuBase,
+    MenuBaseText,
     MenuSelection,
+    MenuSelectionText,
     Window,
     WindowText,
     Button,

+ 3 - 3
Servers/WindowServer/WSMenu.cpp

@@ -154,11 +154,11 @@ void WSMenu::draw()
 
     for (auto& item : m_items) {
         if (item.type() == WSMenuItem::Text) {
-            Color text_color = palette.window_text();
+            Color text_color = palette.menu_base_text();
             if (&item == m_hovered_item && item.is_enabled()) {
                 painter.fill_rect(item.rect(), palette.menu_selection());
                 painter.draw_rect(item.rect(), palette.menu_selection().darkened());
-                text_color = Color::White;
+                text_color = palette.menu_selection_text();
             } else if (!item.is_enabled()) {
                 text_color = Color::MidGray;
             }
@@ -190,7 +190,7 @@ void WSMenu::draw()
                     s_submenu_arrow_bitmap_height
                 };
                 submenu_arrow_rect.center_vertically_within(item.rect());
-                painter.draw_bitmap(submenu_arrow_rect.location(), submenu_arrow_bitmap, palette.window_text());
+                painter.draw_bitmap(submenu_arrow_rect.location(), submenu_arrow_bitmap, text_color);
             }
         } else if (item.type() == WSMenuItem::Separator) {
             Point p1(item.rect().translated(stripe_rect.width() + 4, 0).x(), item.rect().center().y() - 1);