Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-07 12:33:08 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-07 12:33:08 (GMT)
commit8c3ac8960fdee7e4bcc8b0bf813ec5d84eb7bcc9 (patch)
treecca83d013899a3e0c9731902e7a450b432381d9b /sugar
parent55f82602c4e7dfdaa4e402d1166bbd2bf75d1d27 (diff)
Spread box cleanups and fixes
Diffstat (limited to 'sugar')
-rw-r--r--sugar/graphics/spreadbox.py29
1 files changed, 12 insertions, 17 deletions
diff --git a/sugar/graphics/spreadbox.py b/sugar/graphics/spreadbox.py
index b9d07d4..6e96e53 100644
--- a/sugar/graphics/spreadbox.py
+++ b/sugar/graphics/spreadbox.py
@@ -19,21 +19,6 @@ class SpreadBox(hippo.CanvasBox, hippo.CanvasItem):
def add(self, item):
self._items_to_position.append(item)
self.append(item, hippo.PACK_FIXED)
- if self._spread_on_add:
- self.spread()
-
- def spread(self):
- self._spread_on_add = True
-
- [width, height] = self.get_allocation()
- for item in self._items_to_position:
- x = int(random.random() * width)
- y = int(random.random() * height)
-
- [x, y] = self._clamp_position(item, x, y)
- self.move(item, x, y)
-
- self._items_to_position = []
def _get_distance(self, icon1, icon2):
[icon1_x, icon1_y] = self.get_position(icon1)
@@ -57,8 +42,7 @@ class SpreadBox(hippo.CanvasBox, hippo.CanvasItem):
x = max(0, x)
y = max(0, y)
- item_w = icon.get_width_request()
- item_h = icon.get_height_request(item_w)
+ [item_w, item_h] = icon.get_request()
[box_w, box_h] = self.get_allocation()
x = min(box_w - item_w, x)
@@ -94,6 +78,17 @@ class SpreadBox(hippo.CanvasBox, hippo.CanvasItem):
def do_allocate(self, width, height):
hippo.CanvasBox.do_allocate(self, width, height)
+ for item in self._items_to_position:
+ [item_w, item_h] = item.get_request()
+
+ x = int(random.random() * width - item_w)
+ y = int(random.random() * height - item_h)
+
+ [x, y] = self._clamp_position(item, x, y)
+ self.move(item, x, y)
+
+ self._items_to_position = []
+
tries = 10
self._spread_icons()
while not self._stable and tries > 0: