示例#1
0
    def append_item(self, item: QGraphicsItem) -> None:
        self.items.append(item)

        col = self.next_col
        row = self.next_row

        x = col * (self.style.tile_width +
                   self.style.spacing_x) + self.style.padding_x
        y = row * (self.style.tile_height +
                   self.style.spacing_y) + self.style.padding_y

        item.setPos(self.x + x + self.center_x_off, self.y + y)

        bottom_y = y + self.style.tile_height + self.style.padding_y

        # calculate next items position
        if self.style.arrangement == TileStyle.Arrangement.ROWS:
            col += 1
            if col == self.columns:
                col = 0
                row += 1
        else:
            row += 1
            if row == self.rows:
                row = 0
                col += 1

        self.next_col = col
        self.next_row = row
        self.height = bottom_y
示例#2
0
文件: layout.py 项目: Grumbel/dirtool
    def append_item(self, item: QGraphicsItem) -> None:
        self.items.append(item)

        col = self.next_col
        row = self.next_row

        x = col * (self.style.tile_width + self.style.spacing_x) + self.style.padding_x
        y = row * (self.style.tile_height + self.style.spacing_y) + self.style.padding_y

        item.setPos(self.x + x + self.center_x_off,
                    self.y + y)

        bottom_y = y + self.style.tile_height + self.style.padding_y

        # calculate next items position
        if self.style.arrangement == TileStyle.Arrangement.ROWS:
            col += 1
            if col == self.columns:
                col = 0
                row += 1
        else:
            row += 1
            if row == self.rows:
                row = 0
                col += 1

        self.next_col = col
        self.next_row = row
        self.height = bottom_y
示例#3
0
 def add_animation(self, item: QGraphicsItem, position: int):
     item.setParentItem(self)
     item.setPos(self.source_point)
     item.update()
     animated_object = AnimatedObject()
     animated_object.item = item
     animated_object.position = position
     self.animations.append(animated_object)
示例#4
0
    def addAnnotationItem(self, item: QGraphicsItem, pos: QPointF):
        scene = self.scene()
        if scene is None:
            return

        if isinstance(item, (ArrowItem, RectItem, EllipseItem)):
            item.setPen(
                QPen(Qt.black, scene.getDefaultPenSizeFromRect(),
                     Qt.SolidLine))

        self._undo_stack.push(AddCommand(item, scene))
        item.setPos(pos)
        scene.annotationAdded.emit(item)

        return item