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()
|
unlock()
|
||||||
|
|
||||||
|
|
||||||
|
func select_all() -> void:
|
||||||
|
fill(Color(1, 1, 1, 1))
|
||||||
|
|
||||||
|
|
||||||
func clear() -> void:
|
func clear() -> void:
|
||||||
fill(Color(0))
|
fill(Color(0))
|
||||||
|
|
||||||
|
|
|
@ -644,7 +644,8 @@ func _get_selected_draw_images() -> Array: # Array of Images
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
for cel_index in project.selected_cels:
|
for cel_index in project.selected_cels:
|
||||||
var cel: Cel = project.frames[cel_index[0]].cels[cel_index[1]]
|
var cel: Cel = project.frames[cel_index[0]].cels[cel_index[1]]
|
||||||
images.append(cel.image)
|
if project.layers[cel_index[1]].can_layer_get_drawn():
|
||||||
|
images.append(cel.image)
|
||||||
return images
|
return images
|
||||||
|
|
||||||
|
|
||||||
|
@ -663,36 +664,40 @@ func copy() -> void:
|
||||||
var cl_big_bounding_rectangle := Rect2()
|
var cl_big_bounding_rectangle := Rect2()
|
||||||
var cl_selection_offset := Vector2.ZERO
|
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 image: Image = project.frames[project.current_frame].cels[project.current_layer].image
|
||||||
var to_copy := Image.new()
|
var to_copy := Image.new()
|
||||||
if is_moving_content:
|
if !project.has_selection:
|
||||||
to_copy.copy_from(preview_image)
|
to_copy.copy_from(image)
|
||||||
var selection_map_copy := SelectionMap.new()
|
|
||||||
selection_map_copy.copy_from(project.selection_map)
|
|
||||||
selection_map_copy.move_bitmap_values(project, false)
|
|
||||||
cl_selection_map = selection_map_copy
|
|
||||||
else:
|
|
||||||
to_copy = image.get_rect(big_bounding_rectangle)
|
|
||||||
to_copy.lock()
|
|
||||||
# Remove unincluded pixels if the selection is not a single rectangle
|
|
||||||
for x in to_copy.get_size().x:
|
|
||||||
for y in to_copy.get_size().y:
|
|
||||||
var pos := Vector2(x, y)
|
|
||||||
var offset_pos = big_bounding_rectangle.position
|
|
||||||
if offset_pos.x < 0:
|
|
||||||
offset_pos.x = 0
|
|
||||||
if offset_pos.y < 0:
|
|
||||||
offset_pos.y = 0
|
|
||||||
if not project.selection_map.is_pixel_selected(pos + offset_pos):
|
|
||||||
to_copy.set_pixelv(pos, Color(0))
|
|
||||||
to_copy.unlock()
|
|
||||||
cl_selection_map.copy_from(project.selection_map)
|
cl_selection_map.copy_from(project.selection_map)
|
||||||
cl_image = to_copy
|
cl_selection_map.select_all()
|
||||||
cl_big_bounding_rectangle = big_bounding_rectangle
|
cl_big_bounding_rectangle = Rect2(Vector2.ZERO, project.size)
|
||||||
cl_selection_offset = project.selection_offset
|
else:
|
||||||
|
if is_moving_content:
|
||||||
|
to_copy.copy_from(preview_image)
|
||||||
|
var selection_map_copy := SelectionMap.new()
|
||||||
|
selection_map_copy.copy_from(project.selection_map)
|
||||||
|
selection_map_copy.move_bitmap_values(project, false)
|
||||||
|
cl_selection_map = selection_map_copy
|
||||||
|
else:
|
||||||
|
to_copy = image.get_rect(big_bounding_rectangle)
|
||||||
|
to_copy.lock()
|
||||||
|
# Remove unincluded pixels if the selection is not a single rectangle
|
||||||
|
for x in to_copy.get_size().x:
|
||||||
|
for y in to_copy.get_size().y:
|
||||||
|
var pos := Vector2(x, y)
|
||||||
|
var offset_pos = big_bounding_rectangle.position
|
||||||
|
if offset_pos.x < 0:
|
||||||
|
offset_pos.x = 0
|
||||||
|
if offset_pos.y < 0:
|
||||||
|
offset_pos.y = 0
|
||||||
|
if not project.selection_map.is_pixel_selected(pos + offset_pos):
|
||||||
|
to_copy.set_pixelv(pos, Color(0))
|
||||||
|
to_copy.unlock()
|
||||||
|
cl_selection_map.copy_from(project.selection_map)
|
||||||
|
cl_big_bounding_rectangle = big_bounding_rectangle
|
||||||
|
|
||||||
|
cl_image = to_copy
|
||||||
|
cl_selection_offset = project.selection_offset
|
||||||
var transfer_clipboard := {
|
var transfer_clipboard := {
|
||||||
"image": cl_image,
|
"image": cl_image,
|
||||||
"selection_map": cl_selection_map.data,
|
"selection_map": cl_selection_map.data,
|
||||||
|
@ -765,8 +770,6 @@ func paste() -> void:
|
||||||
|
|
||||||
func delete(selected_cels := true) -> void:
|
func delete(selected_cels := true) -> void:
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
if !project.has_selection:
|
|
||||||
return
|
|
||||||
if !project.layers[project.current_layer].can_layer_get_drawn():
|
if !project.layers[project.current_layer].can_layer_get_drawn():
|
||||||
return
|
return
|
||||||
if is_moving_content:
|
if is_moving_content:
|
||||||
|
@ -788,14 +791,18 @@ func delete(selected_cels := true) -> void:
|
||||||
|
|
||||||
var blank := Image.new()
|
var blank := Image.new()
|
||||||
blank.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
blank.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
||||||
var selection_map_copy := SelectionMap.new()
|
if project.has_selection:
|
||||||
selection_map_copy.copy_from(project.selection_map)
|
var selection_map_copy := SelectionMap.new()
|
||||||
# In case the selection map is bigger than the canvas
|
selection_map_copy.copy_from(project.selection_map)
|
||||||
selection_map_copy.crop(project.size.x, project.size.y)
|
# In case the selection map is bigger than the canvas
|
||||||
for image in images:
|
selection_map_copy.crop(project.size.x, project.size.y)
|
||||||
image.blit_rect_mask(
|
for image in images:
|
||||||
blank, selection_map_copy, big_bounding_rectangle, big_bounding_rectangle.position
|
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)
|
commit_undo("Draw", undo_data_tmp)
|
||||||
|
|
||||||
|
|
||||||
|
@ -843,9 +850,9 @@ func new_brush() -> void:
|
||||||
|
|
||||||
func select_all() -> void:
|
func select_all() -> void:
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
var undo_data_tmp = get_undo_data(false)
|
var undo_data_tmp := get_undo_data(false)
|
||||||
clear_selection()
|
clear_selection()
|
||||||
var full_rect = Rect2(Vector2.ZERO, project.size)
|
var full_rect := Rect2(Vector2.ZERO, project.size)
|
||||||
select_rect(full_rect)
|
select_rect(full_rect)
|
||||||
commit_undo("Select", undo_data_tmp)
|
commit_undo("Select", undo_data_tmp)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue