mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Remove and copy frame options on the right click menu of the frames now affect all of the selected frames
This behavior is consistent with the clone and remove texture buttons
This commit is contained in:
parent
494673e7bc
commit
180aab6360
|
@ -198,13 +198,7 @@ func add_frame() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_DeleteFrame_pressed() -> void:
|
func _on_DeleteFrame_pressed() -> void:
|
||||||
var indices := []
|
delete_frames()
|
||||||
for cel in Global.current_project.selected_cels:
|
|
||||||
var f: int = cel[0]
|
|
||||||
if not f in indices:
|
|
||||||
indices.append(f)
|
|
||||||
indices.sort()
|
|
||||||
delete_frames(indices)
|
|
||||||
|
|
||||||
|
|
||||||
func delete_frames(indices := []) -> void:
|
func delete_frames(indices := []) -> void:
|
||||||
|
@ -212,10 +206,15 @@ func delete_frames(indices := []) -> void:
|
||||||
if project.frames.size() == 1:
|
if project.frames.size() == 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if indices.size() == 0:
|
||||||
|
for cel in Global.current_project.selected_cels:
|
||||||
|
var f: int = cel[0]
|
||||||
|
if not f in indices:
|
||||||
|
indices.append(f)
|
||||||
|
indices.sort()
|
||||||
|
|
||||||
if indices.size() == project.frames.size():
|
if indices.size() == project.frames.size():
|
||||||
indices.remove(indices.size() - 1) # Ensure the project has at least 1 frame
|
indices.remove(indices.size() - 1) # Ensure the project has at least 1 frame
|
||||||
elif indices.size() == 0:
|
|
||||||
indices.append(project.current_frame)
|
|
||||||
|
|
||||||
var current_frame: int = min(project.current_frame, project.frames.size() - indices.size() - 1)
|
var current_frame: int = min(project.current_frame, project.frames.size() - indices.size() - 1)
|
||||||
var frames := []
|
var frames := []
|
||||||
|
@ -269,20 +268,18 @@ func delete_frames(indices := []) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_CopyFrame_pressed() -> void:
|
func _on_CopyFrame_pressed() -> void:
|
||||||
var indices := []
|
copy_frames()
|
||||||
for cel in Global.current_project.selected_cels:
|
|
||||||
var f: int = cel[0]
|
|
||||||
if not f in indices:
|
|
||||||
indices.append(f)
|
|
||||||
indices.sort()
|
|
||||||
copy_frames(indices)
|
|
||||||
|
|
||||||
|
|
||||||
func copy_frames(indices := [], destination := -1) -> void:
|
func copy_frames(indices := [], destination := -1) -> void:
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
|
|
||||||
if indices.size() == 0:
|
if indices.size() == 0:
|
||||||
indices.append(project.current_frame)
|
for cel in Global.current_project.selected_cels:
|
||||||
|
var f: int = cel[0]
|
||||||
|
if not f in indices:
|
||||||
|
indices.append(f)
|
||||||
|
indices.sort()
|
||||||
|
|
||||||
var copied_frames := []
|
var copied_frames := []
|
||||||
var copied_indices := [] # the indices of newly copied frames
|
var copied_indices := [] # the indices of newly copied frames
|
||||||
|
|
|
@ -63,7 +63,7 @@ func _button_pressed() -> void:
|
||||||
pressed = !pressed
|
pressed = !pressed
|
||||||
elif Input.is_action_just_released("middle_mouse"):
|
elif Input.is_action_just_released("middle_mouse"):
|
||||||
pressed = !pressed
|
pressed = !pressed
|
||||||
Global.animation_timeline.delete_frames([frame])
|
Global.animation_timeline.delete_frames()
|
||||||
else: # An example of this would be Space
|
else: # An example of this would be Space
|
||||||
pressed = !pressed
|
pressed = !pressed
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ func _button_pressed() -> void:
|
||||||
func _on_PopupMenu_id_pressed(id: int) -> void:
|
func _on_PopupMenu_id_pressed(id: int) -> void:
|
||||||
match id:
|
match id:
|
||||||
0: # Remove Frame
|
0: # Remove Frame
|
||||||
Global.animation_timeline.delete_frames([frame])
|
Global.animation_timeline.delete_frames()
|
||||||
1: # Clone Frame
|
1: # Clone Frame
|
||||||
Global.animation_timeline.copy_frames([frame])
|
Global.animation_timeline.copy_frames()
|
||||||
2: # Move Left
|
2: # Move Left
|
||||||
change_frame_order(-1)
|
change_frame_order(-1)
|
||||||
3: # Move Right
|
3: # Move Right
|
||||||
|
@ -86,7 +86,7 @@ func _on_PopupMenu_id_pressed(id: int) -> void:
|
||||||
|
|
||||||
|
|
||||||
func change_frame_order(rate: int) -> void:
|
func change_frame_order(rate: int) -> void:
|
||||||
var change = frame + rate
|
var change := frame + rate
|
||||||
var project = Global.current_project
|
var project = Global.current_project
|
||||||
|
|
||||||
project.undo_redo.create_action("Change Frame Order")
|
project.undo_redo.create_action("Change Frame Order")
|
||||||
|
@ -104,7 +104,7 @@ func change_frame_order(rate: int) -> void:
|
||||||
project.undo_redo.commit_action()
|
project.undo_redo.commit_action()
|
||||||
|
|
||||||
|
|
||||||
func get_drag_data(_position) -> Array:
|
func get_drag_data(_position: Vector2) -> Array:
|
||||||
var button := Button.new()
|
var button := Button.new()
|
||||||
button.rect_size = rect_size
|
button.rect_size = rect_size
|
||||||
button.theme = Global.control.theme
|
button.theme = Global.control.theme
|
||||||
|
@ -114,7 +114,7 @@ func get_drag_data(_position) -> Array:
|
||||||
return ["Frame", frame]
|
return ["Frame", frame]
|
||||||
|
|
||||||
|
|
||||||
func can_drop_data(_pos, data) -> bool:
|
func can_drop_data(_pos: Vector2, data) -> bool:
|
||||||
if typeof(data) == TYPE_ARRAY:
|
if typeof(data) == TYPE_ARRAY:
|
||||||
if data[0] == "Frame":
|
if data[0] == "Frame":
|
||||||
if data[1] != frame: # Can't move to same frame
|
if data[1] != frame: # Can't move to same frame
|
||||||
|
@ -136,7 +136,7 @@ func can_drop_data(_pos, data) -> bool:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
func drop_data(_pos, data) -> void:
|
func drop_data(_pos: Vector2, data) -> void:
|
||||||
var drop_frame = data[1]
|
var drop_frame = data[1]
|
||||||
var project = Global.current_project
|
var project = Global.current_project
|
||||||
project.undo_redo.create_action("Change Frame Order")
|
project.undo_redo.create_action("Change Frame Order")
|
||||||
|
|
Loading…
Reference in a new issue