1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-21 21:13:14 +00:00

Fix Copy & Delete to work on the currently selected parts of the image

This also fixed a crash when deleting while content is being moved/resized
This commit is contained in:
Manolis Papadeas 2021-04-19 19:05:05 +03:00
parent fccd37360a
commit 1d5b44fad2

View file

@ -379,20 +379,23 @@ func copy() -> void:
return 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()
to_copy = image.get_rect(big_bounding_rectangle) if is_moving_content:
to_copy.lock() to_copy.copy_from(preview_image)
# Only remove unincluded pixels if the selection is not a single rectangle else:
for x in to_copy.get_size().x: to_copy = image.get_rect(big_bounding_rectangle)
for y in to_copy.get_size().y: to_copy.lock()
var pos := Vector2(x, y) # Remove unincluded pixels if the selection is not a single rectangle
var offset_pos = big_bounding_rectangle.position for x in to_copy.get_size().x:
if offset_pos.x < 0: for y in to_copy.get_size().y:
offset_pos.x = 0 var pos := Vector2(x, y)
if offset_pos.y < 0: var offset_pos = big_bounding_rectangle.position
offset_pos.y = 0 if offset_pos.x < 0:
if not project.selection_bitmap.get_bit(pos + offset_pos): offset_pos.x = 0
to_copy.set_pixelv(pos, Color(0)) if offset_pos.y < 0:
to_copy.unlock() offset_pos.y = 0
if not project.selection_bitmap.get_bit(pos + offset_pos):
to_copy.set_pixelv(pos, Color(0))
to_copy.unlock()
clipboard.image = to_copy clipboard.image = to_copy
clipboard.selection_bitmap = project.selection_bitmap.duplicate() clipboard.selection_bitmap = project.selection_bitmap.duplicate()
clipboard.big_bounding_rectangle = big_bounding_rectangle clipboard.big_bounding_rectangle = big_bounding_rectangle
@ -427,6 +430,16 @@ func delete() -> void:
var project := Global.current_project var project := Global.current_project
if !project.has_selection: if !project.has_selection:
return return
if is_moving_content:
is_moving_content = false
original_preview_image = Image.new()
preview_image = Image.new()
original_bitmap = BitMap.new()
is_pasting = false
update()
commit_undo("Draw", undo_data)
return
var _undo_data = _get_undo_data(true) var _undo_data = _get_undo_data(true)
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
for x in big_bounding_rectangle.size.x: for x in big_bounding_rectangle.size.x: