|
@@ -60,18 +60,7 @@ GlyphMapWidget::~GlyphMapWidget()
|
|
|
|
|
|
void GlyphMapWidget::resize_event(ResizeEvent& event)
|
|
|
{
|
|
|
- int event_width = event.size().width() - vertical_scrollbar().width() - (frame_thickness() * 2) - m_horizontal_spacing;
|
|
|
- int event_height = event.size().height() - (frame_thickness() * 2);
|
|
|
- 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();
|
|
|
- set_content_size({ content_width, content_height });
|
|
|
-
|
|
|
- scroll_to_glyph(m_active_glyph);
|
|
|
-
|
|
|
+ recalculate_content_size();
|
|
|
AbstractScrollableWidget::resize_event(event);
|
|
|
}
|
|
|
|
|
@@ -245,6 +234,7 @@ void GlyphMapWidget::keydown_event(KeyEvent& event)
|
|
|
|
|
|
void GlyphMapWidget::did_change_font()
|
|
|
{
|
|
|
+ recalculate_content_size();
|
|
|
vertical_scrollbar().set_step(font().glyph_height() + m_vertical_spacing);
|
|
|
set_active_glyph('A');
|
|
|
}
|
|
@@ -262,4 +252,20 @@ void GlyphMapWidget::scroll_to_glyph(int glyph)
|
|
|
scroll_into_view(scroll_rect, true, true);
|
|
|
}
|
|
|
|
|
|
+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();
|
|
|
+ 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();
|
|
|
+ set_content_size({ content_width, content_height });
|
|
|
+
|
|
|
+ scroll_to_glyph(m_active_glyph);
|
|
|
+}
|
|
|
+
|
|
|
}
|