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
Notes: sideshowbarker 2024-07-19 01:46:57 +09:00
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);
}
}

View file

@ -39,6 +39,7 @@ public:
virtual void paint_normal_frame(Painter&, WindowState, const IntRect& window_rect, const StringView& title, const Bitmap& icon, const Palette&, const IntRect& leftmost_button_rect) const override;
virtual void paint_notification_frame(Painter&, const IntRect& window_rect, const Palette&, const IntRect& close_button_rect) const override;
virtual int title_bar_height(const Palette&) const override;
virtual IntRect title_bar_rect(WindowType, const IntRect& window_rect, const Palette&) const override;
virtual IntRect title_bar_icon_rect(WindowType, const IntRect& window_rect, const Palette&) const override;
virtual IntRect title_bar_text_rect(WindowType, const IntRect& window_rect, const Palette&) const override;

View file

@ -53,6 +53,7 @@ public:
virtual void paint_normal_frame(Painter&, WindowState, const IntRect& window_rect, const StringView& title, const Bitmap& icon, const Palette&, const IntRect& leftmost_button_rect) const = 0;
virtual void paint_notification_frame(Painter&, const IntRect& window_rect, const Palette&, const IntRect& close_button_rect) const = 0;
virtual int title_bar_height(const Palette&) const = 0;
virtual IntRect title_bar_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;
virtual IntRect title_bar_icon_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;
virtual IntRect title_bar_text_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;

View file

@ -1444,7 +1444,7 @@ void WindowManager::maximize_windows(Window& window, bool maximized)
Gfx::IntPoint WindowManager::get_recommended_window_position(const Gfx::IntPoint& desired)
{
// FIXME: Find a better source for the width and height to shift by.
Gfx::IntPoint shift(8, palette().window_title_height() + 10);
Gfx::IntPoint shift(8, Gfx::WindowTheme::current().title_bar_height(palette()) + 10);
// FIXME: Find a better source for this.
int taskbar_height = 28;
@ -1463,7 +1463,7 @@ Gfx::IntPoint WindowManager::get_recommended_window_position(const Gfx::IntPoint
point = overlap_window->position() + shift;
point = { point.x() % Screen::the().width(),
(point.y() >= (Screen::the().height() - taskbar_height))
? menubar_height + palette().window_title_height()
? menubar_height + Gfx::WindowTheme::current().title_bar_height(palette())
: point.y() };
} else {
point = desired;