Unverified Commit d2668a97 authored by dmMaze's avatar dmMaze Committed by GitHub
Browse files

Merge pull request #30 from dmMaze/vertical_type_rework

Vertical type rework
parents 18a65651 96f44868
Loading
Loading
Loading
Loading
+40 −17
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ TransTextEdit {
QComboBox {
    height: 40px;
    font-size: 20px;
    padding-left: 16px;
    padding-left: 12px;
    border: 1px solid whitesmoke;
}

@@ -85,9 +85,9 @@ QComboBox::down-arrow {
}

QFontComboBox#FontFamilyBox {
    width: 200px;
    width: 160px;
    height: 40px;
    font-size: 24px;
    font-size: 20px;
    padding-right: 20px;
    padding-left: 10px;
    border-color: #b3b6bf;
@@ -105,17 +105,19 @@ QFontComboBox#FontFamilyBox::down-arrow {
    margin-right: 10px;
}

QComboBox#FontSizeComboBox {
SizeComboBox {
    padding-left: 8px;
    padding-right: 5px;
    font-size: 24px;
    font-size: 20px;
    width: 52px;
    border-color: #b3b6bf;
}

QComboBox#FontSizeComboBox::hover {
SizeComboBox::hover {
    border: 1px solid rgb(30, 147, 229);
}

QComboBox#FontSizeComboBox::down-arrow {
SizeComboBox::down-arrow {
    image: url(data/icons/combobox_arrow.svg);
    width: 42px;
    height: 16px;
@@ -123,27 +125,43 @@ QComboBox#FontSizeComboBox::down-arrow {
    margin-right: 5px;
}

QLabel#lineSpacingLabel {
    image: url(data/icons/fontfmt_linespacing.svg);
    max-width: 38px;
    max-height: 38px;
    min-width: 38px;
    min-height: 38px;
}

QLabel#letterSpacingLabel {
    image: url(data/icons/fontfmt_letterspacing.svg);
    max-width: 42px;
    max-height: 42px;
    min-width: 42px;
    min-height: 42px;
}

ColorPicker {
    max-height: 46px;
    min-height: 46px;
    min-width: 46px;
    max-width: 46px;
    border: 4px solid #b3b6bf;
    max-height: 38px;
    min-height: 38px;
    min-width: 38px;
    max-width: 38px;
    border: 3px solid #b3b6bf;
}

ColorPicker::hover {
    border: 4px solid rgb(30, 147, 229);
    border: 3px solid rgb(30, 147, 229);
}

AlignmentChecker {
    /* max-height: 30px; */
    max-width: 52px;
    /* max-width: 52px; */
    margin: 0px;
}

AlignmentChecker::indicator {
    height: 50px;
    width: 50px;
    height: 42px;
    width: 42px;
    border: 2px solid #b3b6bf;
}

@@ -157,6 +175,8 @@ AlignmentChecker::indicator:hover {

AlignmentChecker#AlignLeftChecker::indicator {
    border-right: none;
    min-width: 54px;
    max-width: 54px;
    image: url(data/icons/fontfmt_alignl.svg);
}

@@ -167,7 +187,8 @@ AlignmentChecker#AlignLeftChecker::indicator:checked {
AlignmentChecker#AlignCenterChecker::indicator {
    border-right: none;
    border-left: none;
    width: 52px;
    min-width: 54px;
    max-width: 54px;
    image: url(data/icons/fontfmt_alignc.svg);
}

@@ -177,6 +198,8 @@ AlignmentChecker#AlignCenterChecker::indicator:checked {

AlignmentChecker#AlignRightChecker::indicator {
    border-left: none;
    min-width: 52px;
    max-width: 52px;
    image: url(data/icons/fontfmt_alignr.svg);
}

+1 −0
Original line number Diff line number Diff line
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1613973513102" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1676" fill="#697187" width="128" height="128" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"></style></defs><path d="M298.666667 725.333333h426.666666v-106.666666l149.333334 149.333333-149.333334 149.333333V810.666667H298.666667v106.666666L149.333333 768 298.666667 618.666667V725.333333z m256-469.333333v384h-85.333334V256H213.333333V170.666667h597.333334v85.333333h-256z" p-id="1785" fill="#697187"></path></svg>
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1613973513102" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1676" width="128" height="128" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"></style></defs><path d="M298.666667 792.96l55.168-55.125333a42.666667 42.666667 0 0 1 56.32-3.541334l4.010666 3.541334a42.666667 42.666667 0 0 1 3.541334 56.32l-3.541334 4.010666-128 128-1.877333 1.792-2.901333 2.346667-4.693334 3.029333-2.645333 1.322667-3.456 1.450667-3.242667 1.024-6.357333 1.28L256 938.666667l-3.498667-0.170667-5.077333-0.682667-4.736-1.28-4.736-1.877333-4.181333-2.218667-3.157334-2.133333-4.778666-4.138667-128-128a42.666667 42.666667 0 0 1 56.32-63.872l4.010666 3.541334L213.333333 792.96V231.04L158.165333 286.165333l-4.010666 3.541334A42.666667 42.666667 0 0 1 94.293333 229.845333l3.541334-4.010666 128-128 4.778666-4.138667 3.157334-2.133333 4.181333-2.218667 4.693333-1.877333 4.778667-1.28 5.077333-0.682667L256 85.333333l4.992 0.298667 6.357333 1.237333 3.242667 1.024 3.456 1.450667 2.602667 1.28 4.736 3.072 2.901333 2.346667 1.877333 1.792 128 128 3.541334 4.010666a42.666667 42.666667 0 0 1 0 52.309334l-3.541334 4.010666-4.010666 3.541334a42.666667 42.666667 0 0 1-52.309334 0l-4.010666-3.541334L298.666667 231.04v561.92zM896 810.666667a42.666667 42.666667 0 0 1 0 85.333333h-341.333333a42.666667 42.666667 0 0 1 0-85.333333h341.333333z m0-341.333334a42.666667 42.666667 0 0 1 0 85.333334h-341.333333a42.666667 42.666667 0 0 1 0-85.333334h341.333333z m0-341.333333a42.666667 42.666667 0 0 1 0 85.333333h-341.333333a42.666667 42.666667 0 0 1 0-85.333333h341.333333z" p-id="2141" fill="#697187"></path></svg>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ class TextBlock(object):
                       bg_g = 0,
                       bg_b = 0,                
                       line_spacing = 1.,
                       letter_spacing = 1.,
                       font_family: str = "",
                       bold: bool = False,
                       underline: bool = False,
@@ -78,6 +79,7 @@ class TextBlock(object):
        self.alpha = alpha
        self.rich_text = rich_text
        self.line_spacing = line_spacing
        self.letter_spacing = letter_spacing
        self._alignment = _alignment
        self._target_lang = _target_lang

+11 −11
Original line number Diff line number Diff line
@@ -103,7 +103,6 @@ class Canvas(QGraphicsScene):
        self.creating_textblock = False
        self.create_block_origin: QPointF = None
        self.editing_textblkitem: TextBlkItem = None
        self.hovering_textblkitem: TextBlkItem = None

        self.gv = CustomGV(self)
        self.gv.setAlignment(Qt.AlignmentFlag.AlignCenter)
@@ -148,12 +147,14 @@ class Canvas(QGraphicsScene):
        self.imgLayer.setParentItem(self.baseLayer)
        self.maskLayer.setParentItem(self.baseLayer)
        self.drawingLayer.setParentItem(self.baseLayer)
        self.addItem(self.txtblkShapeControl)
        self.txtblkShapeControl.setParentItem(self.inpaintLayer)

        self.scalefactor_changed.connect(self.onScaleFactorChanged)
        self.selectionChanged.connect(self.on_selection_changed)     
        self.stroke_path_item: StrokeItem = None

        self.editor_index = 0 # 0: drawing 1: text editor

    def scaleUp(self):
        self.scaleImage(1 + CANVAS_SCALE_SPEED)

@@ -209,6 +210,7 @@ class Canvas(QGraphicsScene):
        self.old_size = sbr.size()
        self.scale_factor = s_f
        self.baseLayer.setScale(self.scale_factor)
        self.txtblkShapeControl.updateScale(self.scale_factor)

        self.adjustScrollBar(self.gv.horizontalScrollBar(), factor)
        self.adjustScrollBar(self.gv.verticalScrollBar(), factor)
@@ -257,6 +259,7 @@ class Canvas(QGraphicsScene):
        item.setParentItem(self.drawingLayer)

    def startCreateTextblock(self, pos: QPointF, hide_control: bool = False):
        pos = pos / self.scale_factor
        self.creating_textblock = True
        self.create_block_origin = pos
        self.gv.setCursor(Qt.CursorShape.CrossCursor)
@@ -280,7 +283,7 @@ class Canvas(QGraphicsScene):

    def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent) -> None:
        if self.creating_textblock:
            self.txtblkShapeControl.setRect(QRectF(self.create_block_origin, event.scenePos()).normalized())
            self.txtblkShapeControl.setRect(QRectF(self.create_block_origin, event.scenePos() / self.scale_factor).normalized())
        elif self.stroke_path_item is not None:
            self.stroke_path_item.addNewPoint(self.imgLayer.mapFromScene(event.scenePos()))
        elif self.scale_tool_mode:
@@ -293,9 +296,8 @@ class Canvas(QGraphicsScene):
        return super().mouseMoveEvent(event)

    def mousePressEvent(self, event: QGraphicsSceneMouseEvent) -> None:
        if self.textblock_mode:
        if self.textblock_mode and len(self.selectedItems()) == 0:
            if event.button() == Qt.MouseButton.RightButton:
                if self.hovering_textblkitem is None:
                return self.startCreateTextblock(event.scenePos())
        elif self.creating_normal_rect:
            return self.startCreateTextblock(event.scenePos(), hide_control=True)
@@ -324,7 +326,7 @@ class Canvas(QGraphicsScene):

    @property
    def creating_normal_rect(self):
        return self.image_edit_mode == ImageEditMode.RectTool
        return self.image_edit_mode == ImageEditMode.RectTool and self.editor_index == 0

    def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent) -> None:
        if self.creating_textblock:
@@ -349,8 +351,8 @@ class Canvas(QGraphicsScene):
        self.clearSelection()
        self.setProjSaveState(False)
        self.editing_textblkitem = None
        self.hovering_textblkitem = None
        self.txtblkShapeControl.setBlkItem(None)
        self.stroke_path_item
        self.setImageLayer()
        self.setInpaintLayer()
        self.setMaskLayer()
@@ -382,7 +384,6 @@ class Canvas(QGraphicsScene):
    def setPaintMode(self, painting: bool):
        if painting:
            self.editing_textblkitem = None
            self.hovering_textblkitem = None
            self.textblock_mode = False
            self.maskLayer.setVisible(True)
        else:
@@ -405,7 +406,7 @@ class Canvas(QGraphicsScene):
        self.textblock_mode = mode

    def contextMenuEvent(self, event: QGraphicsSceneContextMenuEvent):
        if self.hovering_textblkitem or self.editing_textblkitem:
        if len(self.selectedItems()) != 0:
            menu = QMenu()
            delete_act = menu.addAction(self.tr("Delete"))
            format_act = menu.addAction(self.tr("Apply font formatting"))
@@ -424,7 +425,6 @@ class Canvas(QGraphicsScene):
        self.creating_textblock = False
        self.create_block_origin = None
        self.editing_textblkitem = None
        self.hovering_textblkitem = None
        if self.stroke_path_item is not None:
            self.removeItem(self.stroke_path_item)
            self.stroke_path_item = None
Loading