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:
parent
be461e95e1
commit
63a74d0911
@ -124,20 +124,13 @@ Widget::_size_allocate (Rect const & r)
|
||||
void
|
||||
Widget::compute_bounding_box () const
|
||||
{
|
||||
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);
|
||||
if (_allocation) {
|
||||
_bounding_box = Rect (0, 0, _allocation.width(), _allocation.height());
|
||||
} else {
|
||||
GtkRequisition req = { 0, 0 };
|
||||
_widget.size_request (req);
|
||||
_bounding_box = Rect (0., 0., req.width, req.height);
|
||||
}
|
||||
|
||||
bb_clean ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user