Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Coudoin <bruno.coudoin@free.fr>2009-11-08 22:05:15 (GMT)
committer Bruno Coudoin <bruno.coudoin@free.fr>2009-11-08 22:05:15 (GMT)
commitf4ce55cc2917e1af57c5b4eb83fc3d5a2b31d4b2 (patch)
tree2a1e777bf8a471796cd8f830fcd415c57391abc0
parent7c32c8cd14f2d3e7c7e9523dc85c47da82bea06c (diff)
Class reog, there is now a Document class that holds
everything related to the animation document itself.
-rw-r--r--src/anim-activity/AnimItem.py16
-rw-r--r--src/anim-activity/anim.py73
2 files changed, 47 insertions, 42 deletions
diff --git a/src/anim-activity/AnimItem.py b/src/anim-activity/AnimItem.py
index 1ed7534..1919482 100644
--- a/src/anim-activity/AnimItem.py
+++ b/src/anim-activity/AnimItem.py
@@ -291,13 +291,13 @@ class AnimItem:
if self.anchor:
self.anchor.update()
- self.save_at_time(AnimItem.anim.timeline.get_time())
+ self.save_at_time(AnimItem.anim.doc.timeline.get_time())
def delete(self):
gcompris.sound.play_ogg("sounds/eraser1.wav",
"sounds/eraser2.wav")
- self.delete_at_time(AnimItem.anim.timeline.get_time())
+ self.delete_at_time(AnimItem.anim.doc.timeline.get_time())
if not self.visible:
AnimItem.anim.deleteItem(self)
self.show(False)
@@ -342,13 +342,13 @@ class AnimItem:
def create_item_event(self, item, target):
self.refpoint = None
- self.save_at_time(AnimItem.anim.timeline.get_time())
+ self.save_at_time(AnimItem.anim.doc.timeline.get_time())
# By default, an object is displayed till the timeline end
- self.set_visible_to_end(AnimItem.anim.timeline.get_time())
+ self.set_visible_to_end(AnimItem.anim.doc.timeline.get_time())
def create_item_drag_event(self, item, target, event):
if event.type == gtk.gdk.BUTTON_RELEASE:
- self.save_at_time(AnimItem.anim.timeline.get_time())
+ self.save_at_time(AnimItem.anim.doc.timeline.get_time())
if (event.type == gtk.gdk.MOTION_NOTIFY
and event.state & gtk.gdk.BUTTON1_MASK):
@@ -373,7 +373,7 @@ class AnimItem:
if event.type == gtk.gdk.BUTTON_RELEASE:
self.old_x = 0
self.old_y = 0
- self.save_at_time(AnimItem.anim.timeline.get_time())
+ self.save_at_time(AnimItem.anim.doc.timeline.get_time())
elif event.type == gtk.gdk.BUTTON_PRESS:
self.old_x = event.x
self.old_y = event.y
@@ -728,7 +728,7 @@ class AnimItemRect(AnimItem):
stroke_color_rgba = stroke)
else:
self.item.set_properties(stroke_color_rgba = stroke)
- self.save_at_time(AnimItem.anim.timeline.get_time())
+ self.save_at_time(AnimItem.anim.doc.timeline.get_time())
#
# The ellipse (filled or not)
@@ -1112,7 +1112,7 @@ class AnimItemText(AnimItem):
y = y1 + yoffset)
if self.anchor:
self.anchor.update()
- self.save_at_time(AnimItem.anim.timeline.get_time())
+ self.save_at_time(AnimItem.anim.doc.timeline.get_time())
def set_bounds(self, p1, p2):
diff --git a/src/anim-activity/anim.py b/src/anim-activity/anim.py
index 7a9d2c2..1723743 100644
--- a/src/anim-activity/anim.py
+++ b/src/anim-activity/anim.py
@@ -19,6 +19,7 @@
# Version 3 of anim
# Rewrote to support a timeline. Now each object type has its own
# python class.
+# Each frame can be re-edited at will.
#
# Version 2 of anim
# Due to performance, the animation code as been rewriten
@@ -64,18 +65,7 @@ class Gcompris_anim:
self.gcomprisBoard = gcomprisBoard
self.timeout = 0
- # The list of all the user's objects
- self.animlist = []
-
- # There is two board in the same code
- # here the diff in parameters
- self.pickle_protocol = 2
- if self.gcomprisBoard.mode == 'draw':
- self.format_string = { 'gcompris' : 'GCompris draw 3 cPikle file',
- }
- else:
- self.format_string = { 'gcompris' : 'GCompris anim 3 cPikle file',
- }
+ self.doc = None
if self.gcomprisBoard.mode == 'draw':
# DRAW
@@ -171,14 +161,15 @@ class Gcompris_anim:
self.rootitem = goocanvas.Group(
parent = self.gcomprisBoard.canvas.get_root_item())
+ self.doc = Document(self)
+
# initialisation
self.draw_tools()
self.draw_animtools()
- self.timeline = Timeline(self)
- self.timeline.draw()
+ self.doc.timeline.draw()
if self.gcomprisBoard.mode == 'draw':
- self.timeline.hide()
+ self.doc.timeline.hide()
self.color = Color(self.rootitem, self.drawing_area)
self.color.draw()
@@ -229,10 +220,10 @@ class Gcompris_anim:
self.selector_section, self.file_type,
general_restore, self)
elif (keyval == gtk.keysyms.Left):
- self.timeline.previous()
+ self.doc.timeline.previous()
return True
elif (keyval == gtk.keysyms.Right):
- self.timeline.next()
+ self.doc.timeline.next()
return True
# Printing
@@ -538,7 +529,7 @@ class Gcompris_anim:
# This is called by animitem itself when the object
# is no more displayed on any time lines.
def deleteItem(self, item):
- self.animlist.remove(item)
+ self.doc.animlist.remove(item)
# Main callback on item comes here first
# And are then dispatched to the proper functions
@@ -611,7 +602,7 @@ class Gcompris_anim:
target)
# We keep all object in a unique list
- self.animlist.append(self.created_object)
+ self.doc.animlist.append(self.created_object)
# Mark it as selected so we can write in it without
# having to make a real selection and keys shortcuts
@@ -657,11 +648,11 @@ class Gcompris_anim:
def refresh(self, time):
# We keep all object in a unique list
# Here we order them to refresh them at the given time
- for item in self.animlist:
+ for item in self.doc.animlist:
item.display_at_time(time)
def refresh_loop(self):
- self.timeline.next()
+ self.doc.timeline.next()
return True
def playing_start(self):
@@ -711,12 +702,27 @@ class Gcompris_anim:
font = gcompris.skin.get_font("gcompris/board/medium"),
fill_color = "white")
+
+class Document:
+ """This holds everything releated to the animation itself"""
+
+ def __init__(self, anim_):
+ self.anim = anim_
+ self.timeline = Timeline(self.anim)
+ # The list of all the user's objects
+ self.animlist = []
+ self.item_id = 0
+
+ self.pickle_protocol = 2
+ self.format_string = { 'gcompris' : 'GCompris anim 3 cPikle file' }
+
+
def anim_to_file(self, filename):
file = open(filename, 'wb')
# Save the descriptif frame:
- pickle.dump(fles.format_string['gcompris'], file, self.pickle_protocol)
+ pickle.dump(self.format_string['gcompris'], file, self.pickle_protocol)
# Save the last mark
pickle.dump(self.timeline.get_lastmark(), file, self.pickle_protocol)
@@ -739,20 +745,20 @@ class Gcompris_anim:
if type(desc) == type('str'):
# string
- if 'desc' != fles.format_string['gcompris']:
- if (desc == 'GCompris draw 3 cPikle file'
- or desc == 'GCompris anim 3 cPikle file'):
+ if 'desc' != self.format_string['gcompris']:
+ if (desc == 'GCompris anim 3 cPikle file'):
- self.deselect()
+ self.anim.deselect()
for item in self.animlist[:]:
item.delete()
self.timeline.set_lastmark(pickle.load(file))
self.animlist = pickle.load(file)
for item in self.animlist:
- item.restore(self)
+ item.restore(self.anim)
- self.refresh(self.timeline.get_time())
+ self.anim.refresh(self.timeline.get_time())
+ self.timeline.set_time(0)
else:
print "ERROR: Unrecognized file format, file", filename, ' has description : ', desc
file.close()
@@ -763,9 +769,8 @@ class Gcompris_anim:
return
elif type(desc) == type(1):
- print filename, 'has no description. Are you sure it\'s', fles.format_string['gcompris'],'?'
- # int
- fles.frames_total = desc
+ print filename, 'has no description. Are you sure it\'s', \
+ self.format_string['gcompris'],'?'
file.close()
@@ -777,11 +782,11 @@ class Gcompris_anim:
###############################################
def general_save(filename, filetype, fles):
#print "filename=%s filetype=%s" %(filename, filetype)
- fles.anim_to_file(filename)
+ fles.doc.anim_to_file(filename)
def general_restore(filename, filetype, fles):
#print "general_restore : ", filename, " type ",filetype
- fles.file_to_anim(filename)
+ fles.doc.file_to_anim(filename)
def image_selected(image, fles):
#fles is used because self is not passed through callback
@@ -798,5 +803,5 @@ def image_selected(image, fles):
fles.root_drawingitem)
# We keep all object in a unique list
- fles.animlist.append(fles.created_object)
+ fles.doc.animlist.append(fles.created_object)