From dbb367f918287daae74edc78f383ac520a620572 Mon Sep 17 00:00:00 2001 From: RomainFT Date: Tue, 31 Jan 2023 19:40:30 +0100 Subject: [PATCH] implement on_options_changed for the abstract classic tool (#357) --- src/tools/abstract_tool.py | 3 ++- src/tools/classic_tools/abstract_classic_tool.py | 15 +++++++++------ .../transform_tools/abstract_transform_tool.py | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/tools/abstract_tool.py b/src/tools/abstract_tool.py index 2740a0cd..47f1a3ec 100644 --- a/src/tools/abstract_tool.py +++ b/src/tools/abstract_tool.py @@ -48,6 +48,7 @@ def __init__(self, tool_id, label, icon_name, window, **kwargs): self.cursor_name = 'cell' self._ongoing_operation = False self._modifier_keys = [] + self._last_btn = 1 # Once everything is set, build the UI self.try_build_pane() @@ -236,7 +237,7 @@ def show_only_mnemonics(self, should_show): # Activation or not ######################################################## def on_tool_selected(self): - pass + self._last_btn = 1 def on_tool_unselected(self): pass diff --git a/src/tools/classic_tools/abstract_classic_tool.py b/src/tools/classic_tools/abstract_classic_tool.py index 7b899930..6da4f748 100644 --- a/src/tools/classic_tools/abstract_classic_tool.py +++ b/src/tools/classic_tools/abstract_classic_tool.py @@ -55,6 +55,15 @@ def build_bottom_pane(self): # Options ################################################################## def set_common_values(self, event_btn, event_x, event_y): + self.x_press = event_x + self.y_press = event_y + self._last_btn = event_btn + self._set_options(event_btn) + + def on_options_changed(self): + self._set_options(self._last_btn) + + def _set_options(self, event_btn): self._use_antialias = self.get_option_value('antialias') self.tool_width = self.window.options_manager.get_tool_width() left_c = self.window.options_manager.get_left_color() @@ -65,14 +74,8 @@ def set_common_values(self, event_btn, event_x, event_y): if event_btn == 3: self.main_color = utilities_gdk_rgba_to_normalized_array(right_c) self.secondary_color = utilities_gdk_rgba_to_normalized_array(left_c) - self.x_press = event_x - self.y_press = event_y self._operator = self.window.options_manager.get_operator()[0] - def on_options_changed(self): - self._use_antialias = self.get_option_value('antialias') - self.tool_width = self.window.options_manager.get_tool_width() - ############################################################################ # Operations common methods ################################################ diff --git a/src/tools/transform_tools/abstract_transform_tool.py b/src/tools/transform_tools/abstract_transform_tool.py index 32f32a46..331ad6a0 100644 --- a/src/tools/transform_tools/abstract_transform_tool.py +++ b/src/tools/transform_tools/abstract_transform_tool.py @@ -227,6 +227,7 @@ def get_deformed_surface(self, source_surface, new_surface, coefs): return new_surface ############################################################################ + # Options ################################################################## def _update_expansion_rgba(self, event_btn=1): """When the canvas grows, the color of the new pixels is parametrable"""