Commit 8f6c4530 authored by Bruno Coudoin's avatar Bruno Coudoin

Properly manage the delete item (now deletes the item up to the end)

and removes it from the list of items.

svn path=/branches/gcomprixogoo/; revision=3752
parent c5bf8dcc
......@@ -92,26 +92,19 @@ class AnimItem:
self.set_visible(fromtime, sys.maxint)
# Mark this object to be deleted at the given time
def delete_at_time_to_end(self, time):
index = self.delete_at_time(time)
del self.visible[index+1:]
# Mark this object to be deleted at the given time
# Return the index of the delete item in self.visible
def delete_at_time(self, time):
index = 0
for index in range(0, len(self.visible)):
# It's the set start
if self.visible[index][0] == time:
self.visible[index] = \
(self.visible[index][0] + 1,
del self.visible[index:]
# It's the set end
elif self.visible[index][1] == time:
self.visible[index] = \
self.visible[index][1] - 1)
del self.visible[index+1:]
# It's inside the set
elif (self.visible[index][0] <= time and
......@@ -119,10 +112,9 @@ class AnimItem:
oldend = self.visible[index][1]
self.visible[index] = \
(self.visible[index][0], time - 1)
self.visible.append((time + 1, oldend))
del self.visible[index+1:]
return index
# Given a timeline index, return True if it is visible
def is_visible(self, index):
......@@ -220,7 +212,9 @@ class AnimItem:
def delete(self):
if not self.visible:
def raise_(self):
......@@ -563,6 +563,12 @@ class Gcompris_anim:
self.selected = None
# Delete the item from the unique list
# This is called by animitem itself when the object
# is no more displayed on any time lines.
def deleteItem(self, item):
# Main callback on item comes here first
# And are then dispatched to the proper functions
def item_event(self, item, target, event):
......@@ -672,7 +678,7 @@ class Gcompris_anim:
def refresh(self, time):
# We keep all object in a unique list
# Here we order them to refresh them for the given time
# Here we order them to refresh them at the given time
for item in self.animlist:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment