Parcourir la source

LibGfx+LibGUI: Allow theming the text cursor

Tibor Nagy il y a 5 ans
Parent
commit
c8bc53e987

+ 1 - 0
Base/res/themes/Dark.ini

@@ -40,3 +40,4 @@ Ruler=#505050
 RulerBorder=#666666
 RulerActiveText=white
 RulerInactiveText=#d5d0c7
+TextCursor=#9c9cd5

+ 1 - 0
Base/res/themes/Default.ini

@@ -40,3 +40,4 @@ Ruler=#d4d0c8
 RulerBorder=#404040
 RulerActiveText=#404040
 RulerInactiveText=#808080
+TextCursor=red

+ 1 - 0
Base/res/themes/Hotdog Stand.ini

@@ -40,3 +40,4 @@ Ruler=black
 RulerBorder=black
 RulerActiveText=yellow
 RulerInactiveText=white
+TextCursor=black

+ 1 - 0
Base/res/themes/Nord.ini

@@ -40,3 +40,4 @@ Ruler=#434c5e
 RulerBorder=#3b4252
 RulerActiveText=#95adc5
 RulerInactiveText=#7e9dbc
+TextCursor=#7e9dbc

+ 1 - 0
Base/res/themes/Xmas.ini

@@ -40,3 +40,4 @@ Ruler=#bcc1ae
 RulerBorder=#606060
 RulerActiveText=#404040
 RulerInactiveText=#808080
+TextCursor=#ee3532

+ 1 - 1
Libraries/LibGUI/TextEditor.cpp

@@ -496,7 +496,7 @@ void TextEditor::paint_event(PaintEvent& event)
     }
 
     if (is_focused() && m_cursor_state)
-        painter.fill_rect(cursor_content_rect(), Color::Red);
+        painter.fill_rect(cursor_content_rect(), palette().text_cursor());
 }
 
 void TextEditor::toggle_selection_if_needed_for_event(const KeyEvent& event)

+ 1 - 0
Libraries/LibGfx/Palette.h

@@ -98,6 +98,7 @@ public:
     Color ruler_border() const { return color(ColorRole::RulerBorder); }
     Color ruler_active_text() const { return color(ColorRole::RulerActiveText); }
     Color ruler_inactive_text() const { return color(ColorRole::RulerInactiveText); }
+    Color text_cursor() const { return color(ColorRole::TextCursor); }
 
     Color link() const { return color(ColorRole::Link); }
     Color active_link() const { return color(ColorRole::ActiveLink); }

+ 1 - 0
Libraries/LibGfx/SystemTheme.cpp

@@ -112,6 +112,7 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
     DO_COLOR(RulerBorder);
     DO_COLOR(RulerActiveText);
     DO_COLOR(RulerInactiveText);
+    DO_COLOR(TextCursor);
 
     buffer->seal();
     buffer->share_globally();

+ 1 - 0
Libraries/LibGfx/SystemTheme.h

@@ -75,6 +75,7 @@ enum class ColorRole {
     RulerBorder,
     RulerActiveText,
     RulerInactiveText,
+    TextCursor,
 
     __Count,