diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-09-16 23:05:59 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-09-16 23:05:59 (GMT) |
commit | 89e2f5be91803bf99fcb326f4b5dd51200b7211a (patch) | |
tree | 1c220a04044fc5c3b4007adfe06dbf1e8a9806a6 /shell | |
parent | f77046e76a090f3ca4623064d0734b8e3c78f90a (diff) |
Rework menu positioning. Cleanups.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/view/Makefile.am | 2 | ||||
-rw-r--r-- | shell/view/frame/Makefile.am | 3 | ||||
-rw-r--r-- | shell/view/frame/MenuStrategy.py | 28 | ||||
-rw-r--r-- | shell/view/frame/RightPanel.py | 3 | ||||
-rw-r--r-- | shell/view/frame/TopPanel.py | 3 |
5 files changed, 36 insertions, 3 deletions
diff --git a/shell/view/Makefile.am b/shell/view/Makefile.am index 4b1c901..d291cf3 100644 --- a/shell/view/Makefile.am +++ b/shell/view/Makefile.am @@ -7,5 +7,5 @@ sugar_PYTHON = \ ConsoleWindow.py \ FirstTimeDialog.py \ BuddyIcon.py \ - BuddyPopup.py \ + BuddyMenu.py \ Shell.py diff --git a/shell/view/frame/Makefile.am b/shell/view/frame/Makefile.am index a737e01..8d95114 100644 --- a/shell/view/frame/Makefile.am +++ b/shell/view/frame/Makefile.am @@ -5,4 +5,5 @@ sugar_PYTHON = \ PanelWindow.py \ Frame.py \ TopPanel.py \ - BottomPanel.py + BottomPanel.py \ + MenuStrategy.py diff --git a/shell/view/frame/MenuStrategy.py b/shell/view/frame/MenuStrategy.py new file mode 100644 index 0000000..314cb04 --- /dev/null +++ b/shell/view/frame/MenuStrategy.py @@ -0,0 +1,28 @@ +class MenuStrategy: + def get_menu_position(self, menu, grid_x1, grid_y1, grid_x2, grid_y2): + grid = menu.get_grid() + + [x1, y1] = grid.micro_to_macro(grid_x1, grid_y1) + [x2, y2] = grid.micro_to_macro(grid_x2, grid_y2) + + if x1 == 0: + x = x2 + y = y1 + elif x2 == grid.get_macro_cols(): + x = x1 + y = y1 + elif y2 == grid.get_macro_rows(): + x = x1 + y = y1 + else: + x = x1 + y = y2 + + [grid_x, grid_y] = grid.macro_to_micro(x, y) + + if x2 == grid.get_macro_cols(): + grid_x -= menu.get_width() + elif y2 == grid.get_macro_rows(): + grid_y -= menu.get_height() + + return [grid_x, grid_y] diff --git a/shell/view/frame/RightPanel.py b/shell/view/frame/RightPanel.py index 08f41e6..d238761 100644 --- a/shell/view/frame/RightPanel.py +++ b/shell/view/frame/RightPanel.py @@ -6,6 +6,7 @@ from sugar.canvas.CanvasBox import CanvasBox from sugar.presence import PresenceService from view.BuddyIcon import BuddyIcon from model.BuddyInfo import BuddyInfo +from view.frame.MenuStrategy import MenuStrategy class RightPanel(CanvasBox): def __init__(self, shell): @@ -25,7 +26,7 @@ class RightPanel(CanvasBox): def add(self, buddy): icon = BuddyIcon(self._shell, BuddyInfo(buddy)) - icon.set_menu_distance(1) + icon.set_menu_strategy(MenuStrategy()) self.set_constraints(icon, 3, 3) self.add_child(icon) diff --git a/shell/view/frame/TopPanel.py b/shell/view/frame/TopPanel.py index 5d18141..af07ad4 100644 --- a/shell/view/frame/TopPanel.py +++ b/shell/view/frame/TopPanel.py @@ -4,6 +4,7 @@ from sugar.canvas.CanvasBox import CanvasBox from sugar.canvas.IconItem import IconItem from sugar.canvas.MenuIcon import MenuIcon from sugar.canvas.Menu import Menu +from view.frame.MenuStrategy import MenuStrategy import sugar class ActivityMenu(Menu): @@ -27,6 +28,8 @@ class ActivityIcon(MenuIcon): MenuIcon.__init__(self, shell.get_grid(), icon_name=icon_name, color=icon_color) + self.set_menu_strategy(MenuStrategy()) + def create_menu(self): menu = ActivityMenu(self._shell.get_grid(), self._activity_host) menu.connect('action', self._action_cb) |