GInputBox: Use whichever is greater: the approximate size of the title, or the label's text

Might be an idea to add a minimum size constrain in window server
instead, since it knows the exact dimensions? But this is a simple fix
that seems to do the job.
This commit is contained in:
Robin Burchell 2019-05-17 15:49:06 +02:00 committed by Andreas Kling
parent 77dfd419e9
commit 20e55c0120
Notes: sideshowbarker 2024-07-19 14:03:46 +09:00

View file

@ -23,8 +23,10 @@ void GInputBox::build()
set_main_widget(widget);
int text_width = widget->font().width(m_prompt);
int title_width = widget->font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
int max_width = AK::max(text_width, title_width);
set_rect(x(), y(), text_width + 80, 80);
set_rect(x(), y(), max_width + 80, 80);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_fill_with_background_color(true);