Canvas: propagate ::size_allocate() down the item tree
This previously wasn't done because of fear that it would affect the traditional fixed-sized canvas, but only items that _layout_sensitive (i.e. are packed into a constraint packer directly) will actually do anything in ::size_allocate(). Possibly might want to relax this to cover items that have a constraint packer between them and a root group.
This commit is contained in:
parent
d51893dec6
commit
860d43697c
@ -347,6 +347,7 @@ public:
|
||||
void add_child_bounding_boxes (bool include_hidden = false) const;
|
||||
void render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
|
||||
void prepare_for_render_children (Rect const & area) const;
|
||||
void size_allocate_children (Rect const & r);
|
||||
|
||||
Duple scroll_offset() const;
|
||||
public:
|
||||
|
@ -29,7 +29,6 @@ class LIBCANVAS_API Root : public Container
|
||||
{
|
||||
public:
|
||||
void preferred_size (Duple&, Duple&) const;
|
||||
void size_allocate (Rect const &);
|
||||
|
||||
private:
|
||||
friend class Canvas;
|
||||
|
@ -509,8 +509,6 @@ cBox::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
||||
|
||||
if (fill()) {
|
||||
|
||||
cerr << whoami() << " setting fill context with 0x" << std::hex << _fill_color << std::dec << " draw " << draw << endl;
|
||||
|
||||
setup_fill_context (context);
|
||||
context->rectangle (draw.x0, draw.y0, draw.width(), draw.height());
|
||||
context->fill_preserve ();
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "pbd/convert.h"
|
||||
|
||||
#include "canvas/canvas.h"
|
||||
#include "canvas/constraint_packer.h"
|
||||
#include "canvas/debug.h"
|
||||
#include "canvas/item.h"
|
||||
#include "canvas/scroll_group.h"
|
||||
@ -607,6 +608,27 @@ Item::size_allocate (Rect const & r)
|
||||
_position = Duple (r.x0, r.y0);
|
||||
_allocation = r;
|
||||
}
|
||||
|
||||
size_allocate_children (r);
|
||||
}
|
||||
|
||||
void
|
||||
Item::size_allocate_children (Rect const & r)
|
||||
{
|
||||
bool have_constraint_container = false;
|
||||
|
||||
for (list<Item*>::const_iterator i = _items.begin(); i != _items.end(); ++i) {
|
||||
|
||||
(*i)->size_allocate (r);
|
||||
|
||||
if (dynamic_cast<ConstraintPacker*> (*i)) {
|
||||
have_constraint_container = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (have_constraint_container) {
|
||||
_bounding_box_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -288,13 +288,13 @@ Rectangle::vertical_fraction (double y) const
|
||||
void
|
||||
Rectangle::size_allocate (Rect const & r)
|
||||
{
|
||||
_allocation = r;
|
||||
Item::size_allocate (r);
|
||||
|
||||
if (_layout_sensitive) {
|
||||
/* set position, and then set the _rect member with values that
|
||||
use _position as the origin.
|
||||
/* Item::size_allocate() will have set _position, and then set
|
||||
the _rect member with values that use _position as the
|
||||
origin.
|
||||
*/
|
||||
_position = Duple (r.x0, r.y0);
|
||||
Rect r2 (0, 0, r.x1 - r.x0, r.y1 - r.y0);
|
||||
set (r2);
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "canvas/root_group.h"
|
||||
#include "canvas/canvas.h"
|
||||
#include "canvas/constraint_packer.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ArdourCanvas;
|
||||
@ -48,19 +47,3 @@ Root::preferred_size (Duple& min, Duple& natural) const
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (have_constraint_container) {
|
||||
_bounding_box_dirty = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user