changeset 238:db7f22ecd3ad

Add extend scene function Fix the bug related to create the scnene metadata from scratch
author wycc
date Sat, 27 Dec 2008 12:11:27 +0800
parents 0a8fa86e2e06
children 1499b8b86fcc
files inkscape/MB_Frame.py
diffstat 1 files changed, 39 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/inkscape/MB_Frame.py	Sat Dec 27 10:19:45 2008 +0800
+++ b/inkscape/MB_Frame.py	Sat Dec 27 12:11:27 2008 +0800
@@ -53,6 +53,7 @@
 			self.dump(n,l+1)
 		print " " * l * 2,"/>"
 	def parseMetadata(self,node):
+		self.current = 1
 		for n in node:
 			if n.tag == '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scenes':
 				self.scenemap={}
@@ -219,7 +220,7 @@
 			layer.scene.append(newscene)
 			btn = self.newCell('start.png')
 			btn.nScene = nth
-			btn.layer = layer
+			btn.layer = layer.node.get('id')
 			btn.nLayer = y
 			self.grid.attach(btn, x, x+1, y, y+1,0,0,0,0)
 
@@ -229,7 +230,7 @@
 	def removeKeyScene(self):
 		nth = self.last_cell.nScene
 		try:
-			layer = self.getLayer(self.last_cell.layer.node.get('id'))
+			layer = self.getLayer(self.last_cell.layer)
 		except:
 			return
 		x = self.last_cell.nScene
@@ -270,14 +271,39 @@
 						
 				return
 
-	def extendScene(self,layer,nth):
-		layer = self.getLayer(layer)
+	def extendScene(self):
+		nth = self.last_cell.nScene
+		try:
+			layer = self.getLayer(self.last_cell.layer)
+		except:
+			return
+		x = self.last_cell.nScene
+		y = self.last_cell.nLayer
 		if layer == None: return
+
+		for i in range(0,len(layer.scene)-1):
+			s = layer.scene[i]
+			if nth >= layer.scene[i].start and nth <= layer.scene[i].end:
+				return
+
 		for i in range(0,len(layer.scene)-1):
 			s = layer.scene[i]
 			if nth >= layer.scene[i].start and nth < layer.scene[i+1].start:
+				for j in range(layer.scene[i].end+1, nth+1):
+					btn = self.newCell('fill.png')
+					btn.nScene = nth
+					btn.nLayer = y
+					btn.layer = self.last_cell.layer
+					self.grid.attach(btn, j,j+1,y,y+1,0,0,0,0)
 				layer.scene[i].end = nth
-		if len(layer.scene) > 0:
+				return
+		if len(layer.scene) > 0 and nth > layer.scene[len(layer.scene)-1].end:
+			for j in range(layer.scene[len(layer.scene)-1].end+1, nth+1):
+				btn = self.newCell('fill.png')
+				btn.nScene = nth
+				btn.nLayer = y
+				btn.layer = self.last_cell.layer
+				self.grid.attach(btn, j,j+1,y,y+1,0,0,0,0)
 			layer.scene[len(layer.scene)-1].end = nth
 	def setCurrentScene(self,nth):
 		self.current = nth
@@ -378,7 +404,7 @@
 			self.grid.attach(gtk.Label('%d'% i), i,i+1,0,1,0,0,0,0)
 		for i in range(1,len(self.layer)+1):
 			l = self.layer[i-1]
-			self.grid.attach(gtk.Label(l.node.get('id')), 0, 1, i, i+1,0,0,10,0)
+			self.grid.attach(gtk.Label(l.node.get('{http://www.inkscape.org/namespaces/inkscape}label')), 0, 1, i, i+1,0,0,10,0)
 			for s in l.scene:
 				btn = self.newCell('start.png')
 				btn.nScene = s.start
@@ -425,6 +451,10 @@
 		self.removeKeyScene()
 		self.grid.show_all()
 		self.generate()
+	def doExtendScene(self,w):
+		self.extendScene()
+		self.grid.show_all()
+		self.generate()
 	def addButtons(self,hbox):
 		btn = gtk.Button('Edit')
 		btn.connect('clicked', self.doEditScene)
@@ -435,6 +465,9 @@
 		btn=gtk.Button('Remove Key')
 		btn.connect('clicked', self.doRemoveScene)
 		hbox.pack_start(btn)
+		btn=gtk.Button('Extend scene')
+		btn.connect('clicked', self.doExtendScene)
+		hbox.pack_start(btn)
 	def effect(self):
 		self.parseScene()
 		self.showGrid()