Beispiel #1
0
 def load_pixmaps(self, mask: qtg.QPixmap, image: qtg.QPixmap):
     self.top_container.load_pixmap(mask)
     self.backdrop_container.load_pixmap(image)
     self._max_pixmap_dimension = max(mask.width(), mask.height())
     self._last_midpoint = qtc.QPoint(
         self.horizontalScrollBar().value() + self.width() / 2,
         self.verticalScrollBar().value() + self.height() / 2)
Beispiel #2
0
    def slideInWgt(self, newwidget):
        if self.m_active:
            return

        self.m_active = True

        _now = self.currentIndex()
        _next = self.indexOf(newwidget)

        if _now == _next:
            self.m_active = False
            return

        offsetx, offsety = self.frameRect().width(), self.frameRect().height()
        self.widget(_next).setGeometry(self.frameRect())

        if not self.m_direction == Qt.Orientation.Horizontal:
            if _now < _next:
                offsetx, offsety = 0, -offsety
            else:
                offsetx = 0
        else:
            if _now < _next:
                offsetx, offsety = -offsetx, 0
            else:
                offsety = 0

        pnext = self.widget(_next).pos()
        pnow = self.widget(_now).pos()
        self.m_pnow = pnow

        offset = QtCore.QPoint(offsetx, offsety)
        self.widget(_next).move(pnext - offset)
        self.widget(_next).show()
        self.widget(_next).raise_()

        anim_group = QtCore.QParallelAnimationGroup(
            self, finished=self.animationDoneSlot
        )

        for index, start, end in zip(
            (_now, _next), (pnow, pnext - offset), (pnow + offset, pnext)
        ):
            animation = QtCore.QPropertyAnimation(
                self.widget(index),
                b"pos",
                duration=self.m_speed,
                easingCurve=self.m_animationtype,
                startValue=start,
                endValue=end,
            )
            anim_group.addAnimation(animation)

        self.m_next = _next
        self.m_now = _now
        self.m_active = True
        anim_group.start(QtCore.QAbstractAnimation.DeletionPolicy.DeleteWhenStopped)
Beispiel #3
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        self.m_direction = Qt.Orientation.Horizontal
        self.m_speed = 300
        self.m_animationtype = QtCore.QEasingCurve.Type.OutCubic
        self.m_now = 0
        self.m_next = 0
        self.m_wrap = False
        self.m_pnow = QtCore.QPoint(0, 0)
        self.m_active = False
Beispiel #4
0
    def set_zoom(self):
        if (self._zoom_last_x == None or self._zoom_last_y == None
                or self._zoom_last_x == 0 or self._zoom_last_y == 0):
            return

        self.top_container.set_zoom(self._max_pixmap_dimension)
        zoom_change_x = self.top_container.pixmap().width() / self._zoom_last_x
        self.backdrop_container.set_zoom(self._max_pixmap_dimension)
        zoom_change_y = self.top_container.pixmap().height(
        ) / self._zoom_last_y

        scaled_midpoint = qtc.QPoint(self._last_midpoint.x() * zoom_change_x,
                                     self._last_midpoint.y() * zoom_change_y)
        self.horizontalScrollBar().setValue(
            round(self.horizontalScrollBar().value() + scaled_midpoint.x() -
                  self._last_midpoint.x()))
        self.verticalScrollBar().setValue(
            round(self.verticalScrollBar().value() + scaled_midpoint.y() -
                  self._last_midpoint.y()))

        self._last_midpoint.setX(self.horizontalScrollBar().value() +
                                 self.width() / 2)
        self._last_midpoint.setY(self.verticalScrollBar().value() +
                                 self.height() / 2)