fix documentlayout automatic sizing

This commit is contained in:
hippoz 2022-07-26 01:05:37 +03:00
parent 59e8806c9e
commit 6dd0a1338f
Signed by: hippoz
GPG key ID: 7C52899193467641

View file

@ -9,7 +9,7 @@ void DocumentLayout::run() {
if (!m_target) if (!m_target)
return; return;
Point bound { m_margin, m_margin }; Point bound { m_margin + m_target->rect().max_geometry().width(), m_margin };
Point current_position { m_margin, m_margin }; Point current_position { m_margin, m_margin };
double largest_height_so_far = -1.0; double largest_height_so_far = -1.0;
@ -36,10 +36,12 @@ void DocumentLayout::run() {
if (!new_row_because_of_control_widget) { if (!new_row_because_of_control_widget) {
current_position.add(child->rect().width() + m_margin, 0); current_position.add(child->rect().width() + m_margin, 0);
bound.add(child->rect().width() + m_margin, 0);
} }
} }
/* account for the first row */
bound.add(0, largest_height_so_far);
m_target->rect().set_width(bound.x()); m_target->rect().set_width(bound.x());
m_target->rect().set_height(bound.y()); m_target->rect().set_height(bound.y());
} }