fix up Canvas::Grid child layout
This commit is contained in:
parent
73acd5b413
commit
b4cf8cfc49
@ -45,7 +45,7 @@ public:
|
|||||||
void set_border_width (double w) { set_outline_width (w); }
|
void set_border_width (double w) { set_outline_width (w); }
|
||||||
void set_border_color (Color c) { set_outline_color (c); }
|
void set_border_color (Color c) { set_outline_color (c); }
|
||||||
|
|
||||||
void place(Item*, Duple coord);
|
void place (Item*, Duple coord);
|
||||||
|
|
||||||
void set_collapse_on_hide (bool);
|
void set_collapse_on_hide (bool);
|
||||||
void set_homogenous (bool);
|
void set_homogenous (bool);
|
||||||
|
@ -188,7 +188,13 @@ Grid::reposition_children ()
|
|||||||
row_dimens.assign (max_row, 0);
|
row_dimens.assign (max_row, 0);
|
||||||
col_dimens.assign (max_col, 0);
|
col_dimens.assign (max_col, 0);
|
||||||
|
|
||||||
for (std::list<Item*>::iterator i = _items.begin(); ++i != _items.end(); ++i) {
|
for (std::list<Item*>::iterator i = _items.begin(); i != _items.end(); ++i) {
|
||||||
|
|
||||||
|
if (*i == self) {
|
||||||
|
/* self-rect is not a normal child */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
boost::optional<Rect> bb = (*i)->bounding_box();
|
boost::optional<Rect> bb = (*i)->bounding_box();
|
||||||
|
|
||||||
if (!bb) {
|
if (!bb) {
|
||||||
@ -207,27 +213,33 @@ Grid::reposition_children ()
|
|||||||
* column.
|
* column.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
double prev = row_dimens[0];
|
double current_top_edge = top_margin;
|
||||||
row_dimens[0] = top_margin;
|
|
||||||
|
|
||||||
for (uint32_t n = 1; n < max_row; ++n) {
|
for (uint32_t n = 0; n < max_row; ++n) {
|
||||||
row_dimens[n] = row_dimens[n-1] + prev + top_padding + bottom_padding;
|
if (row_dimens[n]) {
|
||||||
prev = row_dimens[n] + bottom_padding;
|
/* height defined for this row */
|
||||||
|
const double h = row_dimens[n]; /* save height */
|
||||||
|
row_dimens[n] = current_top_edge;
|
||||||
|
current_top_edge = current_top_edge + h + top_padding + bottom_padding;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = col_dimens[0];
|
double current_right_edge = left_margin;
|
||||||
col_dimens[0] = left_margin;
|
|
||||||
|
|
||||||
for (uint32_t n = 1; n < max_col; ++n) {
|
for (uint32_t n = 0; n < max_col; ++n) {
|
||||||
col_dimens[n] = col_dimens[n-1] + prev + left_padding + right_padding;
|
if (col_dimens[n]) {
|
||||||
prev = col_dimens[n];
|
/* a width was defined for this column */
|
||||||
|
const double w = col_dimens[n]; /* save width of this column */
|
||||||
|
col_dimens[n] = current_right_edge;
|
||||||
|
current_right_edge = current_right_edge + w + left_padding + right_padding;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* position each item at the upper left of its (row, col) coordinate,
|
/* position each item at the upper left of its (row, col) coordinate,
|
||||||
* given the width of all rows or columns before it.
|
* given the width of all rows or columns before it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (std::list<Item*>::iterator i = _items.begin(); ++i != _items.end(); ++i) {
|
for (std::list<Item*>::iterator i = _items.begin(); i != _items.end(); ++i) {
|
||||||
CoordsByItem::const_iterator c = coords_by_item.find (*i);
|
CoordsByItem::const_iterator c = coords_by_item.find (*i);
|
||||||
|
|
||||||
if (c == coords_by_item.end()) {
|
if (c == coords_by_item.end()) {
|
||||||
@ -237,7 +249,6 @@ Grid::reposition_children ()
|
|||||||
(*i)->set_position (Duple (col_dimens[c->second.x], row_dimens[c->second.y]));
|
(*i)->set_position (Duple (col_dimens[c->second.x], row_dimens[c->second.y]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_bounding_box_dirty = true;
|
_bounding_box_dirty = true;
|
||||||
reset_self ();
|
reset_self ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user