From 64a40b212d718242985bb2766a01351a2cbaf717 Mon Sep 17 00:00:00 2001 From: RomainFT Date: Fri, 17 Feb 2023 01:19:19 +0100 Subject: [PATCH] text tool: help tips, + apply when changing to another tool #357 --- src/tools/classic_tools/tool_text.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/tools/classic_tools/tool_text.py b/src/tools/classic_tools/tool_text.py index 7ab15aa7..2c3727c3 100644 --- a/src/tools/classic_tools/tool_text.py +++ b/src/tools/classic_tools/tool_text.py @@ -25,7 +25,6 @@ class ToolText(AbstractClassicTool): def __init__(self, window, **kwargs): super().__init__('text', _("Text"), 'tool-text-symbolic', window) - self._should_cancel = False # There are several types of possible interactions with the canvas, # depending on where the pointer is during the press event. @@ -100,6 +99,13 @@ def get_options_label(self): return _("Text options") def get_editing_tips(self): + if self._has_current_text(): + label_move = self.label + " - " + _("Grab the rectangle to adjust the text position") + label_apply = self.label + " - " + _("Click outside the rectangle to apply") + else: + label_move = None + label_apply = None + label_options = self.label + " - " + self._font_fam_name if self._background_id != 'none': bg_label = { @@ -110,7 +116,9 @@ def get_editing_tips(self): 'rectangle': _("Rectangle background"), }[self._background_id] label_options += " - " + bg_label - return [label_options] + + full_list = [label_options, label_move, label_apply] + return list(filter(None, full_list)) def on_options_changed(self): super().on_options_changed() @@ -127,7 +135,11 @@ def on_tool_unselected(self): self.set_action_sensitivity('selection_copy', True) def give_back_control(self, preserve_selection, next_tool=None): - if self._should_cancel: + if self._has_current_text(): + operation = self.build_operation() + self.apply_operation(operation) + self._set_string('') + else: self._on_cancel() return next_tool @@ -172,7 +184,6 @@ def on_motion_on_area(self, event, surface, event_x, event_y, render=True): self._preview_text() def on_release_on_area(self, event, surface, event_x, event_y): - self._should_cancel = True if 'input' == self._pointer_target: if not self._has_current_text(): self.set_common_values(event.button, event_x, event_y) @@ -266,7 +277,13 @@ def on_draw_above(self, area, ccontext): def _on_cancel(self, *args): self._hide_entry() self._set_string('') - self._should_cancel = False + + def on_unclicked_motion_on_area(self, event, surface): + if not self._has_current_text(): + self.cursor_name = 'text' + else: + self.cursor_name = 'pointer' + self.window.set_cursor(True) ############################################################################