Reimplement menu using hippo and hook it up for the
activity menu.
This commit is contained in:
@@ -1,28 +1,15 @@
|
||||
from sugar.graphics.grid import Grid
|
||||
|
||||
class MenuStrategy:
|
||||
def get_menu_position(self, menu, grid_x1, grid_y1, grid_x2, grid_y2):
|
||||
grid = menu.get_grid()
|
||||
def get_menu_position(self, menu, x, y, width, height):
|
||||
grid = Grid()
|
||||
|
||||
[x1, y1] = grid.micro_to_macro(grid_x1, grid_y1)
|
||||
[x2, y2] = grid.micro_to_macro(grid_x2, grid_y2)
|
||||
[grid_x1, grid_y1] = grid.fit_point(x, y)
|
||||
[grid_x2, grid_y2] = grid.fit_point(x + width, y + height)
|
||||
|
||||
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
|
||||
menu_grid_x = grid_x1
|
||||
menu_grid_y = grid_y2
|
||||
|
||||
[grid_x, grid_y] = grid.macro_to_micro(x, y)
|
||||
[menu_x, menu_y] = grid.point(menu_grid_x, menu_grid_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]
|
||||
return [menu_x, menu_y]
|
||||
|
||||
+10
-10
@@ -3,9 +3,8 @@ import hippo
|
||||
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics.menuicon import MenuIcon
|
||||
from sugar.graphics.menu import Menu
|
||||
from sugar.graphics import style
|
||||
from sugar.canvas.Menu import Menu
|
||||
from sugar.canvas.IconItem import IconItem
|
||||
from view.frame.MenuStrategy import MenuStrategy
|
||||
import sugar
|
||||
|
||||
@@ -14,13 +13,14 @@ class ActivityMenu(Menu):
|
||||
ACTION_CLOSE = 2
|
||||
|
||||
def __init__(self, grid, activity_host):
|
||||
title = activity_host.get_title()
|
||||
Menu.__init__(self, grid, title)
|
||||
Menu.__init__(self, activity_host.get_title())
|
||||
|
||||
icon = IconItem(icon_name='stock-share-mesh')
|
||||
icon = CanvasIcon(icon_name='stock-share-mesh')
|
||||
style.apply_stylesheet(icon, 'menu-action-icon')
|
||||
self.add_action(icon, ActivityMenu.ACTION_SHARE)
|
||||
|
||||
icon = IconItem(icon_name='stock-close')
|
||||
icon = CanvasIcon(icon_name='stock-close')
|
||||
style.apply_stylesheet(icon, 'menu-action-icon')
|
||||
self.add_action(icon, ActivityMenu.ACTION_CLOSE)
|
||||
|
||||
class ActivityIcon(MenuIcon):
|
||||
@@ -64,22 +64,22 @@ class ZoomBox(hippo.CanvasBox):
|
||||
icon = CanvasIcon(icon_name='stock-zoom-mesh')
|
||||
style.apply_stylesheet(icon, 'frame-zoom-icon')
|
||||
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_MESH)
|
||||
self.append(icon, 0)
|
||||
self.append(icon)
|
||||
|
||||
icon = CanvasIcon(icon_name='stock-zoom-friends')
|
||||
style.apply_stylesheet(icon, 'frame-zoom-icon')
|
||||
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_FRIENDS)
|
||||
self.append(icon, 0)
|
||||
self.append(icon)
|
||||
|
||||
icon = CanvasIcon(icon_name='stock-zoom-home')
|
||||
style.apply_stylesheet(icon, 'frame-zoom-icon')
|
||||
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_HOME)
|
||||
self.append(icon, 0)
|
||||
self.append(icon)
|
||||
|
||||
icon = CanvasIcon(icon_name='stock-zoom-activity')
|
||||
style.apply_stylesheet(icon, 'frame-zoom-icon')
|
||||
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_ACTIVITY)
|
||||
self.append(icon, 0)
|
||||
self.append(icon)
|
||||
|
||||
shell.connect('activity-changed', self._activity_changed_cb)
|
||||
self._set_current_activity(shell.get_current_activity())
|
||||
|
||||
Reference in New Issue
Block a user