changeset 1359:5313bbfafa67

Fix issue of chain of reference for opacity and matrix
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 16 Feb 2011 15:07:44 +0800
parents cd0c0c7547b4
children f89d3ee130de
files pyink/dom_event.py pyink/tween.py
diffstat 2 files changed, 27 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/dom_event.py	Wed Feb 16 15:07:44 2011 +0800
+++ b/pyink/dom_event.py	Wed Feb 16 15:07:44 2011 +0800
@@ -13,7 +13,7 @@
     def notifyChildRemoved(self, node, child, prev):
         if self.type == 'DOMNodeRemoved':
 	    self.func(node, child)
-    def notifyChildOrderChanged(self,node,child,prev):
+    def notifyChildOrderChanged(self, node, child, old_prev, new_prev):
         pass
     def notifyContentChanged(self,node,old_content,new_content):
         if self.type == 'DOMSubtreeModified':
--- a/pyink/tween.py	Wed Feb 16 15:07:44 2011 +0800
+++ b/pyink/tween.py	Wed Feb 16 15:07:44 2011 +0800
@@ -189,7 +189,7 @@
 
 
 def _apply_animation_attrs(ani_attrs, node):
-    for attr in ('x', 'y', 'width', 'height', 'opacity', 'display'):
+    for attr in ('x', 'y', 'width', 'height'):
 	if attr in ani_attrs:
 	    node.setAttribute(attr, str(ani_attrs[attr]))
 	    pass
@@ -307,40 +307,38 @@
 	    pass
 	pass
 
-    if 'opacity' in names:
-	if 'opacity' not in attrs1:
-	    attrs1['opacity'] = 1.0
-	    pass
-	if 'opacity' not in attrs2:
-	    attrs2['opacity'] = 1.0
-	    pass
-
-	if node2.name() == 'svg:use':
-	    attrs2['opacity'] = attrs2['opacity'] * attrs1['opacity']
+    defaults = {'x': 0, 'y': 0,
+		'width': 0, 'height': 0,
+		'opacity': 1.0, 'display': 'inline'}
+    
+    for attrname in defaults:
+	if attrname in names:
+	    if attrname not in attrs1:
+		attrs1[attrname] = defaults[attrname]
+		pass
+	    if attrname not in attrs2:
+		attrs2[attrname] = defaults[attrname]
+		pass
 	    pass
 	pass
 
-    if 'display' in names:
-	if 'display' not in attrs1:
-	    attrs1['display'] = ''
-	    pass
-	if 'display' not in attrs2:
-	    attrs2['display'] = ''
-	    pass
-	pass
-    
-    for name in 'x y width height'.split():
-	if name in names:
-	    if name not in attrs1:
-		attrs1[name] = 0
-		pass
-	    if name not in attrs2:
-		attrs2[name] = 0
-		pass
+    if node2.name() == 'svg:use':
+	accumulators = {'opacity':
+			    (lambda attr_v1, attr_v2: attr_v1 * attr_v2),
+			'transform':
+			    (lambda m1, m2: (_mulA(m2[0], m1[0]), m2[1]))
+			}
+	for attrname in accumulators:
+	    if attrname not in names:
+		continue
+	    accumulator = accumulators[attrname]
+	    acc = accumulator(attrs1[attrname], attrs2[attrname])
+	    attrs2[attrname] = acc
 	    pass
 	pass
     pass
 
+
 class TweenObject(object):
     TWEEN_TYPE_NORMAL = 0
     #TWEEN_TYPE_RELOCATE = 1