コード例 #1
0
    def __init__(self, scene, tabs=None, parent=None):
        super(PanoramaView, self).__init__(scene, parent)

        self.tabs = tabs or {}

        self.header_items = []
        self.header_animations = []
        self.content_items = []
        self.content_animations = []

        self.current_index = 0
        self.mouse_x_position = 0
        self.prev_x_position = 0

        # set blackish background
        self.setStyleSheet(Style.background_style)

        # create opacity animator
        self.opacity_animator = QtCore.QPropertyAnimation()
        self.opacity_animator.setDuration(Style.animation_time)
        self.opacity_animator.setPropertyName("opacity")
        self.opacity_animator.setEasingCurve(QtCore.QEasingCurve.Linear)
        self.opacity_animator.setStartValue(0.3)
        self.opacity_animator.setEndValue(1.0)

        # create animation groups
        self.content_animation_group = QtCore.QParallelAnimationGroup()
        self.header_animation_group = QtCore.QParallelAnimationGroup()

        # create the rest of the ui
        self._create_top_bar()
        self._create_metro_tab_bar()
        self._create_content_items()
コード例 #2
0
    def update(self):
        '''Animate the view to match sorting and filtering requests'''
        logger.debug('updating view')

        self.deletedTaskWidgets = [
            tw for tw in self.taskWidgets if tw.task.index == -2
        ]
        taskWidgetsHeight = len(self.taskWidgets) * (
            TaskWidget.TASKWIDGETHEIGHT * TaskWidget.TASKWIDGETSPACING)
        self.taskContainer.resize(
            self.scrollArea.width() - 20,
            max(taskWidgetsHeight, self.scrollArea.height()))

        self.animGroup = QtCore.QParallelAnimationGroup()
        animGroupForDeletedWidget = QtCore.QParallelAnimationGroup()
        animGroupForDeletedWidget.finished.connect(self.deleteTaskWidget)

        for taskWidget in self.taskWidgets:
            moveAnimation = QtCore.QPropertyAnimation(taskWidget, 'pos')
            moveAnimation.setDuration(1000)
            moveAnimation.setStartValue(taskWidget.pos())
            moveAnimation.setEndValue(taskWidget.getNewPosition())

            if taskWidget.task.index == -2:
                # DELETED WIDGET
                moveAnimation.setEasingCurve(QtCore.QEasingCurve.InCubic)
                animGroupForDeletedWidget.addAnimation(moveAnimation)
            else:
                moveAnimation.setEasingCurve(QtCore.QEasingCurve.OutCubic)
                self.animGroup.addAnimation(moveAnimation)
            taskWidget.update()
        # GO
        self.animGroup.start()

        # OVERLAP ANIMNATION FOR DELETED WIDGETS IN CASE OF RAPID TASK DELETION
        if animGroupForDeletedWidget.animationCount():
            self.animGroupsDeleted.append(animGroupForDeletedWidget)
            animGroupForDeletedWidget.start()

        logger.debug('finished updating view')
コード例 #3
0
    def showSelectionInPuzzleView(self, selectedItems, deselectedItems):
        selectionChanged = False

        # update the selected cells:
        for itemRange in selectedItems:
            index = itemRange.topLeft()
            index = index.sibling(index.row(), 0)
            # iterate the ranges in this row
            while True:
                if (index == QtCore.QModelIndex()):
                    break
                if (not index.isValid()):
                    break

                item = self.constraintModel.getItem(index)
                if (isinstance(item, (ConstraintProxyItem, CellProxyItem,
                                      ReferencedCellProxyItem, GridProxyItem,
                                      ConstraintGroupProxyItem))):
                    #self.selectedCells |= item.getCells()
                    selectionChanged = True
                    self.selectedItems.add(item)

                # check whether or not to calculate the next index
                if (index.row() + 1 < itemRange.bottomRight().row()):
                    index = index.sibling(index.row() + 1, 0)
                else:
                    break

        # remove the de-selected cells:
        for itemRange in deselectedItems:
            index = itemRange.topLeft()
            index = index.sibling(index.row(), 0)
            # iterate the ranges in this row
            while True:
                if (index == QtCore.QModelIndex()):
                    break
                if (not index.isValid()):
                    break

                item = self.constraintModel.getItem(index)
                if (item in self.selectedItems):
                    self.selectedItems.remove(item)
                    selectionChanged = True
                # check whether or not to calculate the next index
                if (index.row() + 1 < itemRange.bottomRight().row()):
                    index = index.sibling(index.row() + 1, 0)
                else:
                    break

        if (selectionChanged):
            # first copy the reference to the current state to the previous state

            self.trans1, self.trans2 = self.trans2, self.trans1

            self.previousSelectionState, self.currentSelectionState = self.currentSelectionState, self.previousSelectionState

            selectedCells = set()

            for item in self.selectedItems:
                selectedCells |= item.getCells()

            group = QtCore.QParallelAnimationGroup()

            for cell in self.puzzlePieceProxies:
                #it = self.puzzlePieces[cell]
                it = self.puzzlePieceProxies[cell]

                animation = QtCore.QPropertyAnimation(it, "backgroundColor")

                animation.setDuration(200)
                animation.setEasingCurve(QtCore.QEasingCurve.InOutQuad)

                group.addAnimation(animation)

                if cell in selectedCells:
                    self.currentSelectionState.assignProperty(
                        it, "backgroundColor", QtGui.QColor(255, 0, 0, 100))
                else:
                    self.currentSelectionState.assignProperty(
                        it, "backgroundColor", QtGui.QColor(255, 0, 0, 0))

            for anim in self.trans1.animations():
                self.trans1.removeAnimation(anim)

            self.trans1.addAnimation(group)

            self.showNextSelectionState.emit()
コード例 #4
0
    # Ui.
    view = View(scene)
    view.setWindowTitle("Animated Tiles")
    view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)
    view.setBackgroundBrush(QtGui.QBrush(bgPix))
    view.setCacheMode(QtGui.QGraphicsView.CacheBackground)
    view.setRenderHints(QtGui.QPainter.Antialiasing
                        | QtGui.QPainter.SmoothPixmapTransform)
    view.show()

    states = QtCore.QStateMachine()
    states.addState(rootState)
    states.setInitialState(rootState)
    rootState.setInitialState(centeredState)

    group = QtCore.QParallelAnimationGroup()
    for i, item in enumerate(items):
        anim = QtCore.QPropertyAnimation(item, 'pos')
        anim.setDuration(750 + i * 25)
        anim.setEasingCurve(QtCore.QEasingCurve.InOutBack)
        group.addAnimation(anim)

    trans = rootState.addTransition(ellipseButton.pressed, ellipseState)
    trans.addAnimation(group)

    trans = rootState.addTransition(figure8Button.pressed, figure8State)
    trans.addAnimation(group)

    trans = rootState.addTransition(randomButton.pressed, randomState)
    trans.addAnimation(group)