13
0

Canvas: improve behavior of Widget::compute_bounding_box()

Firstly, ::compute_bounding_box() cannot allocate space, so do not try to do that here.
Secondly, if there is no allocation yet, use the CairoWidget's own size_request()
This commit is contained in:
Paul Davis 2021-09-10 12:59:29 -06:00
parent be461e95e1
commit 63a74d0911

View File

@ -124,20 +124,13 @@ Widget::_size_allocate (Rect const & r)
void
Widget::compute_bounding_box () const
{
if (_allocation) {
_bounding_box = Rect (0, 0, _allocation.width(), _allocation.height());
} else {
GtkRequisition req = { 0, 0 };
Gtk::Allocation alloc;
_widget.size_request (req);
_bounding_box = Rect (0, 0, req.width, req.height);
/* make sure the widget knows that it got what it asked for */
alloc.set_x (0);
alloc.set_y (0);
alloc.set_width (req.width);
alloc.set_height (req.height);
_widget.size_allocate (alloc);
_bounding_box = Rect (0., 0., req.width, req.height);
}
bb_clean ();
}