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
|
||||
|
||||
from sugar.graphics.spreadlayout import SpreadLayout
|
||||
from sugar.graphics import style
|
||||
from view.home.MyIcon import MyIcon
|
||||
from view.BuddyActivityView import BuddyActivityView
|
||||
|
||||
@ -16,7 +17,8 @@ class FriendsBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
self._layout = SpreadLayout()
|
||||
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)
|
||||
|
||||
friends = self._shell.get_model().get_friends()
|
||||
|
@ -2,6 +2,8 @@ import hippo
|
||||
|
||||
from view.home.activitiesdonut import ActivitiesDonut
|
||||
from view.home.MyIcon import MyIcon
|
||||
from sugar.graphics.grid import Grid
|
||||
from sugar.graphics import style
|
||||
|
||||
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
__gtype_name__ = 'SugarHomeBox'
|
||||
@ -10,10 +12,13 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff,
|
||||
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._my_icon = MyIcon(120)
|
||||
self._my_icon = MyIcon()
|
||||
style.apply_stylesheet(self._my_icon, 'home.MyIcon')
|
||||
self.append(self._my_icon, hippo.PACK_FIXED)
|
||||
|
||||
def do_allocate(self, width, height):
|
||||
|
@ -1,10 +1,8 @@
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics.iconcolor import IconColor
|
||||
import conf
|
||||
|
||||
class MyIcon(CanvasIcon):
|
||||
def __init__(self, size):
|
||||
def __init__(self):
|
||||
profile = conf.get_profile()
|
||||
|
||||
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
|
||||
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import style
|
||||
|
||||
class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
||||
__gtype_name__ = 'SugarActivitiesDonut'
|
||||
@ -28,7 +29,8 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
||||
icon_name = activity.get_icon_name()
|
||||
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)
|
||||
self.append(icon, hippo.PACK_FIXED)
|
||||
|
||||
|
@ -2,20 +2,35 @@ import gtk
|
||||
|
||||
from sugar.graphics.iconcolor import IconColor
|
||||
|
||||
if gtk.gdk.screen_width() == 1200:
|
||||
_medium_icon_size = 75
|
||||
else:
|
||||
_medium_icon_size = 50
|
||||
_screen_factor = gtk.gdk.screen_width() / 1200.0
|
||||
|
||||
_standard_icon_size = int(75.0 * _screen_factor)
|
||||
_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 = {
|
||||
'color' : IconColor('white'),
|
||||
'size' : _standard_icon_size
|
||||
}
|
||||
|
||||
ring_ActivityIcon = {
|
||||
'size' : _medium_icon_size
|
||||
}
|
||||
|
||||
frame_ZoomIcon = {
|
||||
'size' : _medium_icon_size
|
||||
'size' : _standard_icon_size
|
||||
}
|
||||
|
||||
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,
|
||||
grid_w * self._factor, grid_h * self._factor]
|
||||
|
||||
def dimension(self, grid_dimension):
|
||||
return grid_dimension * self._factor
|
||||
|
||||
def fit_point(self, x, y):
|
||||
return [int(x / self._factor), int(y / self._factor)]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user