1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:57:42 +00:00

LibGfx+WindowServer: Handle taller window title fonts better

If the window title font is taller than the theme's specified title
height, compute the title height based on the font instead. :^)
This commit is contained in:
Andreas Kling 2020-10-24 00:26:13 +02:00
parent f2584bc2eb
commit 20ca3d4a99
4 changed files with 13 additions and 5 deletions

View file

@ -110,13 +110,13 @@ void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window
IntRect ClassicWindowTheme::title_bar_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const
{
auto& title_font = Font::default_bold_font();
auto window_titlebar_height = palette.window_title_height();
auto window_titlebar_height = title_bar_height(palette);
// FIXME: The top of the titlebar doesn't get redrawn properly if this padding is different
int total_vertical_padding = title_font.glyph_height() - 1;
if (window_type == WindowType::Notification)
return { window_rect.width() + 3, total_vertical_padding / 2 - 1, window_titlebar_height, window_rect.height() };
return { 4, total_vertical_padding / 2, window_rect.width(), window_titlebar_height };
return { 4, 4, window_rect.width(), window_titlebar_height };
}
ClassicWindowTheme::FrameColors ClassicWindowTheme::compute_frame_colors(WindowState state, const Palette& palette) const
@ -155,7 +155,7 @@ void ClassicWindowTheme::paint_notification_frame(Painter& painter, const IntRec
IntRect ClassicWindowTheme::frame_rect_for_window(WindowType window_type, const IntRect& window_rect, const Gfx::Palette& palette) const
{
auto window_titlebar_height = palette.window_title_height();
auto window_titlebar_height = title_bar_height(palette);
switch (window_type) {
case WindowType::Normal:
@ -205,4 +205,10 @@ Vector<IntRect> ClassicWindowTheme::layout_buttons(WindowType window_type, const
return button_rects;
}
int ClassicWindowTheme::title_bar_height(const Palette& palette) const
{
auto& title_font = Font::default_bold_font();
return max(palette.window_title_height(), title_font.glyph_height() + 8);
}
}