Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-07-22 09:54:27 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-07-22 09:54:27 (GMT)
commita02313d85aa3dd2e53c4ee98a5e407460e292456 (patch)
treebdf0b63e4fa99c5e47d06acdeb7ab1245b22e968 /sugar
parent2aa23cfa42e1ea5db895bb12a47ca1b35451bcb1 (diff)
Beginnings of a simple scene API. Inspired opened-hand's Clutter
Diffstat (limited to 'sugar')
-rw-r--r--sugar/scene/Actor.py17
-rw-r--r--sugar/scene/Group.py15
-rw-r--r--sugar/scene/PixbufActor.py13
-rw-r--r--sugar/scene/Stage.py5
-rw-r--r--sugar/scene/__init__.py0
5 files changed, 50 insertions, 0 deletions
diff --git a/sugar/scene/Actor.py b/sugar/scene/Actor.py
new file mode 100644
index 0000000..1ee7e2d
--- /dev/null
+++ b/sugar/scene/Actor.py
@@ -0,0 +1,17 @@
+class Actor:
+ def __init__(self):
+ self._x = 0
+ self._y = 0
+ self._width = -1
+ self._height = -1
+
+ def set_position(self, x, y):
+ self._x = x
+ self._y = y
+
+ def set_size(self, width, height):
+ self._width = width
+ self._height = height
+
+ def render(self, window):
+ pass
diff --git a/sugar/scene/Group.py b/sugar/scene/Group.py
new file mode 100644
index 0000000..b845cd8
--- /dev/null
+++ b/sugar/scene/Group.py
@@ -0,0 +1,15 @@
+from sugar.scene.Actor import Actor
+
+class Group(Actor):
+ def __init__(self):
+ self._actors = []
+
+ def add(self, actor):
+ self._actors.append(actor)
+
+ def remove(self, actor):
+ self._actors.remove(actor)
+
+ def render(self, drawable):
+ for actor in self._actors:
+ actor.render(drawable)
diff --git a/sugar/scene/PixbufActor.py b/sugar/scene/PixbufActor.py
new file mode 100644
index 0000000..00ed587
--- /dev/null
+++ b/sugar/scene/PixbufActor.py
@@ -0,0 +1,13 @@
+import gtk
+
+from sugar.scene.Actor import Actor
+
+class PixbufActor(Actor):
+ def __init__(self, pixbuf):
+ Actor.__init__(self)
+
+ self._pixbuf = pixbuf
+
+ def render(self, drawable):
+ gc = gtk.gdk.GC(drawable)
+ drawable.draw_pixbuf(gc, self._pixbuf, 0, 0, self._x, self._y)
diff --git a/sugar/scene/Stage.py b/sugar/scene/Stage.py
new file mode 100644
index 0000000..f314db9
--- /dev/null
+++ b/sugar/scene/Stage.py
@@ -0,0 +1,5 @@
+from sugar.scene.Group import Group
+
+class Stage(Group):
+ def __init__(self):
+ Group.__init__(self)
diff --git a/sugar/scene/__init__.py b/sugar/scene/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sugar/scene/__init__.py