From e34503800c41fb2844107f1e94fe27ea142b5507 Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Thu, 15 Dec 2022 17:10:50 -0500 Subject: LibGUI: Adjust GlyphMapWidget content sizing and glyph padding Fixes a slightly oversized content rect and erroneous glyph outer rect values. Increases glyph rect padding to guarantee at least 1px between the focus rect and glyph. --- Userland/Libraries/LibGUI/GlyphMapWidget.cpp | 19 +++++++++---------- Userland/Libraries/LibGUI/GlyphMapWidget.h | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp index eff4612537..f05b7aa98b 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp @@ -103,10 +103,10 @@ Gfx::IntRect GlyphMapWidget::get_outer_rect(int glyph) const int row = glyph / columns(); int column = glyph % columns(); return Gfx::IntRect { - column * (font().max_glyph_width() + m_horizontal_spacing) + 1, - row * (font().glyph_height() + m_vertical_spacing) + 1, + column * (font().max_glyph_width() + m_horizontal_spacing), + row * (font().glyph_height() + m_vertical_spacing), font().max_glyph_width() + m_horizontal_spacing, - font().glyph_height() + m_horizontal_spacing + font().glyph_height() + m_vertical_spacing } .translated(frame_thickness() - horizontal_scrollbar().value(), frame_thickness() - vertical_scrollbar().value()); } @@ -383,10 +383,10 @@ void GlyphMapWidget::scroll_to_glyph(int glyph) int row = glyph / columns(); int column = glyph % columns(); auto scroll_rect = Gfx::IntRect { - column * (font().max_glyph_width() + m_horizontal_spacing) + 1, - row * (font().glyph_height() + m_vertical_spacing) + 1, + column * (font().max_glyph_width() + m_horizontal_spacing), + row * (font().glyph_height() + m_vertical_spacing), font().max_glyph_width() + m_horizontal_spacing, - font().glyph_height() + m_horizontal_spacing + font().glyph_height() + m_vertical_spacing }; scroll_into_view(scroll_rect, true, true); } @@ -435,15 +435,14 @@ void GlyphMapWidget::select_next_existing_glyph() void GlyphMapWidget::recalculate_content_size() { - auto inner_rect = frame_inner_rect(); - int event_width = inner_rect.width() - vertical_scrollbar().width() - m_horizontal_spacing; - int event_height = inner_rect.height(); + auto event_width = widget_inner_rect().width(); + auto event_height = widget_inner_rect().height(); m_visible_glyphs = (event_width * event_height) / (font().max_glyph_width() * font().glyph_height()); m_columns = max(event_width / (font().max_glyph_width() + m_horizontal_spacing), 1); m_rows = ceil_div(m_glyph_count, m_columns); int content_width = columns() * (font().max_glyph_width() + m_horizontal_spacing); - int content_height = rows() * (font().glyph_height() + m_vertical_spacing) + frame_thickness(); + int content_height = rows() * (font().glyph_height() + m_vertical_spacing); set_content_size({ content_width, content_height }); scroll_to_glyph(m_active_glyph); diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.h b/Userland/Libraries/LibGUI/GlyphMapWidget.h index ffd312527c..7db5d47ede 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.h +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.h @@ -100,8 +100,8 @@ private: int m_glyph_count { 0x110000 }; int m_columns { 0 }; int m_rows { 0 }; - int m_horizontal_spacing { 2 }; - int m_vertical_spacing { 2 }; + int m_horizontal_spacing { 4 }; + int m_vertical_spacing { 4 }; Selection m_selection; int m_active_glyph { 0 }; int m_visible_glyphs { 0 }; -- cgit v1.2.3