From 6aaba192a0863057f3723751a69742fa9eebd168 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 14 Sep 2021 21:39:24 -0600 Subject: [PATCH] canvas: improve computation of Table bounding box --- libs/canvas/canvas/table.h | 2 +- libs/canvas/table.cc | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/libs/canvas/canvas/table.h b/libs/canvas/canvas/table.h index 69334d5a06..ee83b44ec3 100644 --- a/libs/canvas/canvas/table.h +++ b/libs/canvas/canvas/table.h @@ -98,7 +98,7 @@ public: Index lower_right; Duple natural_size; Duple allocate_size; - Duple full_size; + Rect full_size; FourDimensions padding; CellInfo (Item* i, PackOptions ro, PackOptions co, Index const & ul, Index const & lr, FourDimensions const & p) diff --git a/libs/canvas/table.cc b/libs/canvas/table.cc index 8d9905cb2b..10cd3219b3 100644 --- a/libs/canvas/table.cc +++ b/libs/canvas/table.cc @@ -85,17 +85,12 @@ Table::compute_bounding_box() const return; } - add_child_bounding_boxes (!collapse_on_hide); - - if (_bounding_box) { -#if 0 - Rect r = _bounding_box; - - _bounding_box = r.expand (top_padding + outline_width() + top_margin, - right_padding + outline_width() + right_margin, - bottom_padding + outline_width() + bottom_margin, - left_padding + outline_width() + left_margin); -#endif + for (auto const & cell : cells) { + if (_bounding_box) { + _bounding_box = _bounding_box.extend (cell.second.full_size); + } else { + _bounding_box = cell.second.full_size; + } } DEBUG_TRACE (DEBUG::CanvasTable, string_compose ("bounding box computed as %1\n", _bounding_box)); @@ -441,6 +436,7 @@ Table::compute (Rect const & within) rect)); ci->second.content->size_allocate (rect); + ci->second.full_size = rect; hdistance += rect.width() + ci->second.padding.right; hdistance += col_info[c].spacing;