diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-09-24 20:55:13 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-09-24 20:55:13 (GMT) |
commit | 3f73da05492dc22e04b24a12e48c6844b5cd9726 (patch) | |
tree | 3471f8834719256e7ccf443687e285e2aa22962c /shell | |
parent | eac58dcfede3b17163ca625813f55dbaf1d72d38 (diff) |
Some cleanups of the IconLayout
Diffstat (limited to 'shell')
-rw-r--r-- | shell/view/home/FriendsGroup.py | 2 | ||||
-rw-r--r-- | shell/view/home/IconLayout.py | 30 | ||||
-rw-r--r-- | shell/view/home/MeshGroup.py | 2 |
3 files changed, 12 insertions, 22 deletions
diff --git a/shell/view/home/FriendsGroup.py b/shell/view/home/FriendsGroup.py index 1c2ea3a..acf4f93 100644 --- a/shell/view/home/FriendsGroup.py +++ b/shell/view/home/FriendsGroup.py @@ -12,7 +12,7 @@ class FriendsGroup(goocanvas.Group): self._shell = shell self._menu_shell = menu_shell - self._icon_layout = IconLayout(1200, 900) + self._icon_layout = IconLayout(shell.get_grid()) self._friends = {} me = MyIcon(112) diff --git a/shell/view/home/IconLayout.py b/shell/view/home/IconLayout.py index eedced8..276668e 100644 --- a/shell/view/home/IconLayout.py +++ b/shell/view/home/IconLayout.py @@ -1,10 +1,9 @@ import random class IconLayout: - def __init__(self, width, height): + def __init__(self, grid): self._icons = [] - self._width = width - self._height = height + self._grid = grid def add_icon(self, icon): self._icons.append(icon) @@ -13,22 +12,13 @@ class IconLayout: def remove_icon(self, icon): self._icons.remove(icon) - def _is_valid_position(self, icon, x, y): - icon_size = icon.props.size - border = 20 - - if not (border < x < self._width - icon_size - border and \ - border < y < self._height - icon_size - border): - return False - - return True - def _layout_icon(self, icon): - while True: - x = random.random() * self._width - y = random.random() * self._height - if self._is_valid_position(icon, x, y): - break + [x1, y1] = self._grid.convert_to_canvas(1, 1) + [x2, y2] = self._grid.convert_to_canvas(78, 59) + size = icon.props.size + + x = random.random() * (x2 - x1 - size) + y = random.random() * (y2 - y1 - size) - icon.props.x = x - icon.props.y = y + icon.props.x = x + x1 + icon.props.y = y + y1 diff --git a/shell/view/home/MeshGroup.py b/shell/view/home/MeshGroup.py index fee9079..4f523de 100644 --- a/shell/view/home/MeshGroup.py +++ b/shell/view/home/MeshGroup.py @@ -37,7 +37,7 @@ class MeshGroup(goocanvas.Group): self._shell = shell - self._icon_layout = IconLayout(1200, 900) + self._icon_layout = IconLayout(shell.get_grid()) self._activities = {} self._pservice = PresenceService.get_instance() |