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

Make frame properties be for all selected frames

And fix issue where the clone, remove and reverse frames always only affected the selected frames and not the frame where the right click occurred (bug introduced some commits ago, it's not present in v0.11).
This commit is contained in:
Emmanouil Papadeas 2023-06-16 19:14:00 +03:00
parent 1d1b8d5984
commit e9a18f8ea6
4 changed files with 43 additions and 39 deletions

View file

@ -389,14 +389,8 @@ func _on_MoveRight_pressed() -> void:
Global.frame_hbox.get_child(frame).change_frame_order(1)
func reverse_frames() -> void:
func reverse_frames(indices := []) -> void:
var project = Global.current_project
var indices := []
for cel in Global.current_project.selected_cels:
var f: int = cel[0]
if not f in indices:
indices.append(f)
indices.sort()
project.undo_redo.create_action("Change Frame Order")
project.undo_redo.add_do_method(project, "reverse_frames", indices)
project.undo_redo.add_undo_method(project, "reverse_frames", indices)

View file

@ -70,28 +70,28 @@ func _button_pressed() -> void:
pressed = !pressed
elif Input.is_action_just_released("middle_mouse"):
pressed = !pressed
Global.animation_timeline.delete_frames()
Global.animation_timeline.delete_frames(_get_frame_indices())
else: # An example of this would be Space
pressed = !pressed
func _on_PopupMenu_id_pressed(id: int) -> void:
var indices := _get_frame_indices()
match id:
REMOVE:
Global.animation_timeline.delete_frames()
Global.animation_timeline.delete_frames(indices)
CLONE:
Global.animation_timeline.copy_frames()
Global.animation_timeline.copy_frames(indices)
MOVE_LEFT:
change_frame_order(-1)
MOVE_RIGHT:
change_frame_order(1)
PROPERTIES:
frame_properties.frame_indices = indices
frame_properties.popup_centered()
Global.dialog_open(true)
frame_properties.set_frame_label(frame)
frame_properties.set_frame_dur(Global.current_project.frames[frame].duration)
REVERSE:
Global.animation_timeline.reverse_frames()
Global.animation_timeline.reverse_frames(indices)
func change_frame_order(rate: int) -> void:
@ -178,3 +178,15 @@ func _get_region_rect(x_begin: float, x_end: float) -> Rect2:
rect.position.x += rect.size.x * x_begin
rect.size.x *= x_end - x_begin
return rect
func _get_frame_indices() -> Array:
var indices := []
for cel in Global.current_project.selected_cels:
var f: int = cel[0]
if not f in indices:
indices.append(f)
indices.sort()
if not frame in indices:
indices = [frame]
return indices

View file

@ -1,14 +1,19 @@
extends ConfirmationDialog
var frame_indices := []
onready var frame_num = $VBoxContainer/GridContainer/FrameNum
onready var frame_dur = $VBoxContainer/GridContainer/FrameTime
func set_frame_label(frame: int) -> void:
frame_num.set_text(str(frame + 1))
func set_frame_dur(duration: float) -> void:
func _on_FrameProperties_about_to_show() -> void:
if frame_indices.size() == 0:
frame_num.set_text("")
return
if frame_indices.size() == 1:
frame_num.set_text(str(frame_indices[0] + 1))
else:
frame_num.set_text("[%s...%s]" % [frame_indices[0] + 1, frame_indices[-1] + 1])
var duration: float = Global.current_project.frames[frame_indices[0]].duration
frame_dur.set_value(duration)
@ -16,24 +21,16 @@ func _on_FrameProperties_popup_hide() -> void:
Global.dialog_open(false)
func _on_FrameProperties_confirmed():
var frame: int = int(frame_num.get_text()) - 1
var duration: float = frame_dur.get_value()
var new_duration = Global.current_project.frames[frame].duration
new_duration = duration
Global.current_project.undos += 1
Global.current_project.undo_redo.create_action("Change frame duration")
Global.current_project.undo_redo.add_do_property(
Global.current_project.frames[frame], "duration", new_duration
)
Global.current_project.undo_redo.add_undo_property(
Global.current_project.frames[frame],
"duration",
Global.current_project.frames[frame].duration
)
Global.current_project.undo_redo.add_do_method(Global, "undo_or_redo", false)
Global.current_project.undo_redo.add_undo_method(Global, "undo_or_redo", true)
Global.current_project.undo_redo.commit_action()
func _on_FrameProperties_confirmed() -> void:
var project: Project = Global.current_project
var new_duration: float = frame_dur.get_value()
project.undos += 1
project.undo_redo.create_action("Change frame duration")
for frame in frame_indices:
project.undo_redo.add_do_property(project.frames[frame], "duration", new_duration)
project.undo_redo.add_undo_property(
project.frames[frame], "duration", project.frames[frame].duration
)
project.undo_redo.add_do_method(Global, "undo_or_redo", false)
project.undo_redo.add_undo_method(Global, "undo_or_redo", true)
project.undo_redo.commit_action()

View file

@ -65,5 +65,6 @@ value = 2.0
allow_greater = true
suffix = "x"
[connection signal="about_to_show" from="." to="." method="_on_FrameProperties_about_to_show"]
[connection signal="confirmed" from="." to="." method="_on_FrameProperties_confirmed"]
[connection signal="popup_hide" from="." to="." method="_on_FrameProperties_popup_hide"]