From e7bb1eb3a60fd3a5181db433c90164f487192ea0 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 10 Mar 2012 01:07:24 +0000 Subject: [PATCH] PatchCanvas: remove abstract line, add fade-anim class --- src/patchcanvas.py | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/patchcanvas.py b/src/patchcanvas.py index a0794f2..24fffaa 100644 --- a/src/patchcanvas.py +++ b/src/patchcanvas.py @@ -18,7 +18,7 @@ # Imports (Global) from PyQt4.QtCore import pyqtSlot, qDebug, qCritical, qFatal, Qt, QObject, SIGNAL, SLOT -from PyQt4.QtCore import QLineF, QPointF, QRectF, QSettings, QTimer +from PyQt4.QtCore import QAbstractAnimation, QLineF, QPointF, QRectF, QSettings, QTimer from PyQt4.QtGui import QColor, QLinearGradient, QPen, QPolygonF, QPainter, QPainterPath from PyQt4.QtGui import QCursor, QFont, QFontMetrics, QInputDialog, QLineEdit, QMenu from PyQt4.QtGui import QGraphicsScene, QGraphicsItem, QGraphicsLineItem, QGraphicsPathItem @@ -1120,32 +1120,41 @@ class PatchScene(QGraphicsScene): QGraphicsScene.wheelEvent(self, event) # ------------------------------------------------------------------------------ -# abstractcanvasline.h -# NOTE - unused +# canvasfadeanimation.cpp -class AbstractCanvasLine(object): - def __init__(self): - object.__init__(self) +class CanvasFadeAnimation(QAbstractAnimation): + def __init__(self, item, show, parent=None): + QAbstractAnimation.__init__(self, parent) - def deleteFromScene(self): - pass + self.m_show = show + self.m_duration = 0 + self.m_item = item - def isLocked(self): - return False + def setDuration(self, time): + if (self.m_show == False and self.m_item.opacity() == 0): + self._duration = 0 + else: + self.m_item.show() + self.m_duration = time - def setLocked(self, yesno): - pass + def duration(self): + return self.m_duration - def isLineSelected(self): - return False + def updateCurrentTime(self, time): + if (self.m_duration == 0): + return - def setLineSelected(self, yesno): - pass + if (self.m_show): + value = float(time)/self.m_duration + else: + value = 1.0-(float(time)/self.m_duration) - def updateLinePos(self): + self.m_item.setOpacity(value) + + def updateDirection(self, direction): pass - def setZValue(self, z): + def updateState(self, oldState, newState): pass # ------------------------------------------------------------------------------