From ccd19d464eed2b5915f91c3d6e3e368fb08638c0 Mon Sep 17 00:00:00 2001 From: Timothy Date: Thu, 8 Jul 2021 01:36:34 +1000 Subject: LibGUI: Handle multiple lines of text in MessageBox The total height of text is calculated from the glyph height, the number of lines, and a padding modifier. --- Userland/Libraries/LibGUI/MessageBox.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Userland/Libraries/LibGUI/MessageBox.cpp') diff --git a/Userland/Libraries/LibGUI/MessageBox.cpp b/Userland/Libraries/LibGUI/MessageBox.cpp index 2b0a59a5e0..c57c96d251 100644 --- a/Userland/Libraries/LibGUI/MessageBox.cpp +++ b/Userland/Libraries/LibGUI/MessageBox.cpp @@ -82,6 +82,9 @@ void MessageBox::build() auto& widget = set_main_widget(); int text_width = widget.font().width(m_text); + auto number_of_lines = m_text.split('\n').size(); + int padded_text_height = widget.font().glyph_height() * 1.6; + int total_text_height = number_of_lines * padded_text_height; int icon_width = 0; widget.set_layout(); @@ -105,7 +108,7 @@ void MessageBox::build() } auto& label = message_container.add