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