summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2022-12-15 17:10:50 -0500
committerAndreas Kling <kling@serenityos.org>2022-12-20 10:22:27 +0100
commite34503800c41fb2844107f1e94fe27ea142b5507 (patch)
tree753613d12445d3e7019b311d5bac7acb5483e404 /Userland
parent0f5ce017c5be265f7eef1716e142ab00e8422a5f (diff)
downloadserenity-e34503800c41fb2844107f1e94fe27ea142b5507.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGUI/GlyphMapWidget.cpp19
-rw-r--r--Userland/Libraries/LibGUI/GlyphMapWidget.h4
2 files changed, 11 insertions, 12 deletions
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 };