diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-07-05 22:46:12 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-07-05 22:46:12 (GMT) |
commit | f1ecb99207f00887ba51cc3d1303247dabc335b2 (patch) | |
tree | 22dcdd2b48856b90cf74a763a03f2b5568231a5c /sugar/graphics | |
parent | cc11d5ebd5777ca258f2f821daa493f6d2f235e5 (diff) |
Complete transition to new spread layout.
Diffstat (limited to 'sugar/graphics')
-rw-r--r-- | sugar/graphics/spreadlayout.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sugar/graphics/spreadlayout.py b/sugar/graphics/spreadlayout.py index d85e69b..ad2a163 100644 --- a/sugar/graphics/spreadlayout.py +++ b/sugar/graphics/spreadlayout.py @@ -82,7 +82,11 @@ class _Grid(gobject.GObject): self._add_weight(child.grid_rect) def _move_child(self, child, new_rect): + self._remove_weight(child.grid_rect) + self._add_weight(new_rect) + child.grid_rect = new_rect + self.emit('child-changed', child) def _shift_child(self, child): @@ -128,14 +132,20 @@ class _Grid(gobject.GObject): return (len(self._collisions) > 0) def _detect_collisions(self, child): + collision_found = False for c in self._children: intersection = child.grid_rect.intersect(c.grid_rect) if c != child and intersection.width > 0: if c not in self._collisions: + collision_found = True self._collisions.append(c) - if not self._collisions_sid: - self._collisions_sid = \ - gobject.idle_add(self._solve_collisions) + + if collision_found: + if child not in self._collisions: + self._collisions.append(child) + +# if len(self._collisions) and not self._collisions_sid: +# self._collisions_sid = gobject.idle_add(self._solve_collisions) def _add_weight(self, rect): for i in range(rect.x, rect.x + rect.width): @@ -153,7 +163,7 @@ class _Grid(gobject.GObject): for i in range(rect.x, rect.x + rect.width): for j in range(rect.y, rect.y + rect.height): weight += self[j, i] - + return weight def __getitem__(self, (row, col)): |