def _animateExpand(self, value):

        opacityAnim = qc.QPropertyAnimation(self.main_widgetProxy, "opacity")
        opacityAnim.setStartValue(int(not (value)))
        opacityAnim.setEndValue(int(value))
        opacityAnim.setDuration(200)
        opacityAnimCurve = qc.QEasingCurve()
        if value:
            opacityAnimCurve.setType(qc.QEasingCurve.InQuad)

        else:
            opacityAnimCurve.setType(qc.QEasingCurve.OutQuad)

        #####
        size_anim = qc.QPropertyAnimation(self, "geometry")

        geometry = self.geometry()
        width = geometry.width()
        x, y, _, _ = geometry.getCoords()

        size_start = qc.QRect(x, y, width, int(not (value) * 200))
        size_end = qc.QRect(x, y, width, int(value) * 200)

        size_anim.setStartValue(size_start)
        size_anim.setEndValue(size_end)
        size_anim.setDuration(150)

        size_animCurve = qc.QEasingCurve()

        if value:
            size_animCurve.setType(qc.QEasingCurve.InQuad)

        else:
            size_animCurve.setType(qc.QEasingCurve.OutQuad)

        size_anim.setEasingCurve(size_animCurve)

        self._animation = qc.QSequentialAnimationGroup()

        if value:
            self.main_widgetProxy.setOpacity(0.05)
            self._animation.addAnimation(size_anim)
            self._animation.addAnimation(opacityAnim)
        else:
            self.main_widgetProxy.setOpacity(1)
            self._animation.addAnimation(opacityAnim)
            self._animation.addAnimation(size_anim)

        size_anim.valueChanged.connect(self._forceResize)
        self._animation.finished.connect(self._animation.clear)

        if not value:
            self._animation.finished.connect(self.deleteWidgetUI)

        self._animation.start(qc.QAbstractAnimation.DeleteWhenStopped)
Esempio n. 2
0
    def _animateExpand(self, widget, value):
        Proxy = self.opacity_wdt
        opacity_anim = qc.QPropertyAnimation(Proxy, "opacity")
        opacity_anim.setStartValue(not(value))
        opacity_anim.setEndValue(value)
        opacity_anim.setDuration(200)
        opacity_anim_curve = qc.QEasingCurve()

        if value is True:
            opacity_anim_curve.setType(qc.QEasingCurve.InQuad)
        else:
            opacity_anim_curve.setType(qc.QEasingCurve.OutQuad)

        opacity_anim.setEasingCurve(opacity_anim_curve)

        size_anim = qc.QPropertyAnimation(widget, "geometry")
        geometry = widget.geometry()
        height    = geometry.height()
        x, y, _, _ = geometry.getCoords()

        size_start = qc.QRect(x, y, int(not(value)) * 225, height)
        size_end   = qc.QRect(x, y, value * 225, height )

        size_anim.setStartValue(size_start)
        size_anim.setEndValue(size_end)
        size_anim.setDuration(250)

        size_anim_curve = qc.QEasingCurve()

        if value:
            size_anim_curve.setType(qc.QEasingCurve.InSine)
        else:
            size_anim_curve.setType(qc.QEasingCurve.OutCubic)

        size_anim.setEasingCurve(size_anim_curve)

        self._animation = qc.QSequentialAnimationGroup()

        if value:
            Proxy.setOpacity(0)
            self._animation.addAnimation(size_anim)
            self._animation.addAnimation(opacity_anim)
            self.turnAroundLabel.setEnabled(True)

        else:
            Proxy.setOpacity(1)
            self._animation.addAnimation(opacity_anim)
            self._animation.addAnimation(size_anim)
            self.turnAroundLabel.setEnabled(False)

        size_anim.valueChanged.connect(self._forceResize)
        self._animation.finished.connect(self._animation.clear)
        self._animation.start(qc.QAbstractAnimation.DeleteWhenStopped)
