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-09 22:56:19 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-09 22:56:19 (GMT)
commit7fa1b02a8254609aeff5f33999b52662e820b492 (patch)
tree2d7622e2ad9d838f4bde67230beeadd8e449cb99 /sugar
parent067d60573e70dfbe714b57c479889d3d39e1eec0 (diff)
Fix size request calculation
Diffstat (limited to 'sugar')
-rw-r--r--sugar/graphics/snowflakebox.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/sugar/graphics/snowflakebox.py b/sugar/graphics/snowflakebox.py
index 86831f7..c9b73de 100644
--- a/sugar/graphics/snowflakebox.py
+++ b/sugar/graphics/snowflakebox.py
@@ -11,31 +11,39 @@ class SnowflakeBox(hippo.CanvasBox, hippo.CanvasItem):
__gtype_name__ = 'SugarSnowflakeBox'
def __init__(self, **kwargs):
hippo.CanvasBox.__init__(self, **kwargs)
-
self._root = None
- self._r = 0
def set_root(self, icon):
self._root = icon
+ def _get_center(self):
+ [width, height] = self.get_allocation()
+ return [width / 2, height / 2]
+
+ def _get_radius(self):
+ return _BASE_RADIUS + _CHILDREN_FACTOR * len(self.get_children())
+
def _layout_root(self):
[width, height] = self._root.get_allocation()
+ [cx, cy] = self._get_center()
- x = self._cx - (width / 2)
- y = self._cy - (height / 2)
+ x = cx - (width / 2)
+ y = cy - (height / 2)
self.move(self._root, int(x), int(y))
def _layout_child(self, child, index):
- r = self._r
+ r = self._get_radius()
if (len(self.get_children()) > 10):
r += _FLAKE_DISTANCE * (index % 3)
angle = 2 * math.pi / len(self.get_children()) * index
[width, height] = child.get_allocation()
- x = self._cx + math.cos(angle) * r - (width / 2)
- y = self._cy + math.sin(angle) * r - (height / 2)
+ [cx, cy] = self._get_center()
+
+ x = cx + math.cos(angle) * r - (width / 2)
+ y = cy + math.sin(angle) * r - (height / 2)
self.move(child, int(x), int(y))
@@ -49,7 +57,8 @@ class SnowflakeBox(hippo.CanvasBox, hippo.CanvasItem):
max_child_size = max (max_child_size, width)
max_child_size = max (max_child_size, height)
- return self._r * 2 + max_child_size + _FLAKE_DISTANCE * 2
+ return self._get_radius() * 2 + \
+ max_child_size + _FLAKE_DISTANCE * 2
def do_get_height_request(self, width):
hippo.CanvasBox.do_get_height_request(self, width)
@@ -58,10 +67,6 @@ class SnowflakeBox(hippo.CanvasBox, hippo.CanvasItem):
def do_allocate(self, width, height):
hippo.CanvasBox.do_allocate(self, width, height)
- self._cx = width / 2
- self._cy = height / 2
- self._r = _BASE_RADIUS + _CHILDREN_FACTOR * len(self.get_children())
-
self._layout_root()
index = 0