Beginnings of a simple scene API. Inspired opened-hand's Clutter
This commit is contained in:
@@ -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
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -0,0 +1,5 @@
|
||||
from sugar.scene.Group import Group
|
||||
|
||||
class Stage(Group):
|
||||
def __init__(self):
|
||||
Group.__init__(self)
|
||||
Reference in New Issue
Block a user