Esempio n. 3
0
    def _animateExpand(self, value):
        opacity_anim = QtCore.QPropertyAnimation(self.main_widget_proxy,
                                                 "opacity")

        opacity_anim.setStartValue(not (value))
        opacity_anim.setEndValue(value)
        opacity_anim.setDuration(200)

        opacity_anim_curve = QtCore.QEasingCurve()
        if value:
            opacity_anim_curve.setType(QtCore.QEasingCurve.InQuad)
        else:
            opacity_anim_curve.setType(QtCore.QEasingCurve.OutQuad)
        opacity_anim.setEasingCurve(opacity_anim_curve)

        size_anim = QtCore.QPropertyAnimation(self, 'geometry')

        geometry = self.geometry()
        width = geometry.width()
        x, y, _, _ = geometry.getCoords()

        size_start = QtCore.QRect(x, y, width, int(not (value)) * 150)
        size_end = QtCore.QRect(x, y, width, value * 150)

        size_anim.setStartValue(size_start)
        size_anim.setEndValue(size_end)
        size_anim.setDuration(300)

        size_anim_curve = QtCore.QEasingCurve()
        if value:
            size_anim_curve.setType(QtCore.QEasingCurve.InQuad)
        else:
            size_anim_curve.setType(QtCore.QEasingCurve.OutQuad)
        size_anim.setEasingCurve(size_anim_curve)

        self._animation = QtCore.QSequentialAnimationGroup()
        if value:
            self.main_widget_proxy.setOpacity(1)
            self._animation.addAnimation(size_anim)
            self._animation.addAnimation(opacity_anim)
        else:
            self.main_widget_proxy.setOpacity(0)
            self._animation.addAnimation(opacity_anim)
            self._animation.addAnimation(size_anim)

        size_anim.valueChanged.connect(self._forceResize)
        self._animation.finished.connect(self._animation.clear)

        if not value:
            size_anim.finished.connect(self.deleteWidget)
        size_anim.start(QtCore.QAbstractAnimation.DeleteWhenStopped)
Esempio n. 4
0
    def _camera_lyt_anim(self, value):
        Proxy = self.opacityCamera_wdt
        opacity_anim = qc.QPropertyAnimation(Proxy, "opacity")
        opacity_anim.setStartValue(float(value))
        opacity_anim.setEndValue(float(not(value)))
        opacity_anim.setDuration(5000)
        opacity_anim_curve = qc.QEasingCurve()

        if value:
            #Proxy.setOpacity(float(0))
            opacity_anim_curve.setType(qc.QEasingCurve.InQuad)
            opacity_anim.setEasingCurve(opacity_anim_curve)
            opacity_anim.start(qc.QAbstractAnimation.DeleteWhenStopped)

        else:
            #Proxy.setOpacity(float(1))
            opacity_anim_curve.setType(qc.QEasingCurve.OutQuad)
            opacity_anim.setEasingCurve(opacity_anim_curve)
            opacity_anim.start(qc.QAbstractAnimation.DeleteWhenStopped)
Esempio n. 5
0
 def _scroll_to_bottom(self, *args):
     print('scrollValB4: %s' % self._scrollValB4)
     time.sleep(0.1)
     tmax = 0.3
     curve = QtCore.QEasingCurve(QtCore.QEasingCurve.OutQuad)
     res = 0.01
     steps = tmax / res
     tsteps = 1 / steps
     t = 0.0
     # this = self.main.ui.scrollBar.value()
     scrollEnd = self.main.ui.scrollBar.maximum()
     print('scrollEnd: %s' % scrollEnd)
     if not scrollEnd:
         scrollEnd = self._scrollMaxB4 + 100
     r = scrollEnd - self._scrollValB4
     self.main.ui.scrollBar.setValue(self._scrollValB4)
     while t <= 1.0:
         time.sleep(res)
         t += tsteps
         v = curve.valueForProgress(t)
         scrollval = self._scrollValB4 + (v * r)
         self.main.ui.scrollBar.setValue(scrollval)
