mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-21 13:03:13 +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:
parent
1d1b8d5984
commit
e9a18f8ea6
4 changed files with 43 additions and 39 deletions
|
@ -389,14 +389,8 @@ func _on_MoveRight_pressed() -> void:
|
||||||
Global.frame_hbox.get_child(frame).change_frame_order(1)
|
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 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.create_action("Change Frame Order")
|
||||||
project.undo_redo.add_do_method(project, "reverse_frames", indices)
|
project.undo_redo.add_do_method(project, "reverse_frames", indices)
|
||||||
project.undo_redo.add_undo_method(project, "reverse_frames", indices)
|
project.undo_redo.add_undo_method(project, "reverse_frames", indices)
|
||||||
|
|
|
@ -70,28 +70,28 @@ 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()
|
Global.animation_timeline.delete_frames(_get_frame_indices())
|
||||||
else: # An example of this would be Space
|
else: # An example of this would be Space
|
||||||
pressed = !pressed
|
pressed = !pressed
|
||||||
|
|
||||||
|
|
||||||
func _on_PopupMenu_id_pressed(id: int) -> void:
|
func _on_PopupMenu_id_pressed(id: int) -> void:
|
||||||
|
var indices := _get_frame_indices()
|
||||||
match id:
|
match id:
|
||||||
REMOVE:
|
REMOVE:
|
||||||
Global.animation_timeline.delete_frames()
|
Global.animation_timeline.delete_frames(indices)
|
||||||
CLONE:
|
CLONE:
|
||||||
Global.animation_timeline.copy_frames()
|
Global.animation_timeline.copy_frames(indices)
|
||||||
MOVE_LEFT:
|
MOVE_LEFT:
|
||||||
change_frame_order(-1)
|
change_frame_order(-1)
|
||||||
MOVE_RIGHT:
|
MOVE_RIGHT:
|
||||||
change_frame_order(1)
|
change_frame_order(1)
|
||||||
PROPERTIES:
|
PROPERTIES:
|
||||||
|
frame_properties.frame_indices = indices
|
||||||
frame_properties.popup_centered()
|
frame_properties.popup_centered()
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
frame_properties.set_frame_label(frame)
|
|
||||||
frame_properties.set_frame_dur(Global.current_project.frames[frame].duration)
|
|
||||||
REVERSE:
|
REVERSE:
|
||||||
Global.animation_timeline.reverse_frames()
|
Global.animation_timeline.reverse_frames(indices)
|
||||||
|
|
||||||
|
|
||||||
func change_frame_order(rate: int) -> void:
|
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.position.x += rect.size.x * x_begin
|
||||||
rect.size.x *= x_end - x_begin
|
rect.size.x *= x_end - x_begin
|
||||||
return rect
|
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
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
extends ConfirmationDialog
|
extends ConfirmationDialog
|
||||||
|
|
||||||
|
var frame_indices := []
|
||||||
onready var frame_num = $VBoxContainer/GridContainer/FrameNum
|
onready var frame_num = $VBoxContainer/GridContainer/FrameNum
|
||||||
onready var frame_dur = $VBoxContainer/GridContainer/FrameTime
|
onready var frame_dur = $VBoxContainer/GridContainer/FrameTime
|
||||||
|
|
||||||
|
|
||||||
func set_frame_label(frame: int) -> void:
|
func _on_FrameProperties_about_to_show() -> void:
|
||||||
frame_num.set_text(str(frame + 1))
|
if frame_indices.size() == 0:
|
||||||
|
frame_num.set_text("")
|
||||||
|
return
|
||||||
func set_frame_dur(duration: float) -> void:
|
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)
|
frame_dur.set_value(duration)
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,24 +21,16 @@ func _on_FrameProperties_popup_hide() -> void:
|
||||||
Global.dialog_open(false)
|
Global.dialog_open(false)
|
||||||
|
|
||||||
|
|
||||||
func _on_FrameProperties_confirmed():
|
func _on_FrameProperties_confirmed() -> void:
|
||||||
var frame: int = int(frame_num.get_text()) - 1
|
var project: Project = Global.current_project
|
||||||
var duration: float = frame_dur.get_value()
|
var new_duration: float = frame_dur.get_value()
|
||||||
var new_duration = Global.current_project.frames[frame].duration
|
project.undos += 1
|
||||||
new_duration = duration
|
project.undo_redo.create_action("Change frame duration")
|
||||||
|
for frame in frame_indices:
|
||||||
Global.current_project.undos += 1
|
project.undo_redo.add_do_property(project.frames[frame], "duration", new_duration)
|
||||||
Global.current_project.undo_redo.create_action("Change frame duration")
|
project.undo_redo.add_undo_property(
|
||||||
|
project.frames[frame], "duration", project.frames[frame].duration
|
||||||
Global.current_project.undo_redo.add_do_property(
|
)
|
||||||
Global.current_project.frames[frame], "duration", new_duration
|
project.undo_redo.add_do_method(Global, "undo_or_redo", false)
|
||||||
)
|
project.undo_redo.add_undo_method(Global, "undo_or_redo", true)
|
||||||
Global.current_project.undo_redo.add_undo_property(
|
project.undo_redo.commit_action()
|
||||||
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()
|
|
||||||
|
|
|
@ -65,5 +65,6 @@ value = 2.0
|
||||||
allow_greater = true
|
allow_greater = true
|
||||||
suffix = "x"
|
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="confirmed" from="." to="." method="_on_FrameProperties_confirmed"]
|
||||||
[connection signal="popup_hide" from="." to="." method="_on_FrameProperties_popup_hide"]
|
[connection signal="popup_hide" from="." to="." method="_on_FrameProperties_popup_hide"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue