Mercurial > MadButterfly
changeset 1148:153a87b4edb7
Merge
author | wycc |
---|---|
date | Fri, 24 Dec 2010 15:18:05 +0800 |
parents | 5cfa73d7e80f (current diff) 6409a83b68e7 (diff) |
children | 0ffef2df6201 |
files | pyink/MBScene.py |
diffstat | 2 files changed, 82 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/include/mb_types.h Fri Dec 24 15:00:28 2010 +0800 +++ b/include/mb_types.h Fri Dec 24 15:18:05 2010 +0800 @@ -326,9 +326,9 @@ */ #define coord_move(co,x,y) do {(co)->matrix[2] = (x); (co)->matrix[5] = (y);} while(0) #define coord_set_scalex(co,sx) do {(co)->matrix[0] = sx;} while(0) -#define coord_set_scaley(co,sy) do {(co)->matrix[3] = sy;} while(0) +#define coord_set_scaley(co,sy) do {(co)->matrix[4] = sy;} while(0) #define coord_scalex(co) ((co)->matrix[0]) -#define coord_scaley(co) ((co)->matrix[3]) +#define coord_scaley(co) ((co)->matrix[4]) #define coord_x(co) ((co)->matrix[2]) #define coord_y(co) ((co)->matrix[5]) #define FOR_COORD_MEMBERS(coord, geo) \
--- a/pyink/MBScene.py Fri Dec 24 15:00:28 2010 +0800 +++ b/pyink/MBScene.py Fri Dec 24 15:18:05 2010 +0800 @@ -100,27 +100,45 @@ self.ui = ui def notifyChildAdded(self,node,child,prev): pass + def notifyChildRemoved(self,node,child,prev): pass + def notifyChildOrderChanged(self,node,child,prev): pass + def notifyContentChanged(self,node,old_content,new_content): pass + def notifyAttributeChanged(self,node, name, old_value, new_value): self.ui.updateUI() + pass + class LayerAddRemoveWatcher(pybInkscape.PYNodeObserver): def __init__(self,ui): self.ui = ui + pass + def notifyChildAdded(self,node,child,prev): self.ui.updateUI() + pass + def notifyChildRemoved(self,node,child,prev): self.ui.updateUI() + pass + def notifyChildOrderChanged(self,node,child,prev): self.ui.updateUI() + pass + def notifyContentChanged(self,node,old_content,new_content): self.ui.updateUI() + pass + def notifyAttributeChanged(self,node, name, old_value, new_value): self.ui.updateUI() + pass + class MBScene(): def __init__(self,desktop,win): self.desktop = desktop @@ -157,6 +175,7 @@ except: self.nameEditor.set_text('') pass + pass def confirm(self,msg): vbox = gtk.VBox() @@ -232,6 +251,9 @@ self.dom.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd") scenes = self.document.createElement("ns0:scenes") node.appendChild(scenes) + pass + pass + def update(self): doc = self.dom rdoc = self.document @@ -245,7 +267,12 @@ for layer in range(0,len(self._framelines)): lobj = self._framelines[layer] lobj.addScenes(rdoc,ns) - + pass + pass + pass + pass + pass + pass def parseScene(self): """ @@ -269,6 +296,7 @@ except: self.width = 640 self.height=480 + pass for node in doc.childList(): print node.name() @@ -376,7 +404,7 @@ txt.setAttribute("height","100") txt.setAttribute("style","fill:#ff00") ns.appendChild(txt) - gid = self.last_line.node.label()+self.newID() + gid = self.last_line.node.getAttribute('inkscape:label')+self.newID() self.ID[gid]=1 ns.setAttribute("id",gid) ns.setAttribute("inkscape:groupmode","layer") @@ -421,6 +449,9 @@ self.last_line.update() return i = i + 1 + pass + pass + def extendScene(self): nth = self.last_frame layer = self.last_line @@ -496,16 +527,21 @@ def setCurrentScene(self,nth): """ - Update the scene group according to the curretn scene data. There are a couple of cases. - 1. If the type of the scene is normal, we display it when it contains the current - frame. Otherwise hide it. - 2. If the type of the scene is relocate or scale, we need to duplicate the scene group - and then modify its transform matrix according to the definition of the scene. Then, - hide the original scenr group and display the duplciate scene group. In addition, - we may need to delete the old duplicated scene group as well. + Update the scene group according to the curretn scene + data. There are a couple of cases. + 1. If the type of the scene is normal, we display it when + it contains the current frame. Otherwise hide it. + 2. If the type of the scene is relocate or scale, we need + to duplicate the scene group and then modify its + transform matrix according to the definition of the + scene. Then, hide the original scenr group and display + the duplciate scene group. In addition, we may need to + delete the old duplicated scene group as well. - For each layer, we will always use the duplicated scene group whose name as dup. - We will put the duplicated scene group inside it. We will create this group if it is not + For each layer, we will always use the duplicated scene + group whose name as dup. + We will put the duplicated scene group inside it. We will + create this group if it is not available. """ self.current = nth @@ -526,9 +562,7 @@ layer.layer.node.appendChild(layer.duplicateGroup) pass # Create a new group - #layer.duplicateGroup = None - - +#layer.duplicateGroup = None while i < len(layer._keys): s = layer._keys[i] print s.ref.getAttribute("id"),s.idx,s.left_tween,s.right_tween @@ -583,8 +617,12 @@ for l in self.layers: for s in l.node.childList(): if s.getAttribute('id') == obj.getAttribute("id"): - self.desktop.setCurrentLayer(self.DOMtoItem(s)) - + self.desktop.setCurrentLayer(s.spitem) + pass + pass + pass + pass + def selectSceneObject(self,frameline, nth): i = 0 while i < len(frameline._keys): @@ -608,6 +646,7 @@ i = i + 2 pass pass + def setTweenType(self,typ): if typ == 'normal': self.tweenTypeSelector.set_active(0) @@ -615,8 +654,8 @@ self.tweenTypeSelector.set_active(1) elif typ == 'scale': self.tweenTypeSelector.set_active(2) - - + pass + pass def newCell(self,file): img = gtk.Image() @@ -634,7 +673,7 @@ self.lockui = True self.doEditScene(frame) self.lockui = False - + pass def _remove_active_frame(self,widget,event): """ @@ -644,6 +683,9 @@ for f in self._framelines: if f != widget: f.hide_hover() + pass + pass + pass def _create_framelines(self): import frameline @@ -718,6 +760,7 @@ color = cell.get_colormap().alloc_color("green") cell.modify_bg(gtk.STATE_NORMAL, color) pass + def duplicateKeyScene(self): self.last_line.add_keyframe(self.last_frame) # Search for the current scene @@ -737,6 +780,9 @@ return last_key = key i = i + 1 + pass + pass + def duplicateSceneGroup(self,gid): # Search for the duplicated group doc = self.dom @@ -749,10 +795,14 @@ if t.getAttribute("id") == gid: orig = t break + pass + pass + pass + pass if orig == None: return None ns = orig.duplicate(rdoc) - gid = self.last_line.node.getAttribute('id')+self.newID() + gid = self.last_line.node.getAttribute("inkscape:label")+self.newID() self.ID[gid]=1 ns.setAttribute("id",gid) ns.setAttribute("inkscape:groupmode","layer") @@ -770,6 +820,7 @@ self.lockui=False # self.grid.show_all() return + def doDuplicateKeyScene(self,w): self.lockui = True self.duplicateKeyScene() @@ -792,6 +843,7 @@ def changeObjectLabel(self,w): o = self.desktop.selection.list()[0] o.setAttribute("inkscape:label", self.nameEditor.get_text()) + pass def addNameEditor(self,hbox): self.nameEditor = gtk.Entry(max=40) @@ -799,6 +851,7 @@ self.editDone = gtk.Button('Set') hbox.pack_start(self.editDone,expand=False,fill=False) self.editDone.connect('clicked', self.changeObjectLabel) + pass def doRun(self,arg): """ @@ -843,6 +896,7 @@ self.addTweenTypeSelector(hbox) pass + def onTweenTypeChange(self,w): n = self.tweenTypeSelector.get_active() if self.last_line == None: @@ -873,6 +927,7 @@ self.last_line.set_tween_type(found,self.tweenTypeSelector.get_active_text()) self.last_line.update() self.update() + pass def addTweenTypeSelector(self,hbox): tweenbox = gtk.HBox() @@ -887,6 +942,7 @@ tweenbox.pack_start(self.tweenTypeSelector, expand=False,fill=False) hbox.pack_start(tweenbox,expand=False,fill=False) self.tweenTypeSelector.connect('changed', self.onTweenTypeChange) + pass def onQuit(self, event): self.OK = False @@ -903,10 +959,14 @@ self.lockui = True self._updateUI() self.lockui = False + pass + def _updateUI(self,node=None,arg=None): if self.last_update!= None: glib.source_remove(self.last_update) self.last_update = glib.timeout_add(300,self.show) + pass + def show(self): self.OK = True self.dom = self.desktop.doc().root().repr