mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:17:34 +00:00
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.
This commit is contained in:
parent
0f5ce017c5
commit
e34503800c
2 changed files with 11 additions and 12 deletions
|
@ -103,10 +103,10 @@ Gfx::IntRect GlyphMapWidget::get_outer_rect(int glyph) const
|
||||||
int row = glyph / columns();
|
int row = glyph / columns();
|
||||||
int column = glyph % columns();
|
int column = glyph % columns();
|
||||||
return Gfx::IntRect {
|
return Gfx::IntRect {
|
||||||
column * (font().max_glyph_width() + m_horizontal_spacing) + 1,
|
column * (font().max_glyph_width() + m_horizontal_spacing),
|
||||||
row * (font().glyph_height() + m_vertical_spacing) + 1,
|
row * (font().glyph_height() + m_vertical_spacing),
|
||||||
font().max_glyph_width() + m_horizontal_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());
|
.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 row = glyph / columns();
|
||||||
int column = glyph % columns();
|
int column = glyph % columns();
|
||||||
auto scroll_rect = Gfx::IntRect {
|
auto scroll_rect = Gfx::IntRect {
|
||||||
column * (font().max_glyph_width() + m_horizontal_spacing) + 1,
|
column * (font().max_glyph_width() + m_horizontal_spacing),
|
||||||
row * (font().glyph_height() + m_vertical_spacing) + 1,
|
row * (font().glyph_height() + m_vertical_spacing),
|
||||||
font().max_glyph_width() + m_horizontal_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);
|
scroll_into_view(scroll_rect, true, true);
|
||||||
}
|
}
|
||||||
|
@ -435,15 +435,14 @@ void GlyphMapWidget::select_next_existing_glyph()
|
||||||
|
|
||||||
void GlyphMapWidget::recalculate_content_size()
|
void GlyphMapWidget::recalculate_content_size()
|
||||||
{
|
{
|
||||||
auto inner_rect = frame_inner_rect();
|
auto event_width = widget_inner_rect().width();
|
||||||
int event_width = inner_rect.width() - vertical_scrollbar().width() - m_horizontal_spacing;
|
auto event_height = widget_inner_rect().height();
|
||||||
int event_height = inner_rect.height();
|
|
||||||
m_visible_glyphs = (event_width * event_height) / (font().max_glyph_width() * font().glyph_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_columns = max(event_width / (font().max_glyph_width() + m_horizontal_spacing), 1);
|
||||||
m_rows = ceil_div(m_glyph_count, m_columns);
|
m_rows = ceil_div(m_glyph_count, m_columns);
|
||||||
|
|
||||||
int content_width = columns() * (font().max_glyph_width() + m_horizontal_spacing);
|
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 });
|
set_content_size({ content_width, content_height });
|
||||||
|
|
||||||
scroll_to_glyph(m_active_glyph);
|
scroll_to_glyph(m_active_glyph);
|
||||||
|
|
|
@ -100,8 +100,8 @@ private:
|
||||||
int m_glyph_count { 0x110000 };
|
int m_glyph_count { 0x110000 };
|
||||||
int m_columns { 0 };
|
int m_columns { 0 };
|
||||||
int m_rows { 0 };
|
int m_rows { 0 };
|
||||||
int m_horizontal_spacing { 2 };
|
int m_horizontal_spacing { 4 };
|
||||||
int m_vertical_spacing { 2 };
|
int m_vertical_spacing { 4 };
|
||||||
Selection m_selection;
|
Selection m_selection;
|
||||||
int m_active_glyph { 0 };
|
int m_active_glyph { 0 };
|
||||||
int m_visible_glyphs { 0 };
|
int m_visible_glyphs { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue