LibGUI: Improve calculated_min_size() for single-line TextEditor

TextBox now shrinks to fit the current font based on preferred line
height, maintaining its historical minimum size of 40x22
This commit is contained in:
thankyouverycool 2023-04-16 16:01:34 -04:00 committed by Andreas Kling
commit 9c2bcffe83
Notes: sideshowbarker 2024-07-16 21:18:08 +09:00
2 changed files with 6 additions and 3 deletions

View file

@ -22,8 +22,8 @@ namespace GUI {
TextBox::TextBox()
: TextEditor(TextEditor::SingleLine)
{
set_min_size({ 40, 22 });
set_preferred_size({ SpecialDimension::OpportunisticGrow, 22 });
set_min_size({ SpecialDimension::Shrink });
set_preferred_size({ SpecialDimension::OpportunisticGrow, SpecialDimension::Shrink });
}
void TextBox::keydown_event(GUI::KeyEvent& event)