mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Added a displace origin option to Rectangle, Ellipse and Rectangle Selection tools
Works with Mouse Click + Alt. Needs to be documented in the tooltips.
This commit is contained in:
parent
8f846fe04a
commit
0a35615c24
|
@ -551,6 +551,11 @@ escape={
|
|||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
alt={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777240,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[locale]
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ var _start_pos := Vector2.ZERO
|
|||
|
||||
var _square := false # Mouse Click + Shift
|
||||
var _expand_from_center := false # Mouse Click + Ctrl
|
||||
var _displace_origin = false # Mouse Click + Alt
|
||||
|
||||
|
||||
func _input(event : InputEvent) -> void:
|
||||
|
@ -18,6 +19,10 @@ func _input(event : InputEvent) -> void:
|
|||
_expand_from_center = true
|
||||
elif event.is_action_released("ctrl"):
|
||||
_expand_from_center = false
|
||||
if event.is_action_pressed("alt"):
|
||||
_displace_origin = true
|
||||
elif event.is_action_released("alt"):
|
||||
_displace_origin = false
|
||||
|
||||
|
||||
func draw_start(position : Vector2) -> void:
|
||||
|
@ -29,10 +34,13 @@ func draw_start(position : Vector2) -> void:
|
|||
func draw_move(position : Vector2) -> void:
|
||||
.draw_move(position)
|
||||
if !_move:
|
||||
if _displace_origin:
|
||||
_start_pos += position - _offset
|
||||
_rect = _get_result_rect(_start_pos, position)
|
||||
_set_cursor_text(_rect)
|
||||
Global.canvas.selection.drawn_rect = _rect
|
||||
Global.canvas.selection.update()
|
||||
_offset = position
|
||||
|
||||
|
||||
func draw_end(position : Vector2) -> void:
|
||||
|
@ -42,6 +50,7 @@ func draw_end(position : Vector2) -> void:
|
|||
Global.canvas.selection.update()
|
||||
_square = false
|
||||
_expand_from_center = false
|
||||
_displace_origin = false
|
||||
|
||||
|
||||
func apply_selection(_position) -> void:
|
||||
|
|
|
@ -29,6 +29,7 @@ func draw_start(position : Vector2) -> void:
|
|||
_intersect = Tools.shift && Tools.control
|
||||
_add = Tools.shift && !_intersect
|
||||
_subtract = Tools.control && !_intersect
|
||||
_offset = position
|
||||
|
||||
var selection_position : Vector2 = Global.canvas.selection.big_bounding_rectangle.position
|
||||
var offsetted_pos := position
|
||||
|
@ -39,7 +40,6 @@ func draw_start(position : Vector2) -> void:
|
|||
if offsetted_pos.x >= 0 and offsetted_pos.y >= 0 and Global.current_project.selection_bitmap.get_bit(offsetted_pos) and (!Tools.control or Tools.alt) and !Tools.shift:
|
||||
# Move current selection
|
||||
_move = true
|
||||
_offset = position
|
||||
if Tools.control and Tools.alt: # Move selection without content
|
||||
Global.canvas.selection.transform_content_confirm()
|
||||
_move_content = false
|
||||
|
|
|
@ -2,9 +2,11 @@ extends "res://src/Tools/Draw.gd"
|
|||
|
||||
|
||||
var _start := Vector2.ZERO
|
||||
var _offset := Vector2.ZERO
|
||||
var _dest := Vector2.ZERO
|
||||
var _fill := false
|
||||
var _drawing := false
|
||||
var _displace_origin := false
|
||||
var _thickness := 1
|
||||
|
||||
|
||||
|
@ -52,18 +54,30 @@ func _get_shape_points_filled(_size: Vector2) -> PoolVector2Array:
|
|||
return PoolVector2Array()
|
||||
|
||||
|
||||
func _input(event : InputEvent) -> void:
|
||||
if _drawing:
|
||||
if event.is_action_pressed("alt"):
|
||||
_displace_origin = true
|
||||
elif event.is_action_released("alt"):
|
||||
_displace_origin = false
|
||||
|
||||
|
||||
func draw_start(position : Vector2) -> void:
|
||||
Global.canvas.selection.transform_content_confirm()
|
||||
update_mask()
|
||||
|
||||
_start = position
|
||||
_offset = position
|
||||
_dest = position
|
||||
_drawing = true
|
||||
|
||||
|
||||
func draw_move(position : Vector2) -> void:
|
||||
if _drawing:
|
||||
if _displace_origin:
|
||||
_start += position - _offset
|
||||
_dest = position
|
||||
_offset = position
|
||||
|
||||
|
||||
func draw_end(position : Vector2) -> void:
|
||||
|
@ -73,6 +87,7 @@ func draw_end(position : Vector2) -> void:
|
|||
_start = Vector2.ZERO
|
||||
_dest = Vector2.ZERO
|
||||
_drawing = false
|
||||
_displace_origin = false
|
||||
|
||||
|
||||
func draw_preview() -> void:
|
||||
|
|
Loading…
Reference in a new issue