25
25
Rectangle *vspc_rect;
28
Record(SPItem *i, NR::Point m, Rectangle *r)
28
Record(SPItem *i, Geom::Point m, Rectangle *r)
29
29
: item(i), midpoint(m), vspc_rect(r) {}
42
42
std::vector<Record> records;
43
43
std::vector<Rectangle *> rs;
45
NR::Point const gap(xGap, yGap);
45
Geom::Point const gap(xGap, yGap);
46
46
for (std::list<SPItem *>::iterator it(selected.begin());
47
47
it != selected.end();
50
using NR::X; using NR::Y;
51
NR::Maybe<NR::Rect> item_box(sp_item_bbox_desktop(*it));
50
using Geom::X; using Geom::Y;
51
Geom::OptRect item_box(sp_item_bbox_desktop(*it));
53
NR::Point min(item_box->min() - .5*gap);
54
NR::Point max(item_box->max() + .5*gap);
53
Geom::Point min(item_box->min() - .5*gap);
54
Geom::Point max(item_box->max() + .5*gap);
55
// A negative gap is allowed, but will lead to problems when the gap is larger than
56
// the bounding box (in either X or Y direction, or both); min will have become max
57
// now, which cannot be handled by Rectangle() which is called below. And how will
58
// removeRectangleOverlap handle such a case?
59
// That's why we will enforce some boundaries on min and max here:
60
if (max[X] < min[X]) {
61
min[X] = max[X] = (min[X] + max[X])/2;
63
if (max[Y] < min[Y]) {
64
min[Y] = max[Y] = (min[Y] + max[Y])/2;
55
66
Rectangle *vspc_rect = new Rectangle(min[X], max[X], min[Y], max[Y]);
56
67
records.push_back(Record(*it, item_box->midpoint(), vspc_rect));
57
68
rs.push_back(vspc_rect);
64
75
it != records.end();
67
NR::Point const curr = it->midpoint;
68
NR::Point const dest(it->vspc_rect->getCentreX(),
78
Geom::Point const curr = it->midpoint;
79
Geom::Point const dest(it->vspc_rect->getCentreX(),
69
80
it->vspc_rect->getCentreY());
70
sp_item_move_rel(it->item, NR::translate(dest - curr));
81
sp_item_move_rel(it->item, Geom::Translate(dest - curr));
71
82
delete it->vspc_rect;