more fixes for Box and Grid layout

This commit is contained in:
Paul Davis 2017-08-25 15:53:19 -04:00
parent 7e66535c84
commit f98efbaf22
3 changed files with 11 additions and 5 deletions

View file

@ -20,6 +20,7 @@
#include <algorithm>
#include "pbd/unwind.h"
#include "pbd/stacktrace.h"
#include "canvas/box.h"
#include "canvas/rectangle.h"
@ -39,11 +40,13 @@ Box::Box (Canvas* canvas, Orientation o)
bg->name = "bg rect for box";
bg->set_outline (false);
bg->set_fill (false);
bg->hide ();
}
void
Box::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
bg->render (area, context);
Item::render_children (area, context);
}
@ -148,6 +151,11 @@ Box::reposition_children ()
for (std::list<Item*>::iterator i = _items.begin(); i != _items.end(); ++i) {
if ((*i) == bg || !(*i)->visible()) {
/* background rect takes up no space */
continue;
}
(*i)->set_position (previous_edge);
if (homogenous) {
@ -204,12 +212,10 @@ Box::reposition_children ()
}
if (!_bounding_box) {
bg->hide ();
return;
}
Rect r (_bounding_box);
/* XXX need to shrink by margin */
bg->set (r);
}

View file

@ -76,7 +76,7 @@ public:
void parented ();
private:
Rectangle *bg;
Rectangle* bg;
bool collapse_on_hide;
bool homogenous;
bool repositioning;

View file

@ -41,6 +41,7 @@ Grid::Grid (Canvas* canvas)
{
bg = new Rectangle (this);
bg->name = "bg rect for grid";
bg->hide ();
}
void
@ -52,6 +53,7 @@ Grid::set_homogenous (bool yn)
void
Grid::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
bg->render (area, context);
Item::render_children (area, context);
}
@ -297,7 +299,6 @@ Grid::reposition_children ()
}
if (!_bounding_box) {
bg->hide ();
return;
} else {
@ -306,7 +307,6 @@ Grid::reposition_children ()
/* XXX need to shrink by margin */
bg->set (r);
bg->show ();
}
}