mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-20 12:33:14 +00:00
Fixed bug when copying while moving content
This commit is contained in:
parent
3852b419dd
commit
a712f822d7
2 changed files with 21 additions and 9 deletions
|
@ -682,7 +682,7 @@ func get_selection_rectangle(bitmap : BitMap = selection_bitmap) -> Rect2:
|
|||
return Rect2(minx, miny, maxx - minx + 1, maxy - miny + 1)
|
||||
|
||||
|
||||
func move_bitmap_values(bitmap : BitMap) -> void:
|
||||
func move_bitmap_values(bitmap : BitMap, move_offset := true) -> void:
|
||||
var selection_node = Global.canvas.selection
|
||||
var selection_position : Vector2 = selection_node.big_bounding_rectangle.position
|
||||
var selection_end : Vector2 = selection_node.big_bounding_rectangle.end
|
||||
|
@ -700,16 +700,20 @@ func move_bitmap_values(bitmap : BitMap) -> void:
|
|||
|
||||
if selection_position.x < 0:
|
||||
nw -= selection_position.x
|
||||
self.selection_offset.x = selection_position.x
|
||||
if move_offset:
|
||||
self.selection_offset.x = selection_position.x
|
||||
dst.x = 0
|
||||
else:
|
||||
self.selection_offset.x = 0
|
||||
if move_offset:
|
||||
self.selection_offset.x = 0
|
||||
if selection_position.y < 0:
|
||||
nh -= selection_position.y
|
||||
self.selection_offset.y = selection_position.y
|
||||
if move_offset:
|
||||
self.selection_offset.y = selection_position.y
|
||||
dst.y = 0
|
||||
else:
|
||||
self.selection_offset.y = 0
|
||||
if move_offset:
|
||||
self.selection_offset.y = 0
|
||||
|
||||
if nw <= image.get_size().x:
|
||||
nw = image.get_size().x
|
||||
|
|
|
@ -39,11 +39,15 @@ var clipboard := Clipboard.new()
|
|||
var is_moving_content := false
|
||||
var is_pasting := false
|
||||
var big_bounding_rectangle := Rect2() setget _big_bounding_rectangle_changed
|
||||
|
||||
var temp_rect := Rect2()
|
||||
var temp_bitmap := BitMap.new()
|
||||
|
||||
var original_big_bounding_rectangle := Rect2()
|
||||
var original_preview_image := Image.new()
|
||||
var original_bitmap := BitMap.new()
|
||||
var original_offset := Vector2.ZERO
|
||||
|
||||
var preview_image := Image.new()
|
||||
var preview_image_texture := ImageTexture.new()
|
||||
var undo_data : Dictionary
|
||||
|
@ -94,6 +98,7 @@ func _input(event : InputEvent) -> void:
|
|||
mouse_pos_on_gizmo_drag = Global.canvas.current_pixel
|
||||
dragged_gizmo = gizmo
|
||||
temp_rect = big_bounding_rectangle
|
||||
temp_bitmap = Global.current_project.selection_bitmap
|
||||
move_content_start()
|
||||
Global.current_project.selection_offset = Vector2.ZERO
|
||||
if gizmo.type == Gizmo.Type.ROTATE:
|
||||
|
@ -188,7 +193,7 @@ func gizmo_resize() -> void:
|
|||
if temp_rect.size.y < 0:
|
||||
preview_image.flip_y()
|
||||
preview_image_texture.create_from_image(preview_image, 0)
|
||||
Global.current_project.selection_bitmap = Global.current_project.resize_bitmap_values(original_bitmap, size, temp_rect.size.x < 0, temp_rect.size.y < 0)
|
||||
Global.current_project.selection_bitmap = Global.current_project.resize_bitmap_values(temp_bitmap, size, temp_rect.size.x < 0, temp_rect.size.y < 0)
|
||||
Global.current_project.selection_bitmap_changed()
|
||||
update()
|
||||
|
||||
|
@ -260,7 +265,7 @@ func move_borders(move : Vector2) -> void:
|
|||
|
||||
|
||||
func move_borders_end() -> void:
|
||||
var selected_bitmap_copy = Global.current_project.selection_bitmap.duplicate()
|
||||
var selected_bitmap_copy := Global.current_project.selection_bitmap.duplicate()
|
||||
Global.current_project.move_bitmap_values(selected_bitmap_copy)
|
||||
|
||||
Global.current_project.selection_bitmap = selected_bitmap_copy
|
||||
|
@ -381,6 +386,9 @@ func copy() -> void:
|
|||
var to_copy := Image.new()
|
||||
if is_moving_content:
|
||||
to_copy.copy_from(preview_image)
|
||||
var selected_bitmap_copy := Global.current_project.selection_bitmap.duplicate()
|
||||
Global.current_project.move_bitmap_values(selected_bitmap_copy, false)
|
||||
clipboard.selection_bitmap = selected_bitmap_copy
|
||||
else:
|
||||
to_copy = image.get_rect(big_bounding_rectangle)
|
||||
to_copy.lock()
|
||||
|
@ -396,8 +404,8 @@ func copy() -> void:
|
|||
if not project.selection_bitmap.get_bit(pos + offset_pos):
|
||||
to_copy.set_pixelv(pos, Color(0))
|
||||
to_copy.unlock()
|
||||
clipboard.selection_bitmap = project.selection_bitmap.duplicate()
|
||||
clipboard.image = to_copy
|
||||
clipboard.selection_bitmap = project.selection_bitmap.duplicate()
|
||||
clipboard.big_bounding_rectangle = big_bounding_rectangle
|
||||
clipboard.selection_offset = project.selection_offset
|
||||
|
||||
|
@ -405,6 +413,7 @@ func copy() -> void:
|
|||
func paste() -> void:
|
||||
if !clipboard.image:
|
||||
return
|
||||
clear_selection()
|
||||
undo_data = _get_undo_data(true)
|
||||
var project := Global.current_project
|
||||
|
||||
|
@ -412,7 +421,6 @@ func paste() -> void:
|
|||
original_big_bounding_rectangle = big_bounding_rectangle
|
||||
original_offset = Global.current_project.selection_offset
|
||||
|
||||
clear_selection()
|
||||
project.selection_bitmap = clipboard.selection_bitmap.duplicate()
|
||||
self.big_bounding_rectangle = clipboard.big_bounding_rectangle
|
||||
project.selection_offset = clipboard.selection_offset
|
||||
|
|
Loading…
Add table
Reference in a new issue