From f1ecb99207f00887ba51cc3d1303247dabc335b2 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 05 Jul 2007 22:46:12 +0000 Subject: Complete transition to new spread layout. --- (limited to 'sugar/graphics/spreadlayout.py') 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)): -- cgit v0.9.1