From 5e3460aaaeff30a4d17672972231dccea34b79ef Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 27 Jul 2021 22:40:14 -0600 Subject: [PATCH] canvas: start to extend size allocation process for box packing --- libs/canvas/box.cc | 14 ++++++++++++++ libs/canvas/canvas/box.h | 2 ++ libs/canvas/canvas/item.h | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/canvas/box.cc b/libs/canvas/box.cc index 91b9714d7a..fd3b871071 100644 --- a/libs/canvas/box.cc +++ b/libs/canvas/box.cc @@ -224,6 +224,20 @@ Box::reposition_children () set (r); } +void +Box::size_request (double& w, double& h) const +{ + w = width(); + h = height(); +} + +void +Box::size_allocate_children (Rect const & r) +{ + std::cerr << "Box allocated " << r << std::endl; + Item::size_allocate_children (r); +} + void Box::add (Item* i) { diff --git a/libs/canvas/canvas/box.h b/libs/canvas/canvas/box.h index 2d884a5e98..1ef5fa4472 100644 --- a/libs/canvas/canvas/box.h +++ b/libs/canvas/canvas/box.h @@ -67,6 +67,8 @@ public: void set_homogenous (bool); void compute_bounding_box () const; + void size_request (double& w, double& h) const; + void size_allocate_children (Rect const & r); protected: Orientation orientation; diff --git a/libs/canvas/canvas/item.h b/libs/canvas/canvas/item.h index d3544585e1..43695c9e06 100644 --- a/libs/canvas/canvas/item.h +++ b/libs/canvas/canvas/item.h @@ -153,6 +153,7 @@ public: virtual void preferred_size (Duple& minimum, Duple& natural) const; virtual void size_allocate (Rect const&); + virtual void size_allocate_children (Rect const & r); Rect allocation() const { return _allocation; } void set_layout_sensitive (bool); bool layout_sensitive () const { return _layout_sensitive; } @@ -353,7 +354,6 @@ public: void add_child_bounding_boxes (bool include_hidden = false) const; void render_children (Rect const & area, Cairo::RefPtr context) const; void prepare_for_render_children (Rect const & area) const; - void size_allocate_children (Rect const & r); Duple scroll_offset() const; public: