Commit a6353547 authored by dmMaze's avatar dmMaze
Browse files

move command bugfix

parent c9fa7c8b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ class TextBlock(object):
        min_bbox = np.array([[min_x, min_y, max_x, min_y, max_x, max_y, min_x, max_y]])
        if angled and rotate_back:
            min_bbox = rotate_polygons(center, min_bbox, -self.angle)
        return min_bbox.reshape(-1, 4, 2)
        return min_bbox.reshape(-1, 4, 2).astype(np.int64)

    def normalizd_width_list(self) -> List[float]:
        angled, center, polygons = self.unrotated_polygons()
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ PUNSET_HALF = {chr(i) for i in range(0x21, 0x7F)}

# https://www.w3.org/TR/2022/DNOTE-clreq-20220801/#tables_of_chinese_punctuation_marks
# https://www.w3.org/TR/2022/DNOTE-clreq-20220801/#glyphs_sizes_and_positions_in_character_faces_of_punctuation_marks
PUNSET_PAUSEORSTOP = {'', '', '', '', '', '', '', '', '', '', '', ''}     # dont need to rotate, 
PUNSET_PAUSEORSTOP = {'', '', '', '', '', '', '', '', '', '', '', '', ''}     # dont need to rotate, 
PUNSET_BRACKETL = {'', '', '', '', '', '', '', '', '', '', '', ''}
PUNSET_BRACKETR = {'', '', '', '', '', '', '', '', '', '', '', ''}
PUNSET_BRACKET = PUNSET_BRACKETL.union(PUNSET_BRACKETR)
+13 −11
Original line number Diff line number Diff line
from typing import List, Union, Tuple

from qtpy.QtGui import QTextCursor
from qtpy.QtCore import QPointF
try:
    from qtpy.QtWidgets import QUndoCommand
except:
@@ -44,31 +45,32 @@ class MoveBlkItemsCommand(QUndoCommand):
    def __init__(self, items: List[TextBlkItem], shape_ctrl: TextBlkShapeControl):
        super(MoveBlkItemsCommand, self).__init__()
        self.items = items
        self.old_pos_lst = []
        self.new_pos_lst = []
        self.old_pos_lst: List[QPointF] = []
        self.new_pos_lst: List[QPointF] = []
        self.shape_ctrl = shape_ctrl
        for item in items:
            self.old_pos_lst.append(item.oldPos)
            self.new_pos_lst.append(item.pos())
            padding = item.padding()
            padding = QPointF(padding, padding)
            self.old_pos_lst.append(item.oldPos + padding)
            self.new_pos_lst.append(item.pos() + padding)
            item.oldPos = item.pos()

    def redo(self):
        for item, new_pos in zip(self.items, self.new_pos_lst):
            item.setPos(new_pos)
            padding = item.padding()
            padding = QPointF(padding, padding)
            item.setPos(new_pos - padding)
            if self.shape_ctrl.blk_item == item and self.shape_ctrl.pos() != new_pos:
                self.shape_ctrl.setPos(new_pos)

    def undo(self):
        for item, old_pos in zip(self.items, self.old_pos_lst):
            item.setPos(old_pos)
            padding = item.padding()
            padding = QPointF(padding, padding)
            item.setPos(old_pos - padding)
            if self.shape_ctrl.blk_item == item and self.shape_ctrl.pos() != old_pos:
                self.shape_ctrl.setPos(old_pos)

    def mergeWith(self, command: QUndoCommand):
        if command.old_pos_lst == self.old_pos_lst:
            return True
        return False


class ApplyFontformatCommand(QUndoCommand):
    def __init__(self, items: List[TextBlkItem], trans_widget_lst: List[TransTextEdit], fontformat: FontFormat):