Skip to content

Commit

Permalink
implement on_options_changed for the abstract classic tool (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
maoschanz committed Jan 31, 2023
1 parent 20547fa commit dbb367f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/tools/abstract_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions src/tools/classic_tools/abstract_classic_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 ################################################

Expand Down
1 change: 1 addition & 0 deletions src/tools/transform_tools/abstract_transform_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit dbb367f

Please sign in to comment.