Remove several hardcoded sizes, substitute them with stylesheets.
This commit is contained in:
parent
b3abf30dec
commit
250060b7f8
@ -3,6 +3,7 @@ import random
|
|||||||
import hippo
|
import hippo
|
||||||
|
|
||||||
from sugar.graphics.spreadlayout import SpreadLayout
|
from sugar.graphics.spreadlayout import SpreadLayout
|
||||||
|
from sugar.graphics import style
|
||||||
from view.home.MyIcon import MyIcon
|
from view.home.MyIcon import MyIcon
|
||||||
from view.BuddyActivityView import BuddyActivityView
|
from view.BuddyActivityView import BuddyActivityView
|
||||||
|
|
||||||
@ -16,7 +17,8 @@ class FriendsBox(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
self._layout = SpreadLayout()
|
self._layout = SpreadLayout()
|
||||||
self._friends = {}
|
self._friends = {}
|
||||||
|
|
||||||
self._my_icon = MyIcon(112)
|
self._my_icon = MyIcon()
|
||||||
|
style.apply_stylesheet(self._my_icon, 'friends.MyIcon')
|
||||||
self.append(self._my_icon, hippo.PACK_FIXED)
|
self.append(self._my_icon, hippo.PACK_FIXED)
|
||||||
|
|
||||||
friends = self._shell.get_model().get_friends()
|
friends = self._shell.get_model().get_friends()
|
||||||
|
@ -2,6 +2,8 @@ import hippo
|
|||||||
|
|
||||||
from view.home.activitiesdonut import ActivitiesDonut
|
from view.home.activitiesdonut import ActivitiesDonut
|
||||||
from view.home.MyIcon import MyIcon
|
from view.home.MyIcon import MyIcon
|
||||||
|
from sugar.graphics.grid import Grid
|
||||||
|
from sugar.graphics import style
|
||||||
|
|
||||||
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||||
__gtype_name__ = 'SugarHomeBox'
|
__gtype_name__ = 'SugarHomeBox'
|
||||||
@ -10,10 +12,13 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff,
|
hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff,
|
||||||
yalign=2)
|
yalign=2)
|
||||||
|
|
||||||
donut = ActivitiesDonut(shell, box_width=300, box_height=300)
|
grid = Grid()
|
||||||
|
donut = ActivitiesDonut(shell, box_width=grid.dimension(7),
|
||||||
|
box_height=grid.dimension(7))
|
||||||
self.append(donut)
|
self.append(donut)
|
||||||
|
|
||||||
self._my_icon = MyIcon(120)
|
self._my_icon = MyIcon()
|
||||||
|
style.apply_stylesheet(self._my_icon, 'home.MyIcon')
|
||||||
self.append(self._my_icon, hippo.PACK_FIXED)
|
self.append(self._my_icon, hippo.PACK_FIXED)
|
||||||
|
|
||||||
def do_allocate(self, width, height):
|
def do_allocate(self, width, height):
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
from sugar.graphics.canvasicon import CanvasIcon
|
from sugar.graphics.canvasicon import CanvasIcon
|
||||||
from sugar.graphics.iconcolor import IconColor
|
|
||||||
import conf
|
import conf
|
||||||
|
|
||||||
class MyIcon(CanvasIcon):
|
class MyIcon(CanvasIcon):
|
||||||
def __init__(self, size):
|
def __init__(self):
|
||||||
profile = conf.get_profile()
|
profile = conf.get_profile()
|
||||||
|
|
||||||
CanvasIcon.__init__(self, icon_name='stock-buddy',
|
CanvasIcon.__init__(self, icon_name='stock-buddy',
|
||||||
color=profile.get_color(), size=size)
|
color=profile.get_color())
|
||||||
|
@ -2,6 +2,7 @@ import hippo
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
from sugar.graphics.canvasicon import CanvasIcon
|
from sugar.graphics.canvasicon import CanvasIcon
|
||||||
|
from sugar.graphics import style
|
||||||
|
|
||||||
class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
||||||
__gtype_name__ = 'SugarActivitiesDonut'
|
__gtype_name__ = 'SugarActivitiesDonut'
|
||||||
@ -28,7 +29,8 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
icon_name = activity.get_icon_name()
|
icon_name = activity.get_icon_name()
|
||||||
icon_color = activity.get_icon_color()
|
icon_color = activity.get_icon_color()
|
||||||
|
|
||||||
icon = CanvasIcon(icon_name=icon_name, color=icon_color, size=75)
|
icon = CanvasIcon(icon_name=icon_name, color=icon_color)
|
||||||
|
style.apply_stylesheet(icon, 'ring.ActivityIcon')
|
||||||
icon.connect('activated', self.__activity_icon_clicked_cb, activity)
|
icon.connect('activated', self.__activity_icon_clicked_cb, activity)
|
||||||
self.append(icon, hippo.PACK_FIXED)
|
self.append(icon, hippo.PACK_FIXED)
|
||||||
|
|
||||||
|
@ -2,20 +2,35 @@ import gtk
|
|||||||
|
|
||||||
from sugar.graphics.iconcolor import IconColor
|
from sugar.graphics.iconcolor import IconColor
|
||||||
|
|
||||||
if gtk.gdk.screen_width() == 1200:
|
_screen_factor = gtk.gdk.screen_width() / 1200.0
|
||||||
_medium_icon_size = 75
|
|
||||||
else:
|
_standard_icon_size = int(75.0 * _screen_factor)
|
||||||
_medium_icon_size = 50
|
_small_icon_size = _standard_icon_size * 0.5
|
||||||
|
_medium_icon_size = _standard_icon_size * 1.5
|
||||||
|
_large_icon_size = _standard_icon_size * 2.0
|
||||||
|
_xlarge_icon_size = _standard_icon_size * 3.0
|
||||||
|
|
||||||
frame_ActivityIcon = {
|
frame_ActivityIcon = {
|
||||||
'color' : IconColor('white'),
|
'color' : IconColor('white'),
|
||||||
|
'size' : _standard_icon_size
|
||||||
|
}
|
||||||
|
|
||||||
|
ring_ActivityIcon = {
|
||||||
'size' : _medium_icon_size
|
'size' : _medium_icon_size
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_ZoomIcon = {
|
frame_ZoomIcon = {
|
||||||
'size' : _medium_icon_size
|
'size' : _standard_icon_size
|
||||||
}
|
}
|
||||||
|
|
||||||
menu_ActionIcon = {
|
menu_ActionIcon = {
|
||||||
'size' : _medium_icon_size
|
'size' : _standard_icon_size
|
||||||
|
}
|
||||||
|
|
||||||
|
home_MyIcon = {
|
||||||
|
'size' : _xlarge_icon_size
|
||||||
|
}
|
||||||
|
|
||||||
|
friends_MyIcon = {
|
||||||
|
'size' : _large_icon_size
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,9 @@ class Grid(object):
|
|||||||
return [grid_x * self._factor, grid_y * self._factor,
|
return [grid_x * self._factor, grid_y * self._factor,
|
||||||
grid_w * self._factor, grid_h * self._factor]
|
grid_w * self._factor, grid_h * self._factor]
|
||||||
|
|
||||||
|
def dimension(self, grid_dimension):
|
||||||
|
return grid_dimension * self._factor
|
||||||
|
|
||||||
def fit_point(self, x, y):
|
def fit_point(self, x, y):
|
||||||
return [int(x / self._factor), int(y / self._factor)]
|
return [int(x / self._factor), int(y / self._factor)]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user