Esempio n. 6
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        self.m_iconSize = QtCore.QSize(64, 64)
        self.m_scene = QtGui.QGraphicsScene()

        m_ui = Ui_Form()
        m_ui.setupUi(self)
        m_ui.easingCurvePicker.setIconSize(self.m_iconSize)
        m_ui.easingCurvePicker.setMinimumHeight(self.m_iconSize.height() + 50)
        m_ui.buttonGroup.setId(m_ui.lineRadio, 0)
        m_ui.buttonGroup.setId(m_ui.circleRadio, 1)

        dummy = QtCore.QEasingCurve()
        m_ui.periodSpinBox.setValue(dummy.period())
        m_ui.amplitudeSpinBox.setValue(dummy.amplitude())
        m_ui.overshootSpinBox.setValue(dummy.overshoot())

        m_ui.easingCurvePicker.currentRowChanged.connect(self.curveChanged)
        m_ui.buttonGroup.buttonClicked[int].connect(self.pathChanged)
        m_ui.periodSpinBox.valueChanged.connect(self.periodChanged)
        m_ui.amplitudeSpinBox.valueChanged.connect(self.amplitudeChanged)
        m_ui.overshootSpinBox.valueChanged.connect(self.overshootChanged)

        self.m_ui = m_ui
        self.createCurveIcons()

        pix = QtGui.QPixmap(':/images/qt-logo.png')
        self.m_item = Pixmap(pix)
        self.m_scene.addItem(self.m_item.pixmap_item)
        self.m_ui.graphicsView.setScene(self.m_scene)

        self.m_anim = Animation(self.m_item, 'pos')
        self.m_anim.setEasingCurve(QtCore.QEasingCurve.OutBounce)
        self.m_ui.easingCurvePicker.setCurrentRow(
            int(QtCore.QEasingCurve.OutBounce))

        self.startAnimation()
    def addWidgetSizeAnim(self, widget, onoff):
        self.size_anim = QtCore.QPropertyAnimation(widget, 'geometry')
        geometry = widget.geometry()
        width = geometry.width()
        x, y, _, _ = geometry.getCoords()
        print x, y
        size_start = QtCore.QRect(x, y, width, int(not (onoff)) * 20)
        size_end = QtCore.QRect(x, y, width, onoff * 20)

        self.size_anim.setStartValue(size_start)
        self.size_anim.setEndValue(size_end)
        self.size_anim.setDuration(200)

        size_anim_curve = QtCore.QEasingCurve()
        if onoff:
            size_anim_curve.setType(QtCore.QEasingCurve.InQuad)
        else:
            size_anim_curve.setType(QtCore.QEasingCurve.OutQuad)

        self.size_anim.setEasingCurve(size_anim_curve)

        self.size_anim.valueChanged.connect(self.forceResize)
        self.size_anim.start(QtCore.QAbstractAnimation.DeleteWhenStopped)
Esempio n. 8
0
    def createCurveIcons(self):
        pix = QtGui.QPixmap(self.m_iconSize)
        painter = QtGui.QPainter()

        gradient = QtGui.QLinearGradient(0, 0, 0, self.m_iconSize.height())
        gradient.setColorAt(0.0, QtGui.QColor(240, 240, 240))
        gradient.setColorAt(1.0, QtGui.QColor(224, 224, 224))

        brush = QtGui.QBrush(gradient)

        # The original C++ code uses undocumented calls to get the names of the
        # different curve types.  We do the Python equivalant (but without
        # cheating)
        curve_types = [(n, c) for n, c in QtCore.QEasingCurve.__dict__.items()
                        if isinstance(c, QtCore.QEasingCurve.Type) \
                            and c != QtCore.QEasingCurve.Custom    \
                            and c != QtCore.QEasingCurve.NCurveTypes]
        curve_types.sort(key=lambda ct: ct[1])

        painter.begin(pix)

        for curve_name, curve_type in curve_types:
            painter.fillRect(
                QtCore.QRect(QtCore.QPoint(0, 0), self.m_iconSize), brush)
            curve = QtCore.QEasingCurve(curve_type)

            painter.setPen(QtGui.QColor(0, 0, 255, 64))
            xAxis = self.m_iconSize.height() / 1.5
            yAxis = self.m_iconSize.width() / 3.0
            painter.drawLine(0, xAxis, self.m_iconSize.width(), xAxis)
            painter.drawLine(yAxis, 0, yAxis, self.m_iconSize.height())

            curveScale = self.m_iconSize.height() / 2.0

            painter.setPen(QtCore.Qt.NoPen)

            # Start point.
            painter.setBrush(QtCore.Qt.red)
            start = QtCore.QPoint(
                yAxis, xAxis - curveScale * curve.valueForProgress(0))
            painter.drawRect(start.x() - 1, start.y() - 1, 3, 3)

            # End point.
            painter.setBrush(QtCore.Qt.blue)
            end = QtCore.QPoint(yAxis + curveScale,
                                xAxis - curveScale * curve.valueForProgress(1))
            painter.drawRect(end.x() - 1, end.y() - 1, 3, 3)

            curvePath = QtGui.QPainterPath()
            curvePath.moveTo(QtCore.QPointF(start))
            t = 0.0
            while t <= 1.0:
                to = QtCore.QPointF(
                    yAxis + curveScale * t,
                    xAxis - curveScale * curve.valueForProgress(t))
                curvePath.lineTo(to)
                t += 1.0 / curveScale

            painter.setRenderHint(QtGui.QPainter.Antialiasing, True)
            painter.strokePath(curvePath, QtGui.QColor(32, 32, 32))
            painter.setRenderHint(QtGui.QPainter.Antialiasing, False)

            item = QtGui.QListWidgetItem()
            item.setIcon(QtGui.QIcon(pix))
            item.setText(curve_name)
            self.m_ui.easingCurvePicker.addItem(item)

        painter.end()