From a086be993b22ca45d53e8143b26b937182725d48 Mon Sep 17 00:00:00 2001 From: sin-ack Date: Tue, 31 Aug 2021 00:31:44 +0000 Subject: [PATCH] LibGUI: Bias text towards bottom when tabs at top have uneven spacing This makes the text on inactive tabs in Browser look a lil' bit nicer. :^) --- Userland/Libraries/LibGUI/TabWidget.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp index db76058f59..8c65a8f6f6 100644 --- a/Userland/Libraries/LibGUI/TabWidget.cpp +++ b/Userland/Libraries/LibGUI/TabWidget.cpp @@ -218,6 +218,13 @@ void TabWidget::paint_event(PaintEvent& event) auto icon_rect_difference = icon_rect.top() - text_rect.top(); text_rect.set_top(text_rect.top() + icon_rect_difference); text_rect.set_height(text_rect.height() - icon_rect_difference); + + // ...unless our leftover height after text drawing is uneven, in which + // case we want to bias towards the bottom when the tab position is at + // the top. + if ((text_rect.height() - font().glyph_height()) % 2 != 0 && m_tab_position == TabPosition::Top) { + text_rect.set_top(text_rect.top() + 1); + } }; for (size_t i = 0; i < m_tabs.size(); ++i) {