File tree 4 files changed +23
-5
lines changed
4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,8 @@ func center_to_mouse() -> void:
71
71
# -------------------------------------------------------------------------------------------------
72
72
func use_tool (tool_type : int ) -> void :
73
73
_active_tool .enabled = false
74
- _selection_tool . deselect_all_strokes ()
75
-
74
+ var prev_tool := _active_tool
75
+
76
76
match tool_type :
77
77
Types .Tool .BRUSH :
78
78
_active_tool = _brush_tool
@@ -92,7 +92,9 @@ func use_tool(tool_type: int) -> void:
92
92
Types .Tool .SELECT :
93
93
_active_tool = _selection_tool
94
94
_use_optimizer = false
95
-
95
+
96
+ if prev_tool != _active_tool :
97
+ prev_tool .reset ()
96
98
_active_tool .enabled = true
97
99
_active_tool .get_cursor ()._on_zoom_changed (_camera .zoom .x )
98
100
Original file line number Diff line number Diff line change @@ -89,3 +89,7 @@ func end_stroke() -> void:
89
89
# -------------------------------------------------------------------------------------------------
90
90
func xform_vector2 (v : Vector2 ) -> Vector2 :
91
91
return _canvas .get_camera ().xform (v )
92
+
93
+ # -------------------------------------------------------------------------------------------------
94
+ func reset () -> void :
95
+ end_stroke ()
Original file line number Diff line number Diff line change @@ -22,8 +22,7 @@ func _input(event: InputEvent) -> void:
22
22
_update_bounding_boxes ()
23
23
performing_stroke = true
24
24
elif ! event .pressed :
25
- _bounding_box_cache .clear ()
26
- performing_stroke = false
25
+ reset ()
27
26
28
27
# -------------------------------------------------------------------------------------------------
29
28
func _process (delta : float ) -> void :
@@ -73,3 +72,8 @@ func _update_bounding_boxes() -> void:
73
72
var strokes : Array = _canvas .get_all_strokes ()
74
73
_bounding_box_cache = Utils .calculte_bounding_boxes (strokes , BOUNDING_BOX_MARGIN )
75
74
# $"../Viewport/DebugDraw".set_bounding_boxes(_bounding_box_cache.values())
75
+
76
+ # ------------------------------------------------------------------------------------------------
77
+ func reset () -> void :
78
+ _bounding_box_cache .clear ()
79
+ performing_stroke = false
Original file line number Diff line number Diff line change @@ -245,3 +245,11 @@ func get_selected_strokes() -> Array:
245
245
func _on_brush_color_changed (color : Color ) -> void :
246
246
var strokes := get_selected_strokes ()
247
247
_modify_strokes_colors (strokes , color )
248
+
249
+ # ------------------------------------------------------------------------------------------------
250
+ func reset () -> void :
251
+ _state = State .NONE
252
+ _selection_rectangle .reset ()
253
+ _selection_rectangle .update ()
254
+ _commit_strokes_under_selection_rectangle ()
255
+ deselect_all_strokes ()
You can’t perform that action at this time.
0 commit comments