Use draw_rect() instead of on_draw() to draw onto the ImageSurface for exporting the collage. This prevents us from taking into considderation the zoom factor and selection.
Split the selection updating into button_press and button_release portions. In button_press, we handle new selections, i.e. selecting a leaf rectangle that is not within the currently selected rectangle. In button_release, we handle cycling the selections, i.e. if traversing up the tree from the current selection. This split allows a drag starting from an unselected region to work predictably, without needing to have previously triggered a button_release event first, while avoiding cycling the selected rectangle when beginning to drag an already selected rectangle.
When recalculate_size() is triggered at a certain level in the tree, we need to recalculate it before going up the tree to the root. This is because aspect_ratio() starts flapping around due to width()/height() changes after a layout change, causing some rather non-deterministic behaviour when recalculating the size.
This prevents a segfault if the selection is no longer part of the new collage
In preparation of making a recursive find_rect() function which will need shared_from_this in the base class, we need to move enable_shared_from_this into the base Rectangle class. CompositeRectangle will still get a type-safe shared_from_this() function using static_pointer_cast, which is safe because CompositeRectangle::shared_from_this is guaranteed to be called with a CompositeRectangle instance.