mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:37:44 +00:00
Make a preparation pass for variable-width fonts.
This commit is contained in:
parent
b85fe0bd07
commit
0a86366c71
9 changed files with 72 additions and 32 deletions
|
@ -404,7 +404,7 @@ void WSWindowManager::paint_window_frame(WSWindow& window)
|
|||
auto close_button_rect = close_button_rect_for_window(window.rect());
|
||||
|
||||
auto titlebar_title_rect = titlebar_inner_rect;
|
||||
titlebar_title_rect.set_width(font().glyph_width() * window.title().length());
|
||||
titlebar_title_rect.set_width(font().width(window.title()));
|
||||
|
||||
Rect inner_border_rect {
|
||||
window.x() - 1,
|
||||
|
@ -948,7 +948,7 @@ void WSWindowManager::draw_menubar()
|
|||
auto time_rect = menubar_rect().translated(-(menubar_menu_margin() / 2), 0);
|
||||
m_back_painter->draw_text(time_rect, time_text, TextAlignment::CenterRight, Color::Black);
|
||||
|
||||
Rect cpu_rect { time_rect.right() - font().glyph_width() * time_text.length() - (int)m_cpu_history.capacity() - 10, time_rect.y() + 1, (int)m_cpu_history.capacity(), time_rect.height() - 2 };
|
||||
Rect cpu_rect { time_rect.right() - font().width(time_text) - (int)m_cpu_history.capacity() - 10, time_rect.y() + 1, (int)m_cpu_history.capacity(), time_rect.height() - 2 };
|
||||
m_back_painter->fill_rect(cpu_rect, Color::Black);
|
||||
int i = m_cpu_history.capacity() - m_cpu_history.size();
|
||||
for (auto cpu_usage : m_cpu_history) {
|
||||
|
|
|
@ -95,10 +95,10 @@ void WSWindowSwitcher::refresh()
|
|||
m_windows.clear();
|
||||
m_selected_index = 0;
|
||||
int window_count = 0;
|
||||
int longest_title = 0;
|
||||
int longest_title_width = 0;
|
||||
WSWindowManager::the().for_each_visible_window_of_type_from_back_to_front(WSWindowType::Normal, [&] (WSWindow& window) {
|
||||
++window_count;
|
||||
longest_title = max(longest_title, window.title().length());
|
||||
longest_title_width = max(longest_title_width, WSWindowManager::the().font().width(window.title()));
|
||||
if (selected_window == &window)
|
||||
m_selected_index = m_windows.size();
|
||||
m_windows.append(window.make_weak_ptr());
|
||||
|
@ -108,8 +108,8 @@ void WSWindowSwitcher::refresh()
|
|||
hide();
|
||||
return;
|
||||
}
|
||||
int space_for_window_rect = WSWindowManager::the().font().glyph_width() * 24;
|
||||
m_rect.set_width(longest_title * WSWindowManager::the().font().glyph_width() + space_for_window_rect + padding() * 2);
|
||||
int space_for_window_rect = 180;
|
||||
m_rect.set_width(longest_title_width + space_for_window_rect + padding() * 2);
|
||||
m_rect.set_height(window_count * item_height() + padding() * 2);
|
||||
m_rect.center_within(WSWindowManager::the().m_screen_rect);
|
||||
if (!m_switcher_window)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue