mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Copy, cut & delete now affect the entire cel if there is no selection
Also fixed issue with delete deleting content from locked/invisible layers.
This commit is contained in:
parent
c22633901d
commit
edbbec1d55
|
@ -22,6 +22,10 @@ func select_pixel(pixel: Vector2, select := true) -> void:
|
|||
unlock()
|
||||
|
||||
|
||||
func select_all() -> void:
|
||||
fill(Color(1, 1, 1, 1))
|
||||
|
||||
|
||||
func clear() -> void:
|
||||
fill(Color(0))
|
||||
|
||||
|
|
|
@ -644,6 +644,7 @@ func _get_selected_draw_images() -> Array: # Array of Images
|
|||
var project: Project = Global.current_project
|
||||
for cel_index in project.selected_cels:
|
||||
var cel: Cel = project.frames[cel_index[0]].cels[cel_index[1]]
|
||||
if project.layers[cel_index[1]].can_layer_get_drawn():
|
||||
images.append(cel.image)
|
||||
return images
|
||||
|
||||
|
@ -663,10 +664,14 @@ func copy() -> void:
|
|||
var cl_big_bounding_rectangle := Rect2()
|
||||
var cl_selection_offset := Vector2.ZERO
|
||||
|
||||
if !project.has_selection:
|
||||
return
|
||||
var image: Image = project.frames[project.current_frame].cels[project.current_layer].image
|
||||
var to_copy := Image.new()
|
||||
if !project.has_selection:
|
||||
to_copy.copy_from(image)
|
||||
cl_selection_map.copy_from(project.selection_map)
|
||||
cl_selection_map.select_all()
|
||||
cl_big_bounding_rectangle = Rect2(Vector2.ZERO, project.size)
|
||||
else:
|
||||
if is_moving_content:
|
||||
to_copy.copy_from(preview_image)
|
||||
var selection_map_copy := SelectionMap.new()
|
||||
|
@ -689,10 +694,10 @@ func copy() -> void:
|
|||
to_copy.set_pixelv(pos, Color(0))
|
||||
to_copy.unlock()
|
||||
cl_selection_map.copy_from(project.selection_map)
|
||||
cl_image = to_copy
|
||||
cl_big_bounding_rectangle = big_bounding_rectangle
|
||||
cl_selection_offset = project.selection_offset
|
||||
|
||||
cl_image = to_copy
|
||||
cl_selection_offset = project.selection_offset
|
||||
var transfer_clipboard := {
|
||||
"image": cl_image,
|
||||
"selection_map": cl_selection_map.data,
|
||||
|
@ -765,8 +770,6 @@ func paste() -> void:
|
|||
|
||||
func delete(selected_cels := true) -> void:
|
||||
var project: Project = Global.current_project
|
||||
if !project.has_selection:
|
||||
return
|
||||
if !project.layers[project.current_layer].can_layer_get_drawn():
|
||||
return
|
||||
if is_moving_content:
|
||||
|
@ -788,6 +791,7 @@ func delete(selected_cels := true) -> void:
|
|||
|
||||
var blank := Image.new()
|
||||
blank.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
||||
if project.has_selection:
|
||||
var selection_map_copy := SelectionMap.new()
|
||||
selection_map_copy.copy_from(project.selection_map)
|
||||
# In case the selection map is bigger than the canvas
|
||||
|
@ -796,6 +800,9 @@ func delete(selected_cels := true) -> void:
|
|||
image.blit_rect_mask(
|
||||
blank, selection_map_copy, big_bounding_rectangle, big_bounding_rectangle.position
|
||||
)
|
||||
else:
|
||||
for image in images:
|
||||
image.fill(0)
|
||||
commit_undo("Draw", undo_data_tmp)
|
||||
|
||||
|
||||
|
@ -843,9 +850,9 @@ func new_brush() -> void:
|
|||
|
||||
func select_all() -> void:
|
||||
var project: Project = Global.current_project
|
||||
var undo_data_tmp = get_undo_data(false)
|
||||
var undo_data_tmp := get_undo_data(false)
|
||||
clear_selection()
|
||||
var full_rect = Rect2(Vector2.ZERO, project.size)
|
||||
var full_rect := Rect2(Vector2.ZERO, project.size)
|
||||
select_rect(full_rect)
|
||||
commit_undo("Select", undo_data_tmp)
|
||||
|
||||
|
|
Loading…
Reference in a new issue