13
0

Canvas: alter RootGroup to work with layout

This commit is contained in:
Paul Davis 2020-06-10 15:48:58 -06:00
parent baea368223
commit ad39faeb3e
2 changed files with 35 additions and 7 deletions

View File

@ -27,12 +27,15 @@ namespace ArdourCanvas {
class LIBCANVAS_API Root : public Container
{
private:
public:
void preferred_size (Duple&, Duple&) const;
void size_allocate (Rect const &);
private:
friend class Canvas;
Root (Canvas *);
void compute_bounding_box () const;
};
}

View File

@ -17,8 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "pbd/stacktrace.h"
#include "canvas/root_group.h"
#include "canvas/canvas.h"
#include "canvas/constraint_packer.h"
using namespace std;
using namespace ArdourCanvas;
@ -32,12 +35,34 @@ Root::Root (Canvas* canvas)
}
void
Root::compute_bounding_box () const
Root::preferred_size (Duple& min, Duple& natural) const
{
Container::compute_bounding_box ();
if (_items.size() == 1) {
cerr << "Call prefsize on " << _items.front()->whoami() << endl;
_items.front()->preferred_size (min, natural);
return;
}
if (_bounding_box) {
Rect r (_bounding_box);
_canvas->request_size (Duple (r.width (), r.height ()));
cerr << "use regular prefsize for root\n";
Item::preferred_size (min, natural);
}
void
Root::size_allocate (Rect const & r)
{
bool have_constraint_container = false;
cerr << "ROOT alloc " << r << endl;
for (list<Item*>::const_iterator i = _items.begin(); i != _items.end(); ++i) {
if (dynamic_cast<ConstraintPacker*> (*i)) {
(*i)->size_allocate (r);
have_constraint_container = true;
}
}
if (have_constraint_container) {
_bounding_box_dirty = true;
}
}