diff options
Diffstat (limited to 'shell/view/frame/MenuStrategy.py')
-rw-r--r-- | shell/view/frame/MenuStrategy.py | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/shell/view/frame/MenuStrategy.py b/shell/view/frame/MenuStrategy.py index 314cb04..0519d23 100644 --- a/shell/view/frame/MenuStrategy.py +++ b/shell/view/frame/MenuStrategy.py @@ -1,28 +1,15 @@ -class MenuStrategy: - def get_menu_position(self, menu, grid_x1, grid_y1, grid_x2, grid_y2): - grid = menu.get_grid() +from sugar.graphics.grid import Grid - [x1, y1] = grid.micro_to_macro(grid_x1, grid_y1) - [x2, y2] = grid.micro_to_macro(grid_x2, grid_y2) +class MenuStrategy: + def get_menu_position(self, menu, x, y, width, height): + grid = Grid() - 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_x1, grid_y1] = grid.fit_point(x, y) + [grid_x2, grid_y2] = grid.fit_point(x + width, y + height) - [grid_x, grid_y] = grid.macro_to_micro(x, y) + menu_grid_x = grid_x1 + menu_grid_y = grid_y2 - if x2 == grid.get_macro_cols(): - grid_x -= menu.get_width() - elif y2 == grid.get_macro_rows(): - grid_y -= menu.get_height() + [menu_x, menu_y] = grid.point(menu_grid_x, menu_grid_y) - return [grid_x, grid_y] + return [menu_x, menu_y] |