diff --git a/src/tools/classic_tools/tool_arc.py b/src/tools/classic_tools/tool_arc.py index d7f11e3b..1ddcc1c0 100644 --- a/src/tools/classic_tools/tool_arc.py +++ b/src/tools/classic_tools/tool_arc.py @@ -32,6 +32,7 @@ def __init__(self, window, **kwargs): self._dashes_type = 'none' self._arrow_type = 'none' self._use_outline = False + self._path = None self.add_tool_action_enum('line_shape', 'round') self.add_tool_action_enum('dashes-type', self._dashes_type) @@ -92,6 +93,9 @@ def on_options_changed(self): self._arrow_type = self.get_option_value('arrow-type') self.set_active_shape() + operation = self.build_operation() + self.do_tool_operation(operation) + ############################################################################ def on_press_on_area(self, event, surface, event_x, event_y): @@ -114,7 +118,7 @@ def on_motion_on_area(self, event, surface, event_x, event_y, render=True): if not render: return - operation = self.build_operation(event_x, event_y) + operation = self.build_operation() self.do_tool_operation(operation) def on_release_on_area(self, event, surface, event_x, event_y): @@ -129,12 +133,12 @@ def on_release_on_area(self, event, surface, event_x, event_y): self._1st_segment = None self._path = cairo_context.copy_path() - operation = self.build_operation(event_x, event_y) + operation = self.build_operation() self.apply_operation(operation) ############################################################################ - def build_operation(self, event_x, event_y): + def build_operation(self): operation = { 'tool_id': self.id, 'rgba': self.main_color, @@ -147,14 +151,14 @@ def build_operation(self, event_x, event_y): 'arrow': self._arrow_type, 'outline': self._use_outline, 'path': self._path, - 'x_release': event_x, - 'y_release': event_y, 'x_press': self.x_press, 'y_press': self.y_press } return operation def do_tool_operation(self, operation): + if operation['path'] is None: + return cairo_context = self.start_tool_operation(operation) cairo_context.set_operator(operation['operator']) @@ -179,8 +183,8 @@ def do_tool_operation(self, operation): if operation['arrow'] != 'none': x1 = operation['x_press'] y1 = operation['y_press'] - x2 = operation['x_release'] - y2 = operation['y_release'] + x2 = cairo_context.get_current_point()[0] + y2 = cairo_context.get_current_point()[1] utilities_add_arrow_triangle(cairo_context, x2, y2, x1, y1, line_width) if operation['outline']: