Make theme color accessors more descriptive; add mesh view zoom rects
This commit is contained in:
parent
4eb5a61276
commit
e366753ab0
@ -15,18 +15,18 @@ class Model(goocanvas.CanvasModelSimple):
|
||||
|
||||
root = self.get_root_item()
|
||||
|
||||
color = self._theme.get_home_colors()[2]
|
||||
color = self._theme.get_home_mesh_color()
|
||||
self._mesh_rect = goocanvas.Rect(width=1200, height=900,
|
||||
fill_color=color)
|
||||
root.add_child(self._mesh_rect)
|
||||
|
||||
color = self._theme.get_home_colors()[1]
|
||||
color = self._theme.get_home_friends_color()
|
||||
self._friends_rect = goocanvas.Rect(x=100, y=100, width=1000, height=700,
|
||||
line_width=0, fill_color=color,
|
||||
radius_x=30, radius_y=30)
|
||||
root.add_child(self._friends_rect)
|
||||
|
||||
color = self._theme.get_home_colors()[0]
|
||||
color = self._theme.get_home_activities_color()
|
||||
self._home_rect = goocanvas.Rect(x=400, y=300, width=400, height=300,
|
||||
line_width=0, fill_color=color,
|
||||
radius_x=30, radius_y=30)
|
||||
@ -37,12 +37,12 @@ class Model(goocanvas.CanvasModelSimple):
|
||||
|
||||
data_model.connect('friend-added', self.__friend_added_cb)
|
||||
|
||||
def __theme_changed_cb(self, theme, colors):
|
||||
color = self._theme.get_home_colors()[0]
|
||||
def __theme_changed_cb(self, theme):
|
||||
color = self._theme.get_home_activities_color()
|
||||
self._home_rect.set_property("fill-color", color)
|
||||
color = self._theme.get_home_colors()[1]
|
||||
color = self._theme.get_home_friends_color()
|
||||
self._friends_rect.set_property("fill-color", color)
|
||||
color = self._theme.get_home_colors()[2]
|
||||
color = self._theme.get_home_mesh_color()
|
||||
self._mesh_rect.set_property("fill-color", color)
|
||||
|
||||
def add_friend(self, friend):
|
||||
|
@ -46,12 +46,12 @@ class Background(goocanvas.Group):
|
||||
self._theme = Theme.get_instance()
|
||||
self._theme.connect("theme-changed", self.__theme_changed_cb)
|
||||
|
||||
color = self._theme.get_home_colors()[1]
|
||||
color = self._theme.get_home_friends_color()
|
||||
self._friends_rect = goocanvas.Rect(width=1200, height=900,
|
||||
fill_color=color)
|
||||
self.add_child(self._friends_rect)
|
||||
|
||||
color = self._theme.get_home_colors()[0]
|
||||
color = self._theme.get_home_activities_color()
|
||||
self._home_rect = goocanvas.Rect(x=100, y=100, width=1000, height=700,
|
||||
line_width=0, fill_color=color,
|
||||
radius_x=30, radius_y=30)
|
||||
@ -62,10 +62,10 @@ class Background(goocanvas.Group):
|
||||
font="Sans 21")
|
||||
self.add_child(item)
|
||||
|
||||
def __theme_changed_cb(self, theme, colors):
|
||||
color = self._theme.get_home_colors()[0]
|
||||
def __theme_changed_cb(self, theme):
|
||||
color = self._theme.get_home_activities_color()
|
||||
self._home_rect.set_property("fill-color", color)
|
||||
color = self._theme.get_home_colors()[1]
|
||||
color = self._theme.get_friends_colors()
|
||||
self._friends_rect.set_property("fill-color", color)
|
||||
|
||||
class Model(goocanvas.CanvasModelSimple):
|
||||
|
@ -6,6 +6,8 @@ from sugar.canvas.IconItem import IconItem
|
||||
from sugar.canvas.IconItem import IconColor
|
||||
from sugar import conf
|
||||
|
||||
import Theme
|
||||
|
||||
class ActivityItem(IconItem):
|
||||
def __init__(self, activity):
|
||||
registry = conf.get_activity_registry()
|
||||
@ -22,18 +24,36 @@ class ActivityItem(IconItem):
|
||||
class Model(goocanvas.CanvasModelSimple):
|
||||
def __init__(self, data_model):
|
||||
goocanvas.CanvasModelSimple.__init__(self)
|
||||
self._theme = Theme.get_instance()
|
||||
self._theme.connect("theme-changed", self.__theme_changed_cb)
|
||||
|
||||
root = self.get_root_item()
|
||||
|
||||
item = goocanvas.Rect(width=1200, height=900,
|
||||
fill_color="#d8d8d8")
|
||||
root.add_child(item)
|
||||
color = self._theme.get_home_mesh_color()
|
||||
self._mesh_rect = goocanvas.Rect(width=1200, height=900,
|
||||
fill_color=color)
|
||||
root.add_child(self._mesh_rect)
|
||||
|
||||
color = self._theme.get_home_friends_color()
|
||||
self._friends_rect = goocanvas.Rect(x=350, y=280, width=500, height=340,
|
||||
line_width=0, fill_color=color,
|
||||
radius_x=30, radius_y=30)
|
||||
root.add_child(self._friends_rect)
|
||||
|
||||
color = self._theme.get_home_activities_color()
|
||||
self._home_rect = goocanvas.Rect(x=480, y=360, width=240, height=180,
|
||||
line_width=0, fill_color=color,
|
||||
radius_x=30, radius_y=30)
|
||||
root.add_child(self._home_rect)
|
||||
|
||||
for activity in data_model:
|
||||
self.add_activity(activity)
|
||||
|
||||
data_model.connect('activity-added', self.__activity_added_cb)
|
||||
|
||||
def __theme_changed_cb(self, theme):
|
||||
pass
|
||||
|
||||
def add_activity(self, activity):
|
||||
root = self.get_root_item()
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
import gobject
|
||||
|
||||
|
||||
|
||||
class Theme(gobject.GObject):
|
||||
__gsignals__ = {
|
||||
'theme-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
@ -37,9 +39,14 @@ class Theme(gobject.GObject):
|
||||
if updated:
|
||||
self.emit('theme-changed')
|
||||
|
||||
def get_home_colors(self):
|
||||
return self.__colors[self._cur_theme]
|
||||
def get_home_activities_color(self):
|
||||
return self.__colors[self._cur_theme][0]
|
||||
|
||||
def get_home_friends_color(self):
|
||||
return self.__colors[self._cur_theme][1]
|
||||
|
||||
def get_home_mesh_color(self):
|
||||
return self.__colors[self._cur_theme][2]
|
||||
|
||||
# Use this accessor, don't create more than one theme object
|
||||
_theme = None
|
||||
|
Loading…
Reference in New Issue
Block a user