diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-09 21:24:12 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-09 21:24:12 +0100 |
commit | ffe452231634534315321b3096dda60f329f6baa (patch) | |
tree | 2dd99055f60835a00863cae3ade82d8aab581b9b /WindowServer/WSWindowManager.cpp | |
parent | b8f999cbefe3585f077aaf8f07067e5a9c61aebc (diff) | |
download | serenity-ffe452231634534315321b3096dda60f329f6baa.zip |
SharedGraphics: Allow passing a Font to text drawing functions.
This way we don't have to juggle around with calls to Painter::set_font()
which simplifies a bunch of places.
Diffstat (limited to 'WindowServer/WSWindowManager.cpp')
-rw-r--r-- | WindowServer/WSWindowManager.cpp | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/WindowServer/WSWindowManager.cpp b/WindowServer/WSWindowManager.cpp index 260b0caf3d..7dcb28f889 100644 --- a/WindowServer/WSWindowManager.cpp +++ b/WindowServer/WSWindowManager.cpp @@ -179,8 +179,6 @@ WSWindowManager::WSWindowManager() m_front_painter = make<Painter>(*m_front_bitmap); m_back_painter = make<Painter>(*m_back_bitmap); - m_font = Font::default_font(); - m_front_painter->set_font(font()); m_back_painter->set_font(font()); @@ -282,6 +280,26 @@ WSWindowManager::~WSWindowManager() { } +const Font& WSWindowManager::font() const +{ + return Font::default_font(); +} + +const Font& WSWindowManager::window_title_font() const +{ + return Font::default_bold_font(); +} + +const Font& WSWindowManager::menu_font() const +{ + return Font::default_font(); +} + +const Font& WSWindowManager::app_menu_font() const +{ + return Font::default_bold_font(); +} + static void get_cpu_usage(unsigned& busy, unsigned& idle) { busy = 0; @@ -463,9 +481,7 @@ void WSWindowManager::paint_window_frame(WSWindow& window) m_back_painter->draw_rect(outer_rect, border_color); m_back_painter->draw_rect(inner_border_rect, border_color); - m_back_painter->set_font(Font::default_bold_font()); - m_back_painter->draw_text(titlebar_title_rect, window.title(), TextAlignment::CenterLeft, title_color); - m_back_painter->set_font(font()); + m_back_painter->draw_text(titlebar_title_rect, window.title(), window_title_font(), TextAlignment::CenterLeft, title_color); if (!s_close_button_bitmap) s_close_button_bitmap = &CharacterBitmap::create_from_ascii(s_close_button_bitmap_data, s_close_button_bitmap_width, s_close_button_bitmap_height).leak_ref(); @@ -946,11 +962,13 @@ void WSWindowManager::draw_menubar() m_back_painter->fill_rect(menu.rect_in_menubar(), menu_selection_color()); text_color = Color::White; } - if (index == 1) - m_back_painter->set_font(Font::default_bold_font()); - m_back_painter->draw_text(menu.text_rect_in_menubar(), menu.name(), TextAlignment::CenterLeft, text_color); - if (index == 1) - m_back_painter->set_font(font()); + m_back_painter->draw_text( + menu.text_rect_in_menubar(), + menu.name(), + index == 1 ? app_menu_font() : menu_font(), + TextAlignment::CenterLeft, + text_color + ); ++index; return true; }); |