ralsina / marave

Automatically exported from code.google.com/p/marave
GNU General Public License v2.0
0 stars 2 forks source link

Opacity animations with Qt4.5 #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There are no opacity animations for Qt4.5.
The following patch adds them although I think it might be wise to have a 
way to disable them as it might make things slow on some systems:

--- a/marave/main.py
+++ b/marave/main.py
@@ -179,20 +179,25 @@ def fadein(thing, target=1., thendo=None):
         if thendo:
             thing.anim.finished.connect(thendo)
     else:
-        # FIXME maybe implement a timeline based opacity for 
QGraphicsItems
         if isinstance(thing, QtGui.QGraphicsItem):
-            thing.setOpacity(target)
-            if (target):
-                thing.show()
-            else:
-                thing.hide()
-        else:
-            thing.proxy.setOpacity(target)
-            if (target):
-                thing.proxy.show()
-            else:
-                thing.proxy.hide()
-        if thendo: thendo()
+           w = thing
+       else:
+           w = thing.proxy
+       w.show()
+       w.startOpacity = w.opacity()
+       w.endOpacity = target
+       def animateOpacity(v):
+           op = v*(w.endOpacity-w.startOpacity)+w.startOpacity
+           w.setOpacity(op)
+       def animationFinished():
+           if(w.endOpacity == 0):
+               w.hide()
+           if thendo: thendo()
+       thing.tline = QtCore.QTimeLine(200)         
+       thing.tline.setCurveShape(QtCore.QTimeLine.LinearCurve)
+       thing.tline.valueChanged.connect(animateOpacity)
+       thing.tline.finished.connect(animationFinished)
+       thing.tline.start()

 def fadeout(thing, thendo=None):
     fadein(thing, 0, thendo)

Original issue reported on code.google.com by filipe.c...@gmail.com on 3 Mar 2010 at 8:17

GoogleCodeExporter commented 9 years ago
I will commit the patch as r447 as soon as SVN becomes R/W again.

Original comment by roberto.alsina on 5 Mar 2010 at 8:34

GoogleCodeExporter commented 9 years ago
Commited the patch, and also added a --no-animation option in r449.

I think that's all for this Issue, so closing it.

Original comment by roberto.alsina on 6 Mar 2010 at 1:59