# HG changeset patch
# User wycc
# Date 1291852126 -28800
# Node ID b5ff72dbc91005f88ae79b5709f34b2cfc0e4646
# Parent aad659b6b62584f900b601c17f76010e36c3ea35# Parent 17cbb862a8c642f13b21655db673941d8292b4b0
merge
diff -r 17cbb862a8c6 -r b5ff72dbc910 examples/menu/filebrowser.c
--- a/examples/menu/filebrowser.c Thu Dec 09 00:33:41 2010 +0800
+++ b/examples/menu/filebrowser.c Thu Dec 09 07:48:46 2010 +0800
@@ -191,7 +191,8 @@
dir = opendir(curdir);
while(e = readdir(dir)) {
if (strcmp(e->d_name,".")==0) continue;
- if (e->d_type == DT_REG) {
+ printf("e->d_type=%d %d name=%s\n",e->d_type,DT_REG,e->d_name);
+ if (e->d_type == DT_REG || e->d_type == DT_LNK) {
if (data->nFiles < MAX_ENTRY) {
f = fileinfo_new();
data->files[data->nFiles] = f;
diff -r 17cbb862a8c6 -r b5ff72dbc910 nodejs/examples/mce/epg.js
--- a/nodejs/examples/mce/epg.js Thu Dec 09 00:33:41 2010 +0800
+++ b/nodejs/examples/mce/epg.js Thu Dec 09 07:48:46 2010 +0800
@@ -28,7 +28,12 @@
js = js + data;
});
res.on('end', function () {
- res = JSON.parse(js);
+ try {
+ res = JSON.parse(js);
+ } catch(e) {
+ sys.puts(e);
+ sys.puts(js);
+ }
sys.puts("parsed");
self.onLoad(res);
@@ -119,7 +124,7 @@
fs.close(f);
var fields = cachepath.split('.');
var ext = fields.pop();
- if (ext != "png") {
+ if (ext != "png" && ext != 'jpg') {
fields.push("png");
newf = fields.join(".");
sys.puts("cachepath="+cachepath+" newf="+newf);
diff -r 17cbb862a8c6 -r b5ff72dbc910 pyink/MBScene.py
--- a/pyink/MBScene.py Thu Dec 09 00:33:41 2010 +0800
+++ b/pyink/MBScene.py Thu Dec 09 07:48:46 2010 +0800
@@ -48,10 +48,11 @@
pass
class Scene:
- def __init__(self, node, start,end):
+ def __init__(self, node, start,end,typ):
self.node = node
self.start = int(start)
self.end = int(end)
+ self.type = typ
pass
pass
@@ -168,10 +169,15 @@
except:
end = start
pass
+ try:
+ typ = s.repr.attribute('type')
+ if typ == None:
+ typ = 'normal'
+ except:
+ traceback.print_exc()
+ typ = 'normal'
link = s.repr.attribute("ref")
- self.scenemap[link] = [int(start),int(end)]
- print "scene %d to %d" % (self.scenemap[link][0],
- self.scenemap[link][1])
+ self.scenemap[link] = [int(start),int(end),typ]
if cur >= start and cur <= end:
self.currentscene = link
pass
@@ -234,7 +240,7 @@
lyobj.current_scene.append(scene)
continue
- lyobj.scenes.append(Scene(scene,scmap[0],scmap[1]))
+ lyobj.scenes.append(Scene(scene,scmap[0],scmap[1],scmap[2]))
pass
else:
lyobj.current_scene.append(scene)
@@ -423,9 +429,35 @@
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.
+
+ 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
for layer in self._framelines:
i=0
+
+ # Check the duplicated scene group and create it if it is not available
+ try:
+ if layer.duplicateGroup:
+ layer.duplicateGroup.parent().removeChild(layer.duplicateGroup)
+ layer.duplicateGroup = None
+ except:
+ traceback.print_exc()
+ pass
+ # Create a new group
+ layer.duplicateGroup = None
+
+
while i < len(layer._keys):
s = layer._keys[i]
print s.ref.attribute("id"),s.idx,s.left_tween,s.right_tween
@@ -436,15 +468,131 @@
s.ref.setAttribute("style","display:none",True)
i = i + 1
continue
-
- if nth >= (s.idx+1) and nth <= (layer._keys[i+1].idx+1):
+ if nth == s.idx + 1:
s.ref.setAttribute("style","",True)
else:
- s.ref.setAttribute("style","display:none",True)
+ if nth > (s.idx+1) and nth <= (layer._keys[i+1].idx+1):
+ if i+2 < len(layer._keys):
+ layer.duplicateGroup = self.desktop.doc().rdoc.createElement("svg:g")
+ layer.duplicateGroup.setAttribute("inkscape:label","dup",True)
+ s.ref.setAttribute("style","display:none",True)
+ s.ref.parent().appendChild(layer.duplicateGroup)
+ self.updateTweenContent(layer.duplicateGroup, layer.get_tween_type(s.idx),s, layer._keys[i+2], nth)
+ else:
+ s.ref.setAttribute("style","display:none",True)
i = i + 2
pass
pass
pass
+ def updateTweenContent(self,obj, typ, source,dest,cur):
+ """
+ Update the content of the duplicate scene group. We will use the (start,end) and cur to calculate the percentage of
+ the tween motion effect and then use it to update the transform matrix of the duplicated scene group.
+ """
+ start = source.idx
+ end = dest.idx
+ print cur,start,end
+ percent = (cur-start)*1.0/(end-start)
+ i = 0
+ s = source.ref.firstChild()
+ d = dest.ref.firstChild()
+ sources={}
+ dests={}
+ # Collect all objects
+ while d:
+ try:
+ label = d.attribute("inkscape:label")
+ except:
+ d = d.next()
+ continue
+ dests[label.value()] = d
+ d = d.next()
+ # Check if the object in the source exists in the destination
+ s = source.ref.firstChild()
+ d = dest.ref.firstChild()
+ while s:
+ print s,d
+ try:
+ label = s.attribute("inkscape:label")
+ # Use i8nkscape:label to identidy the equipvalent objects
+ if label:
+ if dests.hasattr(label.value()):
+ self.updateTweenObject(obj,typ,s,dests[label.value()],percent)
+ s = s.next()
+ continue
+ except:
+ pass
+ # Search obejcts in the destination
+ while d:
+ try:
+ d.attribute("inkscape:label")
+ d = d.next()
+ continue
+ except:
+ pass
+ if s.name() == d.name():
+ self.updateTweenObject(obj,typ,s,d,percent)
+ d = d.next()
+ break
+ d = d.next()
+ s = s.next()
+ def parseTransform(self,obj):
+ """
+ Return the transform matrix of an object
+ """
+ try:
+ t = obj.attribute("transform")
+ print t
+ if t[0:9] == 'translate':
+ print "translate"
+ fields = t[10:].split(',')
+ x = float(fields[0])
+ fields = fields[1].split(')')
+ y = float(fields[0])
+ return [1,0,x,0,1,y]
+ elif t[0:6] == 'matrix':
+ print "matrix"
+ fields=t[7:].split(')')
+ fields = fields[0].split(',')
+ return [float(fields[0]),float(fields[1]),float(fields[2]),float(fields[3]),float(fields[4]),float(fields[5])]
+ except:
+ traceback.print_exc()
+ return [1,0,0,0,1,0]
+
+
+ def updateTweenObject(self,obj,typ,s,d,p):
+ """
+ Generate tweened object in the @obj by using s and d in the @p percent
+ """
+ print 'compare',s,d
+ if typ == 'relocate':
+ print "percent",p
+ newobj = s.duplicate(self.desktop.doc().rdoc)
+ top = self.desktop.doc().rdoc.createElement("svg:g")
+ top.appendChild(newobj)
+ obj.appendChild(top)
+ print s.name()
+ if s.name() == 'svg:g':
+ # Parse the translate or matrix
+ sm = self.parseTransform(s)
+ dm = self.parseTransform(d)
+ print "g", (dm[2]-sm[2])*p,(dm[5]-sm[5])*p
+ top.setAttribute("transform","translate(%g,%g)" % ((dm[2]-sm[2])*p,(dm[5]-sm[5])*p),True)
+ else:
+ try:
+ sx = float(s.attribute("x"))
+ sy = float(s.attribute("y"))
+ dx = float(d.attribute("x"))
+ dy = float(d.attribute("y"))
+ tx = (dx-sx)*p
+ ty = (dy-sy)*p
+ print tx,ty
+ top.setAttribute("transform","translate(%g,%g)" % (tx,ty),True)
+ except:
+ traceback.print_exc()
+ pass
+ pass
+ pass
def enterGroup(self,obj):
for l in self.layers:
for s in l.node.childList():
@@ -458,6 +606,7 @@
if s.right_tween is False:
if nth == s.idx+1:
self.enterGroup(s.ref)
+ self.setTweenType(frameline.get_tween_type(s.idx))
return
else:
pass
@@ -466,12 +615,20 @@
if nth >= (s.idx+1) and nth <= (frameline._keys[i+1].idx+1):
self.enterGroup(s.ref)
+ self.setTweenType(frameline.get_tween_type(s.idx))
return
else:
pass
i = i + 2
pass
pass
+ def setTweenType(self,typ):
+ if typ == 'normal':
+ self.tweenTypeSelector.set_active(0)
+ elif typ == 'relocate':
+ self.tweenTypeSelector.set_active(1)
+ elif typ == 'scale':
+ self.tweenTypeSelector.set_active(2)
@@ -558,7 +715,7 @@
frameline.add_keyframe(scene.start-1,scene.node.repr)
if scene.start != scene.end:
frameline.add_keyframe(scene.end-1,scene.node.repr)
- frameline.tween(scene.start-1)
+ frameline.tween(scene.start-1,scene.type)
pass
pass
pass
@@ -662,7 +819,52 @@
btn.connect('clicked', self.doDuplicateKeyScene)
hbox.pack_start(btn,expand=False,fill=False)
self.addNameEditor(hbox)
+ self.addTweenTypeSelector(hbox)
pass
+ def onTweenTypeChange(self,w):
+ n = self.tweenTypeSelector.get_active()
+ if self.last_line == None:
+ return
+ frameline = self.last_line
+ i = 0
+ found = -1
+ while i < len(frameline._keys):
+ s = frameline._keys[i]
+ if s.right_tween is False:
+ if self.last_frame == s.idx:
+ found = s.idx
+ break
+ else:
+ pass
+ i = i + 1
+ continue
+
+ if self.last_frame >= s.idx and self.last_frame <= frameline._keys[i+1].idx:
+ found = s.idx
+ break
+ else:
+ pass
+ i = i + 2
+ pass
+ pass
+ if found == -1: return
+ self.last_line.set_tween_type(found,self.tweenTypeSelector.get_active_text())
+ self.last_line.update()
+ self.update()
+
+ def addTweenTypeSelector(self,hbox):
+ tweenbox = gtk.HBox()
+ label = gtk.Label('Tween Type')
+ tweenbox.pack_start(label)
+
+ self.tweenTypeSelector = gtk.combo_box_new_text()
+ self.tweenTypeSelector.append_text('normal')
+ self.tweenTypeSelector.append_text('relocate')
+ self.tweenTypeSelector.append_text('scale')
+ self.tweenTypeSelector.set_active(0)
+ tweenbox.pack_start(self.tweenTypeSelector, expand=False,fill=False)
+ hbox.pack_start(tweenbox,expand=False,fill=False)
+ self.tweenTypeSelector.connect('changed', self.onTweenTypeChange)
def onQuit(self, event):
self.OK = False
diff -r 17cbb862a8c6 -r b5ff72dbc910 pyink/frameline.py
--- a/pyink/frameline.py Thu Dec 09 00:33:41 2010 +0800
+++ b/pyink/frameline.py Thu Dec 09 07:48:46 2010 +0800
@@ -116,7 +116,7 @@
_key_mark_color = 0x000000 # color of marks for key frames.
_key_mark_sz = 4 # width and height of a key frame mark
_tween_color = 0x808080 # color of tween line
- _tween_bgcolors = [0x80ff80, 0xff8080] # bg colors of tween frames
+ _tween_bgcolors = [0x80ff80, 0xff8080,0xffff80] # bg colors of tween frames
# Colors for normal frames
_normal_bgcolors = [0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xcccccc]
_normal_border = 0xaaaaaa # border color of normal frames.
@@ -124,7 +124,8 @@
_hover_border_color = 0xa0a0a0 # border when the pointer over a frame
# tween types
_tween_type_none=0
- _tween_type_shape=3
+ _tween_type_move=1
+ _tween_type_shape=2
FRAME_BUT_PRESS = 'frame-button-press'
@@ -464,6 +465,24 @@
pass
pass
pass
+ def set_tween_type(self,frame_idx,typ):
+ found=False
+ for i in range(0,len(self._keys)):
+ if self._keys[i].idx == frame_idx:
+ idx = i
+ found = True
+ break
+ if not found: return
+ key = self._keys[idx]
+ if typ == 'normal':
+ type = self._tween_type_none
+ elif typ == 'relocate':
+ type = self._tween_type_move
+ elif typ == 'scale':
+ type = self._tween_type_shape
+ if key.left_tween is False and key.right_tween is True:
+ key.right_tween_type = type
+
## \brief Show a mark for the pointer for a frame.
#
@@ -573,7 +592,7 @@
## Tween the key frame specified by an index and the key frame at right.
#
# \see http://www.entheosweb.com/Flash/shape_tween.asp
- def tween(self, idx, _type=0):
+ def tween(self, idx, _type='normal'):
key_indic = [key.idx for key in self._keys]
pos = key_indic.index(idx)
key = self._keys[pos]
@@ -585,8 +604,25 @@
key.right_tween = True
right_key.left_tween = True
- key.right_tween_type = _type
+ if _type == 'normal':
+ key.right_tween_type = self._tween_type_none
+ elif _type == 'relocate':
+ key.right_tween_type = self._tween_type_move
+ elif _type == 'scale':
+ key.right_tween_type = self._tween_type_shape
pass
+ def get_tween_type(self,idx):
+ for i in range(0,len(self._keys)):
+ key = self._keys[i]
+ if key.left_tween is True: continue
+ if key.idx == idx:
+ if key.right_tween_type == self._tween_type_none:
+ return 'normal'
+ elif key.right_tween_type == self._tween_type_move:
+ return 'relocate'
+ elif key.right_tween_type == self._tween_type_shape:
+ return 'scale'
+
## Set active frame
#
@@ -626,11 +662,18 @@
ss.setAttribute("start", str(key.idx+1),True)
ss.setAttribute("ref",key.ref.attribute("id"),True)
ss.setAttribute("end", str(self._keys[i+1].idx+1),True)
+ if self._keys[i].right_tween_type == self._tween_type_none:
+ ss.setAttribute("type", "normal", True)
+ elif self._keys[i].right_tween_type == self._tween_type_move:
+ ss.setAttribute("type", "relocate", True)
+ elif self._keys[i].right_tween_type == self._tween_type_scale:
+ ss.setAttribute("type", "scale", True)
else:
ss = rdoc.createElement("ns0:scene")
node.appendChild(ss)
ss.setAttribute("start", str(key.idx+1),True)
ss.setAttribute("ref",key.ref.attribute("id"),True)
+ ss.setAttribute("type", "normal", True)
## \brief Start future drawing actions
diff -r 17cbb862a8c6 -r b5ff72dbc910 pyink/mbtest.svg
--- a/pyink/mbtest.svg Thu Dec 09 00:33:41 2010 +0800
+++ b/pyink/mbtest.svg Thu Dec 09 07:48:46 2010 +0800
@@ -15,7 +15,7 @@
height="480px"
id="svg2383"
sodipodi:version="0.32"
- inkscape:version="0.48+devel r9764 custom"
+ inkscape:version="0.48+devel r9773 custom"
sodipodi:docname="mbtest.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
@@ -27,13 +27,13 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.6029106"
- inkscape:cx="69.206233"
+ inkscape:cx="238.58561"
inkscape:cy="290.40921"
inkscape:current-layer="layer2"
inkscape:document-units="px"
showgrid="false"
inkscape:window-width="1400"
- inkscape:window-height="974"
+ inkscape:window-height="973"
inkscape:window-x="271"
inkscape:window-y="25"
inkscape:window-maximized="0" />
@@ -180,6 +180,45 @@
y1="28.009714"
x2="104.68548"
y2="28.009714" />
+
+
+
+
+
+
+
+
+
@@ -194,21 +233,30 @@
-
+ ref="s4427"
+ type="normal" />
+ ref="s4159"
+ type="normal" />
+ end="10"
+ type="normal" />
+ ref="s6546"
+ type="normal" />
+
+
-
+ style="display:none"
+ transform="translate(-15.128732,2.0275737)"
+ id="g3303"
+ inkscape:label="action1">
+
+
+
+
-
-
-
+ Action
-
+ id="tspan3301"
+ sodipodi:role="line">Action
+ transform="translate(75.331712,-0.46789912)">
+ style="fill:url(#linearGradient3316-4-8-2);fill-opacity:1;stroke:none;filter:url(#filter3295-1-3-2)" />
+ inkscape:label="action1"
+ id="Backgrounds4326"
+ transform="translate(-15.128732,2.0275737)"
+ style=""
+ inkscape:groupmode="layer">
+
+
+
+
+
+ Action
+
+
+ Select
+
+
+ style="display:none">
@@ -362,7 +474,6 @@
y="0"
width="100"
height="100"
- style="fill:#ff00"
id="rect3116" />
@@ -370,5 +481,5 @@
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer"
- style="display:inline" />
+ style="display:none" />