LibGUI: Implement calculated_min_size() for GlyphMapWidget

This commit is contained in:
thankyouverycool 2022-12-15 19:48:06 -05:00 committed by Andreas Kling
parent c4ac73d073
commit 0f5ce017c5
Notes: sideshowbarker 2024-07-17 08:43:11 +09:00
2 changed files with 9 additions and 0 deletions

View file

@ -498,4 +498,12 @@ ErrorOr<void> GlyphMapWidget::set_font(Gfx::Font const& font)
return {};
}
Optional<UISize> GlyphMapWidget::calculated_min_size() const
{
auto scrollbar = vertical_scrollbar().effective_min_size().height().as_int();
auto min_height = max(font().glyph_height() + m_vertical_spacing, scrollbar);
auto min_width = font().max_glyph_width() + m_horizontal_spacing + width_occupied_by_vertical_scrollbar();
return { { min_width + frame_thickness() * 2, min_height + frame_thickness() * 2 } };
}
}

View file

@ -88,6 +88,7 @@ private:
virtual void resize_event(ResizeEvent&) override;
virtual void did_change_font() override;
virtual void context_menu_event(ContextMenuEvent&) override;
virtual Optional<UISize> calculated_min_size() const override;
Gfx::IntRect get_outer_rect(int glyph) const;
Optional<int> glyph_at_position(Gfx::IntPoint) const;