2013-04-15 22:10:18 -04:00
|
|
|
/*
|
2019-08-02 22:40:09 -04:00
|
|
|
* Copyright (C) 2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2013-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2013-04-15 22:10:18 -04:00
|
|
|
|
2020-06-10 17:48:58 -04:00
|
|
|
#include "pbd/stacktrace.h"
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/root_group.h"
|
|
|
|
#include "canvas/canvas.h"
|
2020-06-10 17:48:58 -04:00
|
|
|
#include "canvas/constraint_packer.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ArdourCanvas;
|
|
|
|
|
2014-06-21 11:43:42 -04:00
|
|
|
Root::Root (Canvas* canvas)
|
2014-06-22 11:41:05 -04:00
|
|
|
: Container (canvas)
|
2013-04-04 00:32:52 -04:00
|
|
|
{
|
|
|
|
#ifdef CANVAS_DEBUG
|
|
|
|
name = "ROOT";
|
2015-10-05 10:17:49 -04:00
|
|
|
#endif
|
2013-04-04 00:32:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-06-10 17:48:58 -04:00
|
|
|
Root::preferred_size (Duple& min, Duple& natural) const
|
2013-04-04 00:32:52 -04:00
|
|
|
{
|
2020-06-10 17:48:58 -04:00
|
|
|
if (_items.size() == 1) {
|
|
|
|
cerr << "Call prefsize on " << _items.front()->whoami() << endl;
|
|
|
|
_items.front()->preferred_size (min, natural);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cerr << "use regular prefsize for root\n";
|
|
|
|
|
|
|
|
Item::preferred_size (min, natural);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Root::size_allocate (Rect const & r)
|
|
|
|
{
|
|
|
|
bool have_constraint_container = false;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2020-06-10 17:48:58 -04:00
|
|
|
if (have_constraint_container) {
|
|
|
|
_bounding_box_dirty = true;
|
2013-04-04 00:32:52 -04:00
|
|
|
}
|
|
|
|
}
|