From 2759d518b7fcb87b3f2a63b63e3f7e02c6ae973a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 16 Dec 2020 12:16:14 +0100 Subject: [PATCH] FileManager+LibGUI: Draw the item text for desktop icons with shadow This makes it look nice regardless of wallpaper or background color. --- Applications/FileManager/DirectoryView.cpp | 1 + Libraries/LibGUI/AbstractView.cpp | 7 ++++++- Libraries/LibGUI/AbstractView.h | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp index c826569d383..b5b2cc106dd 100644 --- a/Applications/FileManager/DirectoryView.cpp +++ b/Applications/FileManager/DirectoryView.cpp @@ -214,6 +214,7 @@ void DirectoryView::setup_icon_view() m_icon_view->set_frame_shape(Gfx::FrameShape::NoFrame); m_icon_view->set_scrollbars_enabled(false); m_icon_view->set_fill_with_background_color(false); + m_icon_view->set_draw_item_text_with_shadow(true); } m_icon_view->set_model(m_sorting_model); diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp index 3cf768e972d..53e01f83712 100644 --- a/Libraries/LibGUI/AbstractView.cpp +++ b/Libraries/LibGUI/AbstractView.cpp @@ -693,7 +693,12 @@ void AbstractView::draw_item_text(Gfx::Painter& painter, const ModelIndex& index }, text_rect, item_text, font, alignment, elision); } else { - painter.draw_text(text_rect, item_text, font, alignment, text_color, elision); + if (m_draw_item_text_with_shadow) { + painter.draw_text(text_rect.translated(1, 1), item_text, font, alignment, Color::Black, elision); + painter.draw_text(text_rect, item_text, font, alignment, Color::White, elision); + } else { + painter.draw_text(text_rect, item_text, font, alignment, text_color, elision); + } } } diff --git a/Libraries/LibGUI/AbstractView.h b/Libraries/LibGUI/AbstractView.h index 7e66730c8b1..a8716e19a88 100644 --- a/Libraries/LibGUI/AbstractView.h +++ b/Libraries/LibGUI/AbstractView.h @@ -127,6 +127,8 @@ public: bool is_tab_key_navigation_enabled() const { return m_tab_key_navigation_enabled; } void set_tab_key_navigation_enabled(bool enabled) { m_tab_key_navigation_enabled = enabled; } + void set_draw_item_text_with_shadow(bool b) { m_draw_item_text_with_shadow = b; } + protected: AbstractView(); virtual ~AbstractView() override; @@ -191,6 +193,7 @@ private: bool m_multi_select { true }; bool m_tab_key_navigation_enabled { false }; bool m_is_dragging { false }; + bool m_draw_item_text_with_shadow { false }; }; }