1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Cut option (#345)

* I Made the cut function, his respective shortcut <c-x> and the appearence of the function in the top
bar in edit.

* Update Main.tscn
This commit is contained in:
PinyaColada 2020-10-08 17:05:33 +02:00 committed by GitHub
parent f15578fbe6
commit 64eb4f27ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 4 deletions

View file

@ -414,6 +414,11 @@ open_docs={
"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":16777255,"unicode":0,"echo":false,"script":null) "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":16777255,"unicode":0,"echo":false,"script":null)
] ]
} }
cut={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":88,"unicode":0,"echo":false,"script":null)
]
}
[locale] [locale]

View file

@ -116,6 +116,26 @@ func copy() -> void:
project.brushes.append(brush) project.brushes.append(brush)
Brushes.add_project_brush(brush) Brushes.add_project_brush(brush)
func cut() -> void: # This is basically the same as copy + delete
if _selected_rect.has_no_area():
return
var undo_data = _get_undo_data(true)
var project := Global.current_project
var image : Image = project.frames[project.current_frame].cels[project.current_layer].image
var size := _selected_rect.size
var rect = Rect2(Vector2.ZERO, size)
_clipboard = image.get_rect(_selected_rect)
if _clipboard.is_invisible():
return
_clear_image.resize(size.x, size.y, Image.INTERPOLATE_NEAREST)
var brush = _clipboard.get_rect(_clipboard.get_used_rect())
project.brushes.append(brush)
Brushes.add_project_brush(brush)
Global.selection_rectangle.move_end() #The selection_rectangle can be used while is moved, this prevents malfunctioning
image.blit_rect(_clear_image, rect, _selected_rect.position)
commit_undo("Draw", undo_data)
func paste() -> void: func paste() -> void:
if _clipboard.get_size() <= Vector2.ZERO: if _clipboard.get_size() <= Vector2.ZERO:

View file

@ -43,6 +43,7 @@ func setup_edit_menu() -> void:
"Undo" : InputMap.get_action_list("undo")[0].get_scancode_with_modifiers(), "Undo" : InputMap.get_action_list("undo")[0].get_scancode_with_modifiers(),
"Redo" : InputMap.get_action_list("redo")[0].get_scancode_with_modifiers(), "Redo" : InputMap.get_action_list("redo")[0].get_scancode_with_modifiers(),
"Copy" : InputMap.get_action_list("copy")[0].get_scancode_with_modifiers(), "Copy" : InputMap.get_action_list("copy")[0].get_scancode_with_modifiers(),
"Cut" : InputMap.get_action_list("cut")[0].get_scancode_with_modifiers(),
"Paste" : InputMap.get_action_list("paste")[0].get_scancode_with_modifiers(), "Paste" : InputMap.get_action_list("paste")[0].get_scancode_with_modifiers(),
"Delete" : InputMap.get_action_list("delete")[0].get_scancode_with_modifiers(), "Delete" : InputMap.get_action_list("delete")[0].get_scancode_with_modifiers(),
"Clear Selection" : 0, "Clear Selection" : 0,
@ -211,14 +212,16 @@ func edit_menu_id_pressed(id : int) -> void:
Global.control.redone = false Global.control.redone = false
2: # Copy 2: # Copy
Global.selection_rectangle.copy() Global.selection_rectangle.copy()
3: # paste 3: # cut
Global.selection_rectangle.cut()
4: # paste
Global.selection_rectangle.paste() Global.selection_rectangle.paste()
4: # Delete 5: # Delete
Global.selection_rectangle.delete() Global.selection_rectangle.delete()
5: # Clear selection 6: # Clear selection
Global.selection_rectangle.set_rect(Rect2(0, 0, 0, 0)) Global.selection_rectangle.set_rect(Rect2(0, 0, 0, 0))
Global.selection_rectangle.select_rect() Global.selection_rectangle.select_rect()
6: # Preferences 7: # Preferences
Global.preferences_dialog.popup_centered(Vector2(400, 280)) Global.preferences_dialog.popup_centered(Vector2(400, 280))
Global.dialog_open(true) Global.dialog_open(true)