Keep popups out of the frame

This commit is contained in:
Marco Pesenti Gritti 2006-09-14 21:15:48 +02:00
parent e12881e36b
commit 3ee23b3a92
2 changed files with 10 additions and 3 deletions

View File

@ -10,10 +10,14 @@ class FriendIcon(IconItem):
self._shell = shell self._shell = shell
self._friend = friend self._friend = friend
self._popup = None self._popup = None
self._popup_distance = 0
self.connect('popup', self._popup_cb) self.connect('popup', self._popup_cb)
self.connect('popdown', self._popdown_cb) self.connect('popdown', self._popdown_cb)
def set_popup_distance(self, distance):
self._popup_distance = distance
def get_friend(self): def get_friend(self):
return self._friend return self._friend
@ -23,13 +27,15 @@ class FriendIcon(IconItem):
if not self._popup: if not self._popup:
self._popup = FriendPopup(self._shell, grid, icon.get_friend()) self._popup = FriendPopup(self._shell, grid, icon.get_friend())
distance = self._popup_distance
[grid_x1, grid_y1] = grid.convert_from_screen(x1, y1) [grid_x1, grid_y1] = grid.convert_from_screen(x1, y1)
[grid_x2, grid_y2] = grid.convert_from_screen(x2, y2) [grid_x2, grid_y2] = grid.convert_from_screen(x2, y2)
if grid_x2 + self._popup.get_width() + 1 > Grid.ROWS: if grid_x2 + self._popup.get_width() + distance > Grid.ROWS:
grid_x = grid_x1 - self._popup.get_width() + 1 grid_x = grid_x1 - self._popup.get_width() - distance
else: else:
grid_x = grid_x2 - 1 grid_x = grid_x2 + distance
grid_y = grid_y1 grid_y = grid_y1

View File

@ -26,6 +26,7 @@ class RightPanel(CanvasBox):
def add(self, buddy): def add(self, buddy):
friend = Friend(buddy.get_name(), buddy.get_color()) friend = Friend(buddy.get_name(), buddy.get_color())
icon = FriendIcon(self._shell, friend) icon = FriendIcon(self._shell, friend)
icon.set_popup_distance(1)
self.set_constraints(icon, 3, 3) self.set_constraints(icon, 3, 3)
self.add_child(icon) self.add_child(icon)