Get rid of the initial implementation of Diana design since that's no more the plan.
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
import gobject
|
||||
|
||||
from sugar.scene.Transformation import Transformation
|
||||
|
||||
class Actor(gobject.GObject):
|
||||
__gsignals__ = {
|
||||
'changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
gobject.GObject.__init__(self)
|
||||
|
||||
self._parent = None
|
||||
self._x = 0
|
||||
self._y = 0
|
||||
self._width = -1
|
||||
self._height = -1
|
||||
self._transf = Transformation()
|
||||
|
||||
def set_position(self, x, y):
|
||||
self._x = x
|
||||
self._y = y
|
||||
self.notify_changed()
|
||||
|
||||
def _get_parents(self):
|
||||
parents = []
|
||||
parent = self._parent
|
||||
while parent:
|
||||
parents.insert(0, parent)
|
||||
parent = parent._parent
|
||||
return parents
|
||||
|
||||
def _get_abs_position(self, x, y):
|
||||
transf = None
|
||||
parents = self._get_parents()
|
||||
for actor in parents:
|
||||
if transf:
|
||||
transf = transf.compose(actor._transf)
|
||||
else:
|
||||
transf = actor._transf
|
||||
return transf.get_position(x, y)
|
||||
|
||||
def notify_changed(self):
|
||||
if self._parent:
|
||||
self._parent.notify_changed()
|
||||
else:
|
||||
self.emit('changed')
|
||||
|
||||
def set_size(self, width, height):
|
||||
self._width = width
|
||||
self._height = height
|
||||
self.notify_changed()
|
||||
|
||||
def render(self, drawable):
|
||||
pass
|
||||
@@ -1,25 +0,0 @@
|
||||
import math
|
||||
|
||||
from sugar.scene.LayoutManager import LayoutManager
|
||||
|
||||
class CircleLayout(LayoutManager):
|
||||
def __init__(self, radius):
|
||||
LayoutManager.__init__(self)
|
||||
|
||||
self._radius = radius
|
||||
self._angle = 0
|
||||
|
||||
def set_angle(self, angle):
|
||||
self._angle = angle
|
||||
|
||||
def layout_group(self, group):
|
||||
step = 2 * math.pi / len(group.get_actors())
|
||||
angle = self._angle
|
||||
for actor in group.get_actors():
|
||||
self._update_position(actor, angle)
|
||||
angle += step
|
||||
|
||||
def _update_position(self, actor, angle):
|
||||
x = math.cos(angle) * self._radius + self._radius
|
||||
y = math.sin(angle) * self._radius + self._radius
|
||||
actor.set_position(int(x + 0.5), int(y + 0.5))
|
||||
@@ -1,39 +0,0 @@
|
||||
from sugar.scene.Actor import Actor
|
||||
|
||||
class Group(Actor):
|
||||
def __init__(self):
|
||||
Actor.__init__(self)
|
||||
|
||||
self._actors = []
|
||||
self._layout = None
|
||||
|
||||
def set_position(self, x, y):
|
||||
Actor.set_position(self, x, y)
|
||||
self._transf.set_translation(x, y)
|
||||
|
||||
def add(self, actor):
|
||||
actor._parent = self
|
||||
self._actors.append(actor)
|
||||
self.do_layout()
|
||||
|
||||
def remove(self, actor):
|
||||
self._actors.remove(actor)
|
||||
self.do_layout()
|
||||
|
||||
def get_actors(self):
|
||||
return self._actors
|
||||
|
||||
def set_layout(self, layout):
|
||||
self._layout = layout
|
||||
self.do_layout()
|
||||
|
||||
def get_layout(self):
|
||||
return self._layout
|
||||
|
||||
def do_layout(self):
|
||||
if self._layout:
|
||||
self._layout.layout_group(self)
|
||||
|
||||
def render(self, drawable):
|
||||
for actor in self._actors:
|
||||
actor.render(drawable)
|
||||
@@ -1,7 +0,0 @@
|
||||
class LayoutManager:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def layout_group(self, group):
|
||||
pass
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
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):
|
||||
(x, y) = self._get_abs_position(self._x, self._y)
|
||||
gc = gtk.gdk.GC(drawable)
|
||||
drawable.draw_pixbuf(gc, self._pixbuf, 0, 0, x, y)
|
||||
@@ -1,16 +0,0 @@
|
||||
import gtk
|
||||
|
||||
class SceneView(gtk.Fixed):
|
||||
def __init__(self, stage):
|
||||
gtk.Fixed.__init__(self)
|
||||
self.set_has_window(True)
|
||||
self.connect('expose-event', self.__expose_cb)
|
||||
|
||||
self._stage = stage
|
||||
stage.connect('changed', self.__stage_changed_cb)
|
||||
|
||||
def __expose_cb(self, widget, event):
|
||||
self._stage.render(widget.window)
|
||||
|
||||
def __stage_changed_cb(self, stage):
|
||||
self.window.invalidate_rect(None, False)
|
||||
@@ -1,12 +0,0 @@
|
||||
from sugar.scene.Group import Group
|
||||
|
||||
class Stage(Group):
|
||||
def __init__(self):
|
||||
Group.__init__(self)
|
||||
self._fps = 50
|
||||
|
||||
def get_fps(self):
|
||||
return self._fps
|
||||
|
||||
def render(self, drawable):
|
||||
Group.render(self, drawable)
|
||||
@@ -1,22 +0,0 @@
|
||||
import gtk
|
||||
|
||||
from sugar.scene.Stage import Stage
|
||||
|
||||
class StageView(gtk.Fixed):
|
||||
def __init__(self, stage):
|
||||
gtk.Fixed.__init__(self)
|
||||
self.set_has_window(True)
|
||||
|
||||
self._stage = stage
|
||||
self._stage.connect('changed', self.__stage_changed_cb)
|
||||
self.connect('expose_event', self.__expose_cb)
|
||||
|
||||
def __stage_changed_cb(self, stage):
|
||||
if self.window:
|
||||
self.window.invalidate_rect(None, False)
|
||||
|
||||
def __expose_cb(self, widget, event):
|
||||
self._stage.render(widget.window)
|
||||
|
||||
def get_stage(self):
|
||||
return self._stage
|
||||
@@ -1,33 +0,0 @@
|
||||
import gobject
|
||||
|
||||
class Timeline(gobject.GObject):
|
||||
__gsignals__ = {
|
||||
'next-frame': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([int])),
|
||||
'completed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([]))
|
||||
}
|
||||
|
||||
def __init__(self, stage, n_frames):
|
||||
gobject.GObject.__init__(self)
|
||||
|
||||
self._stage = stage
|
||||
self._fps = stage.get_fps()
|
||||
self._n_frames = n_frames
|
||||
self._current_frame = 0
|
||||
|
||||
def start(self):
|
||||
gobject.timeout_add(1000 / self._fps, self.__timeout_cb)
|
||||
|
||||
def get_n_frames(self):
|
||||
return self._n_frames
|
||||
|
||||
def __timeout_cb(self):
|
||||
self.emit('next-frame', self._current_frame)
|
||||
|
||||
# FIXME skip frames if necessary
|
||||
self._current_frame += 1
|
||||
|
||||
if self._current_frame < self._n_frames:
|
||||
return True
|
||||
else:
|
||||
self.emit('completed')
|
||||
return False
|
||||
@@ -1,21 +0,0 @@
|
||||
import copy
|
||||
|
||||
class Transformation:
|
||||
def __init__(self):
|
||||
self._translation_x = 0
|
||||
self._translation_y = 0
|
||||
|
||||
def set_translation(self, x, y):
|
||||
self._translation_x = x
|
||||
self._translation_y = y
|
||||
|
||||
def get_position(self, x, y):
|
||||
translated_x = x + self._translation_x
|
||||
translated_y = y + self._translation_y
|
||||
return (translated_x, translated_y)
|
||||
|
||||
def compose(self, transf):
|
||||
composed = copy.copy(self)
|
||||
composed._translation_x += transf._translation_x
|
||||
composed._translation_y += transf._translation_y
|
||||
return composed
|
||||
Reference in New Issue
Block a user