More stylification
This commit is contained in:
parent
0bd96b3987
commit
847f69fce7
@ -1,4 +1,5 @@
|
|||||||
import gtk
|
import gtk
|
||||||
|
import hippo
|
||||||
|
|
||||||
from sugar.graphics.iconcolor import IconColor
|
from sugar.graphics.iconcolor import IconColor
|
||||||
|
|
||||||
@ -10,6 +11,13 @@ _medium_icon_size = _standard_icon_size * 1.5
|
|||||||
_large_icon_size = _standard_icon_size * 2.0
|
_large_icon_size = _standard_icon_size * 2.0
|
||||||
_xlarge_icon_size = _standard_icon_size * 3.0
|
_xlarge_icon_size = _standard_icon_size * 3.0
|
||||||
|
|
||||||
|
_space_unit = 9 * _screen_factor
|
||||||
|
_separator_thickness = 3 * _screen_factor
|
||||||
|
|
||||||
|
def _font_description(style, relative_size):
|
||||||
|
base_size = 18 * _screen_factor
|
||||||
|
return '%s %dpx' % (style, int(base_size * relative_size))
|
||||||
|
|
||||||
frame_ActivityIcon = {
|
frame_ActivityIcon = {
|
||||||
'color' : IconColor('white'),
|
'color' : IconColor('white'),
|
||||||
'size' : _standard_icon_size
|
'size' : _standard_icon_size
|
||||||
@ -23,6 +31,22 @@ frame_ZoomIcon = {
|
|||||||
'size' : _standard_icon_size
|
'size' : _standard_icon_size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu = {
|
||||||
|
'background_color' : 0x000000FF,
|
||||||
|
'spacing' : _space_unit,
|
||||||
|
'padding' : _space_unit
|
||||||
|
}
|
||||||
|
|
||||||
|
menu_Title = {
|
||||||
|
'color' : 0xFFFFFFFF,
|
||||||
|
'font' : _font_description('Bold', 1.2)
|
||||||
|
}
|
||||||
|
|
||||||
|
menu_Separator = {
|
||||||
|
'background_color' : 0xFFFFFFFF,
|
||||||
|
'box_height' : _separator_thickness
|
||||||
|
}
|
||||||
|
|
||||||
menu_ActionIcon = {
|
menu_ActionIcon = {
|
||||||
'size' : _standard_icon_size
|
'size' : _standard_icon_size
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,12 @@ class Menu(gtk.Window):
|
|||||||
self.add(canvas)
|
self.add(canvas)
|
||||||
canvas.show()
|
canvas.show()
|
||||||
|
|
||||||
self._root = hippo.CanvasBox(background_color=0x000000FF,
|
self._root = hippo.CanvasBox()
|
||||||
spacing=6)
|
style.apply_stylesheet(self._root, 'menu')
|
||||||
canvas.set_root(self._root)
|
canvas.set_root(self._root)
|
||||||
|
|
||||||
text = hippo.CanvasText(text=title, color=0xFFFFFFFF)
|
text = hippo.CanvasText(text=title)
|
||||||
|
style.apply_stylesheet(text, 'menu.Title')
|
||||||
self._root.append(text)
|
self._root.append(text)
|
||||||
|
|
||||||
if content_box:
|
if content_box:
|
||||||
@ -30,6 +31,14 @@ class Menu(gtk.Window):
|
|||||||
self._root.append(separator)
|
self._root.append(separator)
|
||||||
self._root.append(content_box)
|
self._root.append(content_box)
|
||||||
|
|
||||||
|
self._action_box = None
|
||||||
|
|
||||||
|
def _create_separator(self):
|
||||||
|
separator = hippo.CanvasBox()
|
||||||
|
style.apply_stylesheet(separator, 'menu.Separator')
|
||||||
|
return separator
|
||||||
|
|
||||||
|
def _create_action_box(self):
|
||||||
separator = self._create_separator()
|
separator = self._create_separator()
|
||||||
self._root.append(separator)
|
self._root.append(separator)
|
||||||
|
|
||||||
@ -37,13 +46,10 @@ class Menu(gtk.Window):
|
|||||||
orientation=hippo.ORIENTATION_HORIZONTAL)
|
orientation=hippo.ORIENTATION_HORIZONTAL)
|
||||||
self._root.append(self._action_box)
|
self._root.append(self._action_box)
|
||||||
|
|
||||||
def _create_separator(self):
|
|
||||||
separator = hippo.CanvasBox(background_color=0xFFFFFFFF,
|
|
||||||
border_left=6, border_right=6,
|
|
||||||
box_height=2)
|
|
||||||
return separator
|
|
||||||
|
|
||||||
def add_action(self, icon, action_id):
|
def add_action(self, icon, action_id):
|
||||||
|
if not self._action_box:
|
||||||
|
self._create_action_box()
|
||||||
|
|
||||||
style.apply_stylesheet(icon, 'menu.ActionIcon')
|
style.apply_stylesheet(icon, 'menu.ActionIcon')
|
||||||
icon.connect('activated', self._action_clicked_cb, action_id)
|
icon.connect('activated', self._action_clicked_cb, action_id)
|
||||||
self._action_box.append(icon)
|
self._action_box.append(icon)
|
||||||
|
Loading…
Reference in New Issue
Block a user