Loading ui/fontformat_commands.py +13 −10 Original line number Diff line number Diff line Loading @@ -41,12 +41,12 @@ def wrap_fntformat_input(values: str, blkitems: List[TextBlkItem], is_global: bo values = [values] * len(blkitems) return blkitems, values def font_formating(push_undostack: bool = False): def font_formating(push_undostack: bool = False, is_property = True): def func_wrapper(formatting_func): def wrapper(param_name: str, values: str, act_ffmt: FontFormat, is_global: bool, blkitems: List[TextBlkItem] = None, set_focus: bool = False, *args, **kwargs): if is_global: if is_global and is_property: if hasattr(act_ffmt, param_name): act_ffmt[param_name] = values else: Loading @@ -54,6 +54,7 @@ def font_formating(push_undostack: bool = False): blkitems, values = wrap_fntformat_input(values, blkitems, is_global) if len(blkitems) > 0: if is_property: act_ffmt[param_name] = values[0] if push_undostack: params = copy.deepcopy(kwargs) Loading Loading @@ -142,14 +143,16 @@ def ffmt_change_stroke_width(param_name: str, values: float, act_ffmt: FontForma def ffmt_change_font_size(param_name: str, values: float, act_ffmt: FontFormat, is_global: bool, blkitems: List[TextBlkItem], clip_size=False, **kwargs): set_kwargs = global_default_set_kwargs if is_global else local_default_set_kwargs for blkitem, value in zip(blkitems, values): if value < 0 and param_name == "font_size": if value < 0: continue if param_name == "font_size": setFontSize = blkitem.setFontSize value = px2pt(value) else: setFontSize = blkitem.setRelFontSize setFontSize(value, clip_size=clip_size, **set_kwargs) blkitem.setFontSize(value, clip_size=clip_size, **set_kwargs) @font_formating(is_property=False) def ffmt_change_rel_font_size(param_name: str, values: float, act_ffmt: FontFormat, is_global: bool, blkitems: List[TextBlkItem], clip_size=False, **kwargs): set_kwargs = global_default_set_kwargs if is_global else local_default_set_kwargs for blkitem, value in zip(blkitems, values): blkitem.setRelFontSize(value, clip_size=clip_size, **set_kwargs) @font_formating(push_undostack=True) def ffmt_change_alignment(param_name: str, values: float, act_ffmt: FontFormat, is_global: bool, blkitems: List[TextBlkItem], **kwargs): Loading ui/funcmaps.py +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ from utils.textblock_mask import canny_flood, connected_canny_flood, existing_ma # Build base function map handle_ffmt_change = build_funcmap('ui.fontformat_commands', list(FontFormat.params().keys()), list(FontFormat.params().keys()) + ['rel_font_size'], 'ffmt_change_', verbose=False) Loading ui/text_panel.py +2 −2 Original line number Diff line number Diff line Loading @@ -427,9 +427,9 @@ class FontFormatPanel(Widget): return self.textstyle_panel.active_text_style_label def on_param_changed(self, param_name: str, value): func = FM.handle_ffmt_change.get(param_name if not param_name == "rel_font_size" else "font_size") func = FM.handle_ffmt_change.get(param_name) func_kwargs = {} if param_name == 'font_size': if param_name in {'font_size', 'rel_font_size'}: func_kwargs['clip_size'] = True if self.global_mode(): func(param_name, value, self.global_format, is_global=True, **func_kwargs) Loading ui/textitem.py +4 −10 Original line number Diff line number Diff line Loading @@ -916,10 +916,8 @@ class TextBlkItem(QGraphicsTextItem): self.update() def setRelFontSize(self, value: float, repaint_background: bool = False, set_selected: bool = False, restore_cursor: bool = False, clip_size: bool = False, **kwargs): self.is_formatting = True self.block_change_signal = True self.layout.relayout_on_changed = False old_undo_steps = self.document().availableUndoSteps() _, after_kwargs = self._before_set_ffmt(set_selected, restore_cursor) doc = self.document() cursor = QTextCursor(doc) block = doc.firstBlock() Loading @@ -938,16 +936,12 @@ class TextBlkItem(QGraphicsTextItem): cursor.mergeCharFormat(cfmt) it += 1 block = block.next() self.old_undo_steps = new_undo_steps = self.document().availableUndoSteps() self.layout.relayout_on_changed = True self.layout.reLayoutEverything() if clip_size: self.squeezeBoundingRect(True, repaint=False) self.repaint_background() new_steps = new_undo_steps - old_undo_steps self.push_undo_stack.emit(new_steps, self.is_formatting) self.is_formatting = False self.block_change_signal = False self._after_set_ffmt(cursor, repaint_background, restore_cursor, **after_kwargs) def setFontSize(self, value: float, repaint_background: bool = False, set_selected: bool = False, restore_cursor: bool = False, clip_size: bool = False, **kwargs): Loading Loading
ui/fontformat_commands.py +13 −10 Original line number Diff line number Diff line Loading @@ -41,12 +41,12 @@ def wrap_fntformat_input(values: str, blkitems: List[TextBlkItem], is_global: bo values = [values] * len(blkitems) return blkitems, values def font_formating(push_undostack: bool = False): def font_formating(push_undostack: bool = False, is_property = True): def func_wrapper(formatting_func): def wrapper(param_name: str, values: str, act_ffmt: FontFormat, is_global: bool, blkitems: List[TextBlkItem] = None, set_focus: bool = False, *args, **kwargs): if is_global: if is_global and is_property: if hasattr(act_ffmt, param_name): act_ffmt[param_name] = values else: Loading @@ -54,6 +54,7 @@ def font_formating(push_undostack: bool = False): blkitems, values = wrap_fntformat_input(values, blkitems, is_global) if len(blkitems) > 0: if is_property: act_ffmt[param_name] = values[0] if push_undostack: params = copy.deepcopy(kwargs) Loading Loading @@ -142,14 +143,16 @@ def ffmt_change_stroke_width(param_name: str, values: float, act_ffmt: FontForma def ffmt_change_font_size(param_name: str, values: float, act_ffmt: FontFormat, is_global: bool, blkitems: List[TextBlkItem], clip_size=False, **kwargs): set_kwargs = global_default_set_kwargs if is_global else local_default_set_kwargs for blkitem, value in zip(blkitems, values): if value < 0 and param_name == "font_size": if value < 0: continue if param_name == "font_size": setFontSize = blkitem.setFontSize value = px2pt(value) else: setFontSize = blkitem.setRelFontSize setFontSize(value, clip_size=clip_size, **set_kwargs) blkitem.setFontSize(value, clip_size=clip_size, **set_kwargs) @font_formating(is_property=False) def ffmt_change_rel_font_size(param_name: str, values: float, act_ffmt: FontFormat, is_global: bool, blkitems: List[TextBlkItem], clip_size=False, **kwargs): set_kwargs = global_default_set_kwargs if is_global else local_default_set_kwargs for blkitem, value in zip(blkitems, values): blkitem.setRelFontSize(value, clip_size=clip_size, **set_kwargs) @font_formating(push_undostack=True) def ffmt_change_alignment(param_name: str, values: float, act_ffmt: FontFormat, is_global: bool, blkitems: List[TextBlkItem], **kwargs): Loading
ui/funcmaps.py +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ from utils.textblock_mask import canny_flood, connected_canny_flood, existing_ma # Build base function map handle_ffmt_change = build_funcmap('ui.fontformat_commands', list(FontFormat.params().keys()), list(FontFormat.params().keys()) + ['rel_font_size'], 'ffmt_change_', verbose=False) Loading
ui/text_panel.py +2 −2 Original line number Diff line number Diff line Loading @@ -427,9 +427,9 @@ class FontFormatPanel(Widget): return self.textstyle_panel.active_text_style_label def on_param_changed(self, param_name: str, value): func = FM.handle_ffmt_change.get(param_name if not param_name == "rel_font_size" else "font_size") func = FM.handle_ffmt_change.get(param_name) func_kwargs = {} if param_name == 'font_size': if param_name in {'font_size', 'rel_font_size'}: func_kwargs['clip_size'] = True if self.global_mode(): func(param_name, value, self.global_format, is_global=True, **func_kwargs) Loading
ui/textitem.py +4 −10 Original line number Diff line number Diff line Loading @@ -916,10 +916,8 @@ class TextBlkItem(QGraphicsTextItem): self.update() def setRelFontSize(self, value: float, repaint_background: bool = False, set_selected: bool = False, restore_cursor: bool = False, clip_size: bool = False, **kwargs): self.is_formatting = True self.block_change_signal = True self.layout.relayout_on_changed = False old_undo_steps = self.document().availableUndoSteps() _, after_kwargs = self._before_set_ffmt(set_selected, restore_cursor) doc = self.document() cursor = QTextCursor(doc) block = doc.firstBlock() Loading @@ -938,16 +936,12 @@ class TextBlkItem(QGraphicsTextItem): cursor.mergeCharFormat(cfmt) it += 1 block = block.next() self.old_undo_steps = new_undo_steps = self.document().availableUndoSteps() self.layout.relayout_on_changed = True self.layout.reLayoutEverything() if clip_size: self.squeezeBoundingRect(True, repaint=False) self.repaint_background() new_steps = new_undo_steps - old_undo_steps self.push_undo_stack.emit(new_steps, self.is_formatting) self.is_formatting = False self.block_change_signal = False self._after_set_ffmt(cursor, repaint_background, restore_cursor, **after_kwargs) def setFontSize(self, value: float, repaint_background: bool = False, set_selected: bool = False, restore_cursor: bool = False, clip_size: bool = False, **kwargs): Loading