diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-08-29 15:18:16 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-08-29 15:18:16 (GMT) |
commit | fa8ad923228a39c265616c44849db4527e5a284f (patch) | |
tree | c506175851d659ac7b22ed4539432099b242ac02 | |
parent | fddc1f56af30cc04b313bd433a7d94e2ef366339 (diff) |
Take icon size and borders into account
-rw-r--r-- | shell/home/IconLayout.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/shell/home/IconLayout.py b/shell/home/IconLayout.py index e0e2e66..37b519d 100644 --- a/shell/home/IconLayout.py +++ b/shell/home/IconLayout.py @@ -19,10 +19,12 @@ class IconLayout: def remove_icon(self, icon): self._icons.remove(icon) - def _is_valid_position(self, x, y): - if x < self._x1 or x > self._x2: + def _is_valid_position(self, icon, x, y): + h_border = icon.props.width + 4 + v_border = icon.props.height + 4 + if x < self._x1 - h_border or x > self._x2 + h_border: return True - if y < self._y1 or y > self._y2: + if y < self._y1 - v_border or y > self._y2 + v_border: return True return False @@ -30,7 +32,7 @@ class IconLayout: while True: x = random.random() * self._width y = random.random() * self._height - if self._is_valid_position(x, y): + if self._is_valid_position(icon, x, y): break icon.props.x = x |