Keep popups out of the frame
This commit is contained in:
parent
e12881e36b
commit
3ee23b3a92
@ -10,10 +10,14 @@ class FriendIcon(IconItem):
|
||||
self._shell = shell
|
||||
self._friend = friend
|
||||
self._popup = None
|
||||
self._popup_distance = 0
|
||||
|
||||
self.connect('popup', self._popup_cb)
|
||||
self.connect('popdown', self._popdown_cb)
|
||||
|
||||
def set_popup_distance(self, distance):
|
||||
self._popup_distance = distance
|
||||
|
||||
def get_friend(self):
|
||||
return self._friend
|
||||
|
||||
@ -23,13 +27,15 @@ class FriendIcon(IconItem):
|
||||
if not self._popup:
|
||||
self._popup = FriendPopup(self._shell, grid, icon.get_friend())
|
||||
|
||||
distance = self._popup_distance
|
||||
|
||||
[grid_x1, grid_y1] = grid.convert_from_screen(x1, y1)
|
||||
[grid_x2, grid_y2] = grid.convert_from_screen(x2, y2)
|
||||
|
||||
if grid_x2 + self._popup.get_width() + 1 > Grid.ROWS:
|
||||
grid_x = grid_x1 - self._popup.get_width() + 1
|
||||
if grid_x2 + self._popup.get_width() + distance > Grid.ROWS:
|
||||
grid_x = grid_x1 - self._popup.get_width() - distance
|
||||
else:
|
||||
grid_x = grid_x2 - 1
|
||||
grid_x = grid_x2 + distance
|
||||
|
||||
grid_y = grid_y1
|
||||
|
||||
|
@ -26,6 +26,7 @@ class RightPanel(CanvasBox):
|
||||
def add(self, buddy):
|
||||
friend = Friend(buddy.get_name(), buddy.get_color())
|
||||
icon = FriendIcon(self._shell, friend)
|
||||
icon.set_popup_distance(1)
|
||||
self.set_constraints(icon, 3, 3)
|
||||
self.add_child(icon)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user