Get rid of the initial implementation of Diana design since that's no more the plan.

This commit is contained in:
Marco Pesenti Gritti 2006-08-14 20:54:33 +02:00
parent 3d4330580c
commit 621e43563f
19 changed files with 0 additions and 385 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

View File

@ -1,61 +0,0 @@
#!/usr/bin/python
import math
import pygtk
pygtk.require('2.0')
import gtk
from sugar.scene.Stage import Stage
from sugar.scene.Group import Group
from sugar.scene.SceneView import SceneView
from sugar.scene.PixbufActor import PixbufActor
from sugar.scene.CircleLayout import CircleLayout
from sugar.scene.Timeline import Timeline
def __next_frame_cb(timeline, frame_num, group):
angle = math.pi * 2 * frame_num / timeline.get_n_frames()
group.get_layout().set_angle(angle)
group.do_layout()
def __completed_cb(timeline, group):
group.get_layout().set_angle(0)
group.do_layout()
stage = Stage()
pixbuf = gtk.gdk.pixbuf_new_from_file('background.png')
stage.add(PixbufActor(pixbuf))
icons_group = Group()
icons_group.set_position(100, 100)
i = 1
while i <= 5:
pixbuf = gtk.gdk.pixbuf_new_from_file('activity%d.png' % i)
icons_group.add(PixbufActor(pixbuf))
i += 1
layout = CircleLayout(100)
icons_group.set_layout(layout)
stage.add(icons_group)
window = gtk.Window()
window.set_default_size(640, 480)
view = SceneView(stage)
window.add(view)
view.show()
button = gtk.Button('Hello')
view.put(button, 10, 10)
button.show()
window.show()
timeline = Timeline(stage, 200)
timeline.connect('next-frame', __next_frame_cb, icons_group)
timeline.connect('completed', __completed_cb, icons_group)
timeline.start()
gtk.main()

View File

@ -1,80 +0,0 @@
import gtk
from sugar.scene.Stage import Stage
from sugar.scene.StageView import StageView
from sugar.scene.PixbufActor import PixbufActor
from sugar.scene.CircleLayout import CircleLayout
from sugar.scene.Group import Group
from sugar.activity import Activity
from sugar import env
class ActivityLauncher(gtk.HButtonBox):
def __init__(self, shell):
gtk.HButtonBox.__init__(self)
self._shell = shell
for module in shell.get_registry().list_activities():
if module.get_show_launcher():
self._add_activity(module)
def _add_activity(self, module):
button = gtk.Button(module.get_name())
activity_id = module.get_id()
button.connect('clicked', self.__clicked_cb, activity_id)
self.pack_start(button)
button.show()
def __clicked_cb(self, button, activity_id):
Activity.create(activity_id)
class HomeScene(StageView):
def __init__(self, shell):
self._stage = self._create_stage()
StageView.__init__(self, self._stage)
self._shell = shell
launcher = ActivityLauncher(shell)
self.put(launcher, 10, 440)
launcher.show()
def _create_stage(self):
stage = Stage()
background = env.get_data_file('home-background.png')
pixbuf = gtk.gdk.pixbuf_new_from_file(background)
stage.add(PixbufActor(pixbuf))
icons_group = Group()
icons_group.set_position(310, 80)
pholder = env.get_data_file('activity-placeholder.png')
pholder_pixbuf = gtk.gdk.pixbuf_new_from_file(pholder)
i = 0
while i < 7:
icons_group.add(PixbufActor(pholder_pixbuf))
i += 1
layout = CircleLayout(110)
icons_group.set_layout(layout)
stage.add(icons_group)
return stage
class HomeWindow(gtk.Window):
def __init__(self, shell):
gtk.Window.__init__(self)
self.connect('realize', self.__realize_cb)
fixed = gtk.Fixed()
scene = HomeScene(shell)
scene.set_size_request(640, 480)
self.add(scene)
scene.show()
def __realize_cb(self, window):
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DESKTOP)

View File

@ -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

View File

@ -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))

View File

@ -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)

View File

@ -1,7 +0,0 @@
class LayoutManager:
def __init__(self):
pass
def layout_group(self, group):
pass

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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