@@ -4,9 +4,9 @@ enum Orientation { ROWS = 0, COLUMNS = 1 }
44
55var global :Node # Needed for reference to "global" node of Pixelorama (Used most of the time)
66onready var previews = $ VBoxContainer/Preview/PreviewPanel/ScrollContainer/Previews
7- onready var spritesheet_lines_count_label = $ VBoxContainer/Preview/Orientation/LinesCountLabel
8- onready var spritesheet_lines_count = $ VBoxContainer/Preview/Orientation/LinesCount
9- onready var spritesheet_orientation = $ VBoxContainer/Preview/Orientation/Orientation
7+ onready var spritesheet_lines_count_label = $ VBoxContainer/Preview/Orientation/HBoxContainer2/ LinesCountLabel
8+ onready var spritesheet_lines_count = $ VBoxContainer/Preview/Orientation/HBoxContainer2/ LinesCount
9+ onready var spritesheet_orientation = $ VBoxContainer/Preview/Orientation/HBoxContainer/ Orientation
1010
1111var processed_images = [] # Image[]
1212var number_of_frames := 1
@@ -181,22 +181,22 @@ var moving = false
181181var scaling = false
182182var can_scale = false
183183var mode = 0
184- enum Mode { NONE , LEFT , RIGHT , UP , DOWN }
184+ enum Mode { NONE , LEFT , RIGHT , UP , DOWN , T_LEFT , T_RIGHT , B_LEFT , B_RIGHT }
185185var scale_limit = 5
186186var offset = Vector2 .ZERO
187187
188188
189189func _on_Main_mouse_entered () -> void :
190190 if global :
191191 global .can_draw = false
192- can_scale = true
192+ can_scale = true
193193
194194
195195func _on_Main_mouse_exited () -> void :
196196 if global :
197197 global .can_draw = true
198- if ! scaling :
199- can_scale = false
198+ if ! scaling :
199+ can_scale = false
200200
201201
202202func _on_Title_gui_input (event : InputEvent ) -> void :
@@ -218,17 +218,29 @@ func _input(event: InputEvent) -> void:
218218 if ! event .pressed :
219219 $ RefreshTimer .start ()
220220
221- if event is InputEventMouse :
221+ if event is InputEventMouse : # Set cursor and mode accordingly
222222 var mouse_pos = get_local_mouse_position ()
223223 if event is InputEventMouseMotion and ! scaling :
224- if (mouse_pos .x >= rect_size .x - scale_limit and mouse_pos .x <= rect_size .x + scale_limit
225- and (mouse_pos .y > 0 and mouse_pos .y < rect_size .y )): # Right
226- mouse_default_cursor_shape = Control .CURSOR_HSIZE
227- mode = Mode .RIGHT
224+ if mouse_pos .distance_to (Vector2 .ZERO ) <= scale_limit : # Top left
225+ mouse_default_cursor_shape = Control .CURSOR_FDIAGSIZE
226+ mode = Mode .T_LEFT
227+ elif mouse_pos .distance_to (Vector2 (rect_size .x , 0 )) <= scale_limit : # Top right
228+ mouse_default_cursor_shape = Control .CURSOR_BDIAGSIZE
229+ mode = Mode .T_RIGHT
230+ elif mouse_pos .distance_to (Vector2 (0 ,rect_size .y )) <= scale_limit : # Bottom left
231+ mouse_default_cursor_shape = Control .CURSOR_BDIAGSIZE
232+ mode = Mode .B_LEFT
233+ elif mouse_pos .distance_to (rect_size ) <= scale_limit : # Bottom right
234+ mouse_default_cursor_shape = Control .CURSOR_FDIAGSIZE
235+ mode = Mode .B_RIGHT
228236 elif ((mouse_pos .x < scale_limit and mouse_pos .x > - scale_limit )
229237 and (mouse_pos .y > 0 and mouse_pos .y < rect_size .y )): # Left
230238 mouse_default_cursor_shape = Control .CURSOR_HSIZE
231239 mode = Mode .LEFT
240+ elif (mouse_pos .x >= rect_size .x - scale_limit and mouse_pos .x <= rect_size .x + scale_limit
241+ and (mouse_pos .y > 0 and mouse_pos .y < rect_size .y )): # Right
242+ mouse_default_cursor_shape = Control .CURSOR_HSIZE
243+ mode = Mode .RIGHT
232244 elif ((mouse_pos .y < scale_limit and mouse_pos .y > - scale_limit )
233245 and (mouse_pos .x > 0 and mouse_pos .x < rect_size .x )): # Up
234246 mouse_default_cursor_shape = Control .CURSOR_VSIZE
@@ -242,9 +254,10 @@ func _input(event: InputEvent) -> void:
242254 mouse_default_cursor_shape = Control .CURSOR_ARROW
243255 mode = Mode .NONE
244256
245- elif event is InputEventMouseMotion and scaling :
257+ elif event is InputEventMouseMotion and scaling : # Here's where the scaling is done
246258 if can_scale :
247259 match mode :
260+ # SIDES
248261 Mode .RIGHT :
249262 rect_size .x += get_global_mouse_position ().x - rect_global_position .x - (rect_size .x )
250263 Mode .LEFT :
@@ -258,6 +271,28 @@ func _input(event: InputEvent) -> void:
258271 rect_size .y += rect_global_position .y - get_global_mouse_position ().y
259272 rect_position .y -= (rect_global_position .y ) - get_global_mouse_position ().y
260273
274+ # CORNERS
275+ Mode .T_LEFT :
276+ if rect_size .y + (rect_global_position .y - get_global_mouse_position ().y ) > rect_min_size .y :
277+ rect_size .y += rect_global_position .y - get_global_mouse_position ().y
278+ rect_position .y -= (rect_global_position .y ) - get_global_mouse_position ().y
279+ if rect_size .x + (rect_global_position .x - get_global_mouse_position ().x ) > rect_min_size .x :
280+ rect_size .x += rect_global_position .x - get_global_mouse_position ().x
281+ rect_position .x -= (rect_global_position .x ) - get_global_mouse_position ().x
282+ Mode .T_RIGHT :
283+ if rect_size .y + (rect_global_position .y - get_global_mouse_position ().y ) > rect_min_size .y :
284+ rect_size .y += rect_global_position .y - get_global_mouse_position ().y
285+ rect_position .y -= (rect_global_position .y ) - get_global_mouse_position ().y
286+ rect_size .x += get_global_mouse_position ().x - rect_global_position .x - (rect_size .x )
287+ Mode .B_LEFT :
288+ rect_size .y += get_global_mouse_position ().y - rect_global_position .y - (rect_size .y )
289+ if rect_size .x + (rect_global_position .x - get_global_mouse_position ().x ) > rect_min_size .x :
290+ rect_size .x += rect_global_position .x - get_global_mouse_position ().x
291+ rect_position .x -= (rect_global_position .x ) - get_global_mouse_position ().x
292+ Mode .B_RIGHT :
293+ rect_size .y += get_global_mouse_position ().y - rect_global_position .y - (rect_size .y )
294+ rect_size .x += get_global_mouse_position ().x - rect_global_position .x - (rect_size .x )
295+
261296 if event is InputEventMouseButton :
262297 if event .pressed :
263298 scaling = true
0 commit